Merge pull request #7076 from asgerf/js/tainted-path-regexp-guard2

Approved by erik-krogh
This commit is contained in:
CodeQL CI
2021-11-09 03:40:37 -08:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -459,7 +459,7 @@ module TaintedPath {
* An expression of form `x.matches(/\.\./)` or similar.
*/
class ContainsDotDotRegExpSanitizer extends BarrierGuardNode instanceof StringOps::RegExpTest {
ContainsDotDotRegExpSanitizer() { super.getRegExp().getConstantValue() = [".", "..", "../"] }
ContainsDotDotRegExpSanitizer() { super.getRegExp().getAMatchedString() = [".", "..", "../"] }
override predicate blocks(boolean outcome, Expr e, DataFlow::FlowLabel label) {
e = super.getStringOperand().asExpr() and

View File

@@ -398,4 +398,7 @@ app.get('/dotdot-regexp', (req, res) => {
if (!path.match(/\.\.\/foo/)) {
fs.readFileSync(path); // NOT OK
}
if (!path.match(/(\.\.\/|\.\.\\)/)) {
fs.readFileSync(path); // OK
}
});