mirror of
https://github.com/github/codeql.git
synced 2026-06-05 21:47:10 +02:00
Python: recover taint for % format strings
This commit is contained in:
committed by
Owen Mansel-Chan
parent
b67694b2ab
commit
facb3b681d
@@ -1093,10 +1093,21 @@ module Conversions {
|
||||
)
|
||||
}
|
||||
|
||||
predicate formatReadStep(Node nodeFrom, ContentSet c, Node nodeTo) {
|
||||
// % formatting
|
||||
exists(BinaryExprNode fmt | fmt = nodeTo.asCfgNode() |
|
||||
fmt.getOp() instanceof Mod and
|
||||
fmt.getRight() = nodeFrom.asCfgNode()
|
||||
) and
|
||||
c instanceof TupleElementContent
|
||||
}
|
||||
|
||||
predicate readStep(Node nodeFrom, ContentSet c, Node nodeTo) {
|
||||
decoderReadStep(nodeFrom, c, nodeTo)
|
||||
or
|
||||
encoderReadStep(nodeFrom, c, nodeTo)
|
||||
or
|
||||
formatReadStep(nodeFrom, c, nodeTo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ def percent_fmt():
|
||||
ensure_tainted(
|
||||
tainted_fmt % (1, 2), # $ tainted
|
||||
"%s foo bar" % ts, # $ tainted
|
||||
"%s %s %s" % (1, 2, ts), # $ MISSING: tainted
|
||||
"%s %s %s" % (1, 2, ts), # $ tainted
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user