Skip to content

Commit ee21312

Browse files
committed
Add builtin open as an additional step
1 parent 0b27b13 commit ee21312

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

python/ql/src/experimental/Security/UnsafeUnpackQuery.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,15 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
6161
}
6262

6363
override predicate isAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
64-
// Open for access
64+
// Open a file for access
6565
exists(MethodCallNode cn |
6666
nodeTo = cn.getObject() and
6767
cn.getMethodName() = "open" and
6868
cn.flowsTo(nodeFrom)
6969
)
7070
or
71-
// Write for access
72-
exists(MethodCallNode cn |
73-
cn.calls(nodeFrom, "write") and
74-
nodeTo = cn.getArg(0)
75-
)
71+
// Open a file for access using builtin
72+
nodeFrom = API::builtin("open").getACall() and nodeTo = nodeFrom.(API::CallNode).getArg(0)
7673
or
7774
// Retrieve Django uploaded files
7875
// see getlist(): https://docs.djangoproject.com/en/4.1/ref/request-response/#django.http.QueryDict.getlist
@@ -100,7 +97,7 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
10097
nodeTo = mcn
10198
)
10299
or
103-
//Use of join of filename
100+
// Join the base_dir to the filename
104101
nodeTo = API::moduleImport("os").getMember("path").getMember("join").getACall() and
105102
nodeFrom = nodeTo.(API::CallNode).getArg(1)
106103
or

0 commit comments

Comments
 (0)