Skip to content

Commit 53d1cd3

Browse files
committed
support sanitizers that remove all forward slashes
1 parent 0b74d56 commit 53d1cd3

File tree

3 files changed

+257
-7
lines changed

3 files changed

+257
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,24 @@ module TaintedPath {
213213
output = this
214214
)
215215
or
216-
// non-global replace or replace of something other than /\.\./g
216+
// non-global replace or replace of something other than /\.\./g, /[/]/g, or /[\.]/g.
217217
this.getCalleeName() = "replace" and
218218
input = getReceiver() and
219219
output = this and
220-
not exists(RegExpLiteral literal, RegExpSequence seq |
220+
not exists(RegExpLiteral literal |
221221
getArgument(0).getALocalSource().asExpr() = literal and
222-
literal.isGlobal() and
223-
literal.getRoot() = seq and
224-
seq.getChild(0).(RegExpConstant).getValue() = "." and
225-
seq.getChild(1).(RegExpConstant).getValue() = "." and
226-
seq.getNumChild() = 2
222+
literal.isGlobal()
223+
|
224+
exists(RegExpSequence seq | literal.getRoot() = seq |
225+
seq.getChild(0).(RegExpConstant).getValue() = "." and
226+
seq.getChild(1).(RegExpConstant).getValue() = "." and
227+
seq.getNumChild() = 2
228+
)
229+
or
230+
exists(RegExpCharacterClass choice | literal.getRoot() = choice |
231+
choice.getAMatchedString() = "/" or
232+
choice.getAMatchedString() = "."
233+
)
227234
)
228235
}
229236

0 commit comments

Comments
 (0)