Skip to content

Commit ed53742

Browse files
committed
Python: Fix additional taint-steps for cgi
So there isn't flow from *any* instance to *any* access of the methods, but only from the _actual_ instance where the method is accessed.
1 parent fabc6fb commit ed53742

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

python/ql/src/semmle/python/frameworks/Stdlib.qll

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,14 +1209,21 @@ private module Stdlib {
12091209
private class AdditionalTaintStep extends TaintTracking::AdditionalTaintStep {
12101210
override predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
12111211
// Methods
1212-
nodeFrom = instance() and
1213-
nodeTo in [getvalueRef(), getfirstRef(), getlistRef()]
1214-
or
1215-
nodeFrom = getvalueRef() and nodeTo = getvalueResult()
1216-
or
1217-
nodeFrom = getfirstRef() and nodeTo = getfirstResult()
1212+
exists(DataFlow::AttrRead read | read = nodeTo and read.getObject() = nodeFrom |
1213+
nodeFrom = instance() and
1214+
nodeTo in [getvalueRef(), getfirstRef(), getlistRef()]
1215+
)
12181216
or
1219-
nodeFrom = getlistRef() and nodeTo = getlistResult()
1217+
exists(CallNode call |
1218+
nodeTo.asCfgNode() = call and
1219+
call.getFunction() = nodeFrom.asCfgNode()
1220+
|
1221+
nodeFrom = getvalueRef() and nodeTo = getvalueResult()
1222+
or
1223+
nodeFrom = getfirstRef() and nodeTo = getfirstResult()
1224+
or
1225+
nodeFrom = getlistRef() and nodeTo = getlistResult()
1226+
)
12201227
or
12211228
// Indexing
12221229
nodeFrom in [instance(), fieldList()] and

0 commit comments

Comments
 (0)