Skip to content

Commit a4aaf0e

Browse files
committed
Remove a write step & update the builtin open step
1 parent 0e2f378 commit a4aaf0e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
6666
or
6767
// Open a file for access
6868
exists(MethodCallNode cn |
69-
nodeTo = cn.getObject() and
70-
cn.getMethodName() = "open" and
69+
cn.calls(nodeTo, "open") and
70+
cn.flowsTo(nodeFrom)
71+
)
72+
or
73+
// Open a file for access using builtin
74+
exists(API::CallNode cn |
75+
cn = API::builtin("open").getACall() and
76+
nodeTo = cn.(API::CallNode).getArg(0) and
7177
cn.flowsTo(nodeFrom)
7278
)
7379
or
@@ -77,22 +83,11 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
7783
nodeFrom = cn.getArg(0)
7884
)
7985
or
80-
// Open a file for access using builtin
81-
nodeFrom = API::builtin("open").getACall() and nodeTo = nodeFrom.(API::CallNode).getArg(0)
82-
or
8386
// Retrieve Django uploaded files
8487
// see getlist(): https://docs.djangoproject.com/en/4.1/ref/request-response/#django.http.QueryDict.getlist
8588
// see chunks(): https://docs.djangoproject.com/en/4.1/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.chunks
8689
nodeTo.(MethodCallNode).calls(nodeFrom, ["getlist", "get", "chunks"])
8790
or
88-
// Writing the response data to the archive
89-
exists(Stdlib::FileLikeObject::InstanceSource is, Node f, MethodCallNode mc |
90-
is.flowsTo(f) and
91-
mc.calls(f, "write") and
92-
nodeFrom = mc.getArg(0) and
93-
nodeTo = is.(CallCfgNode).getArg(0)
94-
)
95-
or
9691
// Considering the use of "fs"
9792
exists(API::CallNode fs, MethodCallNode mcn |
9893
fs =

0 commit comments

Comments
 (0)