/** * @name Incomplete multi-character sanitization * @description A sanitizer that removes a sequence of characters may reintroduce the dangerous sequence. * @kind problem * @problem.severity warning * @precision high * @id js/incomplete-multi-character-sanitization * @tags correctness * security * external/cwe/cwe-116 * external/cwe/cwe-20 */ import javascript import semmle.javascript.security.IncompleteBlacklistSanitizer predicate isDangerous(RegExpTerm t) { // path traversals t.getAMatchedString() = ["..", "/..", "../"] or exists(RegExpTerm start | start = t.(RegExpSequence).getAChild() and start.getConstantValue() = "." and start.getSuccessor().getConstantValue() = "." and not [start.getPredecessor(), start.getSuccessor().getSuccessor()].getConstantValue() = "." ) or // HTML comments t.getAMatchedString() = "