Skip to content

Commit 4dcf944

Browse files
committed
use StringSplitCall in TaintedPath
1 parent 22ec12b commit 4dcf944

File tree

2 files changed

+109
-283
lines changed

2 files changed

+109
-283
lines changed

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,17 @@ module TaintedPath {
9797
)
9898
)
9999
or
100+
// A `str.split()` call can either split into path elements (`str.split("/")`) or split by some other string.
101+
exists(StringSplitCall mcn | dst = mcn and mcn.getUnsplit() = src |
102+
if mcn.getSplitAt() = "/"
103+
then
104+
srclabel.(Label::PosixPath).canContainDotDotSlash() and
105+
dstlabel instanceof Label::SplitPath
106+
else srclabel = dstlabel
107+
)
108+
or
100109
// array method calls of interest
101110
exists(DataFlow::MethodCallNode mcn, string name | dst = mcn and mcn.calls(src, name) |
102-
// A `str.split()` call can either split into path elements (`str.split("/")`) or split by some other string.
103-
name = "split" and
104-
(
105-
if
106-
exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
107-
splitBy.mayHaveStringValue("/") or
108-
any(DataFlow::RegExpCreationNode reg | reg.getRoot().getAMatchedString() = "/")
109-
.flowsTo(splitBy)
110-
)
111-
then
112-
srclabel.(Label::PosixPath).canContainDotDotSlash() and
113-
dstlabel instanceof Label::SplitPath
114-
else srclabel = dstlabel
115-
)
116-
or
117111
(
118112
name = "pop" or
119113
name = "shift"

0 commit comments

Comments
 (0)