Skip to content

Commit 9e33b47

Browse files
committed
added more additional steps
1 parent e2fe0e1 commit 9e33b47

File tree

1 file changed

+20
-0
lines changed
  • ruby/ql/src/experimental/CWE-522-DecompressionBombs

1 file changed

+20
-0
lines changed

ruby/ql/src/experimental/CWE-522-DecompressionBombs/BombsV2.ql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import codeql.ruby.AST
15+
import codeql.ruby.frameworks.Files
1516
import codeql.ruby.ApiGraphs
1617
import codeql.ruby.DataFlow
1718
import codeql.ruby.dataflow.RemoteFlowSources
@@ -135,6 +136,15 @@ module DecompressionBombs {
135136
}
136137
}
137138

139+
/**
140+
* A call to `IO.copy_stream`
141+
*/
142+
class IoCopyStream extends DataFlow::CallNode {
143+
IoCopyStream() { this = API::getTopLevelMember("IO").getAMethodCall("copy_stream") }
144+
145+
DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
146+
}
147+
138148
class Bombs extends TaintTracking::Configuration {
139149
Bombs() { this = "Decompression Bombs" }
140150

@@ -159,11 +169,21 @@ class Bombs extends TaintTracking::Configuration {
159169
nodeTo = n.getReturn().asSource()
160170
)
161171
or
172+
exists(File::FileOpen n |
173+
nodeFrom = n.getAPathArgument() and
174+
nodeTo = n
175+
)
176+
or
162177
exists(API::Node n | n = API::root().getMember("StringIO").getMethod("new") |
163178
nodeFrom = n.getParameter(0).asSink() and
164179
nodeTo = n.getReturn().asSource()
165180
)
166181
or
182+
exists(IoCopyStream n |
183+
nodeFrom = n.getAPathArgument() and
184+
nodeTo = n
185+
)
186+
or
167187
// following can be a global additional step
168188
exists(DataFlow::CallNode cn |
169189
cn.getMethodName() = "open" and cn.getReceiver().toString() = "self"

0 commit comments

Comments
 (0)