File tree Expand file tree Collapse file tree
src/semmle/javascript/security/dataflow
test/query-tests/Security/CWE-022/TaintedPath Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,13 +116,38 @@ module TaintedPath {
116116 name = "pop" or
117117 name = "shift" or
118118 name = "slice" or
119- name = "splice"
119+ name = "splice" or
120+ name = "concat"
120121 ) and
121122 dstlabel instanceof Label:: SplitPath and
122123 srclabel instanceof Label:: SplitPath
123124 or
124125 name = "join" and
125- mcn .getArgument ( 0 ) .mayHaveStringValue ( "/" ) and
126+ mcn .getArgument ( 0 ) .mayHaveStringValue ( "/" ) and
127+ srclabel instanceof Label:: SplitPath and
128+ dstlabel .( Label:: PosixPath ) .canContainDotDotSlash ( )
129+ )
130+ or
131+ // prefix.concat(path)
132+ exists ( DataFlow:: MethodCallNode mcn |
133+ mcn .getMethodName ( ) = "concat" and mcn .getAnArgument ( ) = src
134+ |
135+ dst = mcn and
136+ dstlabel instanceof Label:: SplitPath and
137+ srclabel instanceof Label:: SplitPath
138+ )
139+ or
140+ // reading unknown property of split path
141+ exists ( DataFlow:: PropRead read | read = dst |
142+ src = read .getBase ( ) and
143+ not read .getPropertyName ( ) = "length" and
144+ not exists ( read .getPropertyNameExpr ( ) .getIntValue ( ) ) and
145+ // split[split.length - 1]
146+ not exists ( BinaryExpr binop |
147+ read .getPropertyNameExpr ( ) = binop and
148+ binop .getAnOperand ( ) .getIntValue ( ) = 1 and
149+ binop .getAnOperand ( ) .( PropAccess ) .getPropertyName ( ) = "length"
150+ ) and
126151 srclabel instanceof Label:: SplitPath and
127152 dstlabel .( Label:: PosixPath ) .canContainDotDotSlash ( )
128153 )
You can’t perform that action at this time.
0 commit comments