Merge pull request #958 from esben-semmle/js/improve-tainted-path

JS: add taint steps for fs.realpath and fs.realpathSync
This commit is contained in:
Max Schaefer
2019-02-22 20:55:39 +00:00
committed by GitHub
3 changed files with 58 additions and 0 deletions

View File

@@ -267,6 +267,31 @@ module NodeJSLib {
}
}
/**
* A call to a fs-module method that preserves taint.
*/
private class FsFlowTarget extends TaintTracking::AdditionalTaintStep {
DataFlow::Node tainted;
FsFlowTarget() {
exists(DataFlow::CallNode call, string methodName |
call = DataFlow::moduleMember("fs", methodName).getACall()
|
methodName = "realpathSync" and
tainted = call.getArgument(0) and
this = call
or
methodName = "realpath" and
tainted = call.getArgument(0) and
this = call.getCallback(1).getParameter(1)
)
}
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
pred = tainted and succ = this
}
}
/**
* A model of taint propagation through `new Buffer` and `Buffer.from`.
*/