File tree Expand file tree Collapse file tree 4 files changed +57
-14
lines changed
experimental/semmle/python Expand file tree Collapse file tree 4 files changed +57
-14
lines changed Original file line number Diff line number Diff line change @@ -1025,6 +1025,45 @@ module Http {
1025
1025
}
1026
1026
}
1027
1027
1028
+ /**
1029
+ * A data-flow node that sets a header in an HTTP response.
1030
+ *
1031
+ * Extend this class to model new APIs. If you want to refine existing API models,
1032
+ * extend `ResponseHeaderWrite::Range` instead.
1033
+ */
1034
+ class ResponseHeaderWrite extends DataFlow:: Node instanceof ResponseHeaderWrite:: Range {
1035
+ /**
1036
+ * Gets the argument containing the header name.
1037
+ */
1038
+ DataFlow:: Node getNameArg ( ) { result = super .getNameArg ( ) }
1039
+
1040
+ /**
1041
+ * Gets the argument containing the header value.
1042
+ */
1043
+ DataFlow:: Node getValueArg ( ) { result = super .getValueArg ( ) }
1044
+ }
1045
+
1046
+ /** Provides a class for modelling header writes on HTTP responses. */
1047
+ module ResponseHeaderWrite {
1048
+ /**
1049
+ *A data-flow node that sets a header in an HTTP response.
1050
+ *
1051
+ * Extend this class to model new APIs. If you want to refine existing API models,
1052
+ * extend `ResponseHeaderWrite` instead.
1053
+ */
1054
+ abstract class Range extends DataFlow:: Node {
1055
+ /**
1056
+ * Gets the argument containing the header name.
1057
+ */
1058
+ abstract DataFlow:: Node getNameArg ( ) ;
1059
+
1060
+ /**
1061
+ * Gets the argument containing the header value.
1062
+ */
1063
+ abstract DataFlow:: Node getValueArg ( ) ;
1064
+ }
1065
+ }
1066
+
1028
1067
/**
1029
1068
* A data-flow node that sets a cookie in an HTTP response.
1030
1069
*
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides a taint tracking configuration for reasoning about HTTP header injection.
3
+ */
4
+
1
5
import python
2
- import experimental. semmle.python.Concepts
3
- import semmle.python.dataflow.new.DataFlow
4
- import semmle.python.dataflow.new.TaintTracking
5
- import semmle.python.dataflow.new.RemoteFlowSources
6
+ private import semmle.python.Concepts
7
+ private import semmle.python.dataflow.new.DataFlow
8
+ private import semmle.python.dataflow.new.TaintTracking
9
+ private import semmle.python.dataflow.new.RemoteFlowSources
6
10
7
11
/**
8
- * A taint-tracking configuration for detecting HTTP Header injections .
12
+ * A taint-tracking configuration for detecting HTTP Header injection vulnerabilities .
9
13
*/
10
14
private module HeaderInjectionConfig implements DataFlow:: ConfigSig {
11
15
predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
12
16
13
17
predicate isSink ( DataFlow:: Node sink ) {
14
- exists ( HeaderDeclaration headerDeclaration |
18
+ exists ( Http :: Server :: ResponseHeaderWrite headerDeclaration |
15
19
sink in [ headerDeclaration .getNameArg ( ) , headerDeclaration .getValueArg ( ) ]
16
20
)
17
21
}
Original file line number Diff line number Diff line change 1
1
/**
2
2
* @name HTTP Header Injection
3
- * @description User input should not be used in HTTP headers, otherwise a malicious user
4
- * may be able to inject a value that could manipulate the response .
3
+ * @description Writing user input directly to an HTTP header
4
+ * makes code vulnerable to attack by header splitting .
5
5
* @kind path-problem
6
6
* @problem.severity error
7
+ * @security-severity 6.1
8
+ * @precision high
7
9
* @id py/header-injection
8
10
* @tags security
9
- * experimental
10
11
* external/cwe/cwe-113
11
12
* external/cwe/cwe-079
12
13
*/
13
14
14
- // determine precision above
15
15
import python
16
- import experimental. semmle.python.security.injection.HTTPHeaders
16
+ import semmle.python.security.dataflow.HttpHeaderInjectionQuery
17
17
import HeaderInjectionFlow:: PathGraph
18
18
19
19
from HeaderInjectionFlow:: PathNode source , HeaderInjectionFlow:: PathNode sink
Original file line number Diff line number Diff line change @@ -217,14 +217,14 @@ class SqlEscape extends DataFlow::Node instanceof SqlEscape::Range {
217
217
}
218
218
219
219
/** Provides classes for modeling HTTP Header APIs. */
220
- module HeaderDeclaration {
220
+ deprecated module HeaderDeclaration {
221
221
/**
222
222
* A data-flow node that collects functions setting HTTP Headers.
223
223
*
224
224
* Extend this class to model new APIs. If you want to refine existing API models,
225
225
* extend `HeaderDeclaration` instead.
226
226
*/
227
- abstract class Range extends DataFlow:: Node {
227
+ abstract deprecated class Range extends DataFlow:: Node {
228
228
/**
229
229
* Gets the argument containing the header name.
230
230
*/
@@ -243,7 +243,7 @@ module HeaderDeclaration {
243
243
* Extend this class to refine existing API models. If you want to model new APIs,
244
244
* extend `HeaderDeclaration::Range` instead.
245
245
*/
246
- class HeaderDeclaration extends DataFlow:: Node instanceof HeaderDeclaration:: Range {
246
+ deprecated class HeaderDeclaration extends DataFlow:: Node instanceof HeaderDeclaration:: Range {
247
247
/**
248
248
* Gets the argument containing the header name.
249
249
*/
You can’t perform that action at this time.
0 commit comments