Skip to content

Commit 25ffcb2

Browse files
Split into customizations file
1 parent 6021d92 commit 25ffcb2

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Provides default sources, sinks, and sanitizers for detecting
3+
* "HTTP Header injection" vulnerabilities, as well as extension
4+
* points for adding your own.
5+
*/
6+
7+
import python
8+
private import semmle.python.Concepts
9+
private import semmle.python.dataflow.new.DataFlow
10+
private import semmle.python.dataflow.new.TaintTracking
11+
private import semmle.python.dataflow.new.RemoteFlowSources
12+
13+
/**
14+
* Provides default sources, sinks, and sanitizers for detecting
15+
* "HTTP Header injection" vulnerabilities, as well as extension
16+
* points for adding your own.
17+
*/
18+
module HttpHeaderInjection {
19+
/**
20+
* A data flow source for "HTTP Header injection" vulnerabilities.
21+
*/
22+
abstract class Source extends DataFlow::Node { }
23+
24+
/**
25+
* A data flow sink for "HTTP Header injection" vulnerabilities.
26+
*/
27+
abstract class Sink extends DataFlow::Node { }
28+
29+
/**
30+
* A data flow sanitizer for "HTTP Header injection" vulnerabilities.
31+
*/
32+
abstract class Sanitizer extends DataFlow::Node { }
33+
34+
/**
35+
* A source of remote user input, considered as a flow source.
36+
*/
37+
class RemoteFlowSourceAsSource extends Source, RemoteFlowSource { }
38+
39+
/**
40+
* A HTTP header write, considered as a flow sink.
41+
*/
42+
class HeaderWriteAsSink extends Sink {
43+
HeaderWriteAsSink() {
44+
exists(Http::Server::ResponseHeaderWrite headerDeclaration |
45+
this in [headerDeclaration.getNameArg(), headerDeclaration.getValueArg()]
46+
)
47+
}
48+
}
49+
}

python/ql/lib/semmle/python/security/dataflow/HttpHeaderInjectionQuery.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
*/
44

55
import python
6-
private import semmle.python.Concepts
76
private import semmle.python.dataflow.new.DataFlow
87
private import semmle.python.dataflow.new.TaintTracking
9-
private import semmle.python.dataflow.new.RemoteFlowSources
8+
private import HttpHeaderInjectionCustomizations
109

1110
/**
1211
* A taint-tracking configuration for detecting HTTP Header injection vulnerabilities.
1312
*/
1413
private module HeaderInjectionConfig implements DataFlow::ConfigSig {
15-
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
14+
predicate isSource(DataFlow::Node node) { node instanceof HttpHeaderInjection::Source }
1615

17-
predicate isSink(DataFlow::Node sink) {
18-
exists(Http::Server::ResponseHeaderWrite headerDeclaration |
19-
sink in [headerDeclaration.getNameArg(), headerDeclaration.getValueArg()]
20-
)
21-
}
16+
predicate isSink(DataFlow::Node node) { node instanceof HttpHeaderInjection::Sink }
17+
18+
predicate isBarrier(DataFlow::Node node) { node instanceof HttpHeaderInjection::Sanitizer }
2219
}
2320

2421
/** Global taint-tracking for detecting "HTTP Header injection" vulnerabilities. */

0 commit comments

Comments
 (0)