Skip to content

Commit 46cbeb0

Browse files
committed
add more steps to the SplitPath label
1 parent 7c69ee1 commit 46cbeb0

4 files changed

Lines changed: 702 additions & 5 deletions

File tree

javascript/ql/src/semmle/javascript/security/dataflow/TaintedPath.qll

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff 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
)

0 commit comments

Comments
 (0)