mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Merge pull request #2741 from esbena/js/split-and-slice-for-tainted-path
Approved by erik-krogh
This commit is contained in:
@@ -67,6 +67,40 @@ module TaintedPath {
|
||||
read.getPropertyName() != "length" and
|
||||
srclabel = dstlabel
|
||||
)
|
||||
or
|
||||
// string method calls of interest
|
||||
exists(DataFlow::MethodCallNode mcn, string name |
|
||||
srclabel = dstlabel and dst = mcn and mcn.calls(src, name)
|
||||
|
|
||||
exists(string substringMethodName |
|
||||
substringMethodName = "substr" or
|
||||
substringMethodName = "substring" or
|
||||
substringMethodName = "slice"
|
||||
|
|
||||
name = substringMethodName and
|
||||
// to avoid very dynamic transformations, require at least one fixed index
|
||||
exists(mcn.getAnArgument().asExpr().getIntValue())
|
||||
)
|
||||
or
|
||||
exists(string argumentlessMethodName |
|
||||
argumentlessMethodName = "toLocaleLowerCase" or
|
||||
argumentlessMethodName = "toLocaleUpperCase" or
|
||||
argumentlessMethodName = "toLowerCase" or
|
||||
argumentlessMethodName = "toUpperCase" or
|
||||
argumentlessMethodName = "trim" or
|
||||
argumentlessMethodName = "trimLeft" or
|
||||
argumentlessMethodName = "trimRight"
|
||||
|
|
||||
name = argumentlessMethodName
|
||||
)
|
||||
or
|
||||
name = "split" and
|
||||
not exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
|
||||
splitBy.mayHaveStringValue("/") or
|
||||
any(DataFlow::RegExpLiteralNode reg | reg.getRoot().getAMatchedString() = "/")
|
||||
.flowsTo(splitBy)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user