Skip to content

Commit 3be916e

Browse files
committed
Polish FlaskHeaderCall
1 parent 46c5cb1 commit 3be916e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

python/ql/src/experimental/Security/CWE-113/HeaderInjection.ql

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ class WerkzeugHeaderCall extends DataFlow::CallCfgNode {
3131
DataFlow::Node getHeaderInputNode() { result = this.getArg(1) }
3232
}
3333

34-
class FlaskHeader extends DataFlow::Node {
35-
FlaskHeader() {
34+
class FlaskHeaderCall extends DataFlow::CallCfgNode {
35+
DataFlow::Node headerInputNode;
36+
37+
FlaskHeaderCall() {
3638
exists(
3739
DataFlow::CallCfgNode headerInstance, DataFlow::AttrRead responseMethod,
3840
AssignStmt sinkDeclaration
@@ -41,9 +43,12 @@ class FlaskHeader extends DataFlow::Node {
4143
responseMethod.getAttributeName() = "headers" and
4244
responseMethod.getObject().getALocalSource() = headerInstance and
4345
sinkDeclaration.getATarget() = responseMethod.asExpr().getParentNode() and
44-
this.asExpr() = sinkDeclaration.getValue()
46+
headerInputNode.asExpr() = sinkDeclaration.getValue() and
47+
this.getFunction() = responseMethod
4548
)
4649
}
50+
51+
DataFlow::Node getHeaderInputNode() { result = headerInputNode }
4752
}
4853

4954
class FlaskMakeResponse extends DataFlow::Node {
@@ -69,8 +74,8 @@ class FlaskMakeResponse extends DataFlow::Node {
6974

7075
class HeaderInjectionSink extends DataFlow::Node {
7176
HeaderInjectionSink() {
72-
this instanceof WerkzeugHeader or
73-
this instanceof FlaskHeader or
77+
this instanceof WerkzeugHeaderCall or
78+
this instanceof FlaskHeaderCall or
7479
this instanceof FlaskMakeResponse
7580
}
7681
}

0 commit comments

Comments
 (0)