Skip to content

Commit 2539e2e

Browse files
committed
Python: slightly improve tarslip logic
1 parent 1087087 commit 2539e2e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

python/ql/lib/semmle/python/security/dataflow/TarSlipCustomizations.qll

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,19 @@ module TarSlip {
8484
* A sink capturing method calls to `extractall`.
8585
*
8686
* For a call to `file.extractall`, `file` is considered a sink if
87-
*
88-
* - there are no other arguments, or
89-
* - there are other arguments (except `members`), and the extraction filter is unsafe.
87+
* there is no `members` argument and the extraction filter is unsafe.
9088
*/
9189
class ExtractAllSink extends Sink {
9290
ExtractAllSink() {
93-
exists(DataFlow::CallCfgNode call |
91+
exists(API::CallNode call |
9492
call =
9593
API::moduleImport("tarfile")
9694
.getMember("open")
9795
.getReturn()
9896
.getMember("extractall")
9997
.getACall() and
100-
(
101-
not exists(call.getArg(_)) and
102-
not exists(call.getArgByName(_))
103-
or
104-
hasUnsafeFilter(call)
105-
) and
106-
not exists(call.getArgByName("members")) and
98+
hasUnsafeFilter(call) and
99+
not exists(call.getParameter(2, "members")) and
107100
this = call.(DataFlow::MethodCallNode).getObject()
108101
)
109102
}

0 commit comments

Comments
 (0)