@@ -61,13 +61,22 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
61
61
}
62
62
63
63
override predicate isAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
64
+ // Reading the response
65
+ nodeTo .( MethodCallNode ) .calls ( nodeFrom , "read" )
66
+ or
64
67
// Open a file for access
65
68
exists ( MethodCallNode cn |
66
69
nodeTo = cn .getObject ( ) and
67
70
cn .getMethodName ( ) = "open" and
68
71
cn .flowsTo ( nodeFrom )
69
72
)
70
73
or
74
+ // Write access
75
+ exists ( MethodCallNode cn |
76
+ cn .calls ( nodeTo , "write" ) and
77
+ nodeFrom = cn .getArg ( 0 )
78
+ )
79
+ or
71
80
// Open a file for access using builtin
72
81
nodeFrom = API:: builtin ( "open" ) .getACall ( ) and nodeTo = nodeFrom .( API:: CallNode ) .getArg ( 0 )
73
82
or
@@ -76,11 +85,13 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
76
85
// see chunks(): https://docs.djangoproject.com/en/4.1/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.chunks
77
86
nodeTo .( MethodCallNode ) .calls ( nodeFrom , [ "getlist" , "get" , "chunks" ] )
78
87
or
79
- // Reading the response
80
- nodeTo .( MethodCallNode ) .calls ( nodeFrom , "read" )
81
- or
82
- // Accessing the name or raw content
83
- nodeTo .( AttrRead ) .accesses ( nodeFrom , [ "name" , "raw" ] )
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
+ )
84
95
or
85
96
// Considering the use of "fs"
86
97
exists ( API:: CallNode fs , MethodCallNode mcn |
@@ -97,22 +108,11 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
97
108
nodeTo = mcn
98
109
)
99
110
or
111
+ // Accessing the name or raw content
112
+ nodeTo .( AttrRead ) .accesses ( nodeFrom , [ "name" , "raw" ] )
113
+ or
100
114
// Join the base_dir to the filename
101
115
nodeTo = API:: moduleImport ( "os" ) .getMember ( "path" ) .getMember ( "join" ) .getACall ( ) and
102
116
nodeFrom = nodeTo .( API:: CallNode ) .getArg ( 1 )
103
- or
104
- // Write access
105
- exists ( MethodCallNode cn |
106
- cn .calls ( nodeTo , "write" ) and
107
- nodeFrom = cn .getArg ( 0 )
108
- )
109
- or
110
- // Writing the response data to the archive
111
- exists ( Stdlib:: FileLikeObject:: InstanceSource is , Node f , MethodCallNode mc |
112
- is .flowsTo ( f ) and
113
- mc .calls ( f , "write" ) and
114
- nodeFrom = mc .getArg ( 0 ) and
115
- nodeTo = is .( CallCfgNode ) .getArg ( 0 )
116
- )
117
117
}
118
118
}
0 commit comments