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 {
10251025 }
10261026 }
10271027
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+
10281067 /**
10291068 * A data-flow node that sets a cookie in an HTTP response.
10301069 *
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+
15import 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
610
711/**
8- * A taint-tracking configuration for detecting HTTP Header injections .
12+ * A taint-tracking configuration for detecting HTTP Header injection vulnerabilities .
913 */
1014private module HeaderInjectionConfig implements DataFlow:: ConfigSig {
1115 predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
1216
1317 predicate isSink ( DataFlow:: Node sink ) {
14- exists ( HeaderDeclaration headerDeclaration |
18+ exists ( Http :: Server :: ResponseHeaderWrite headerDeclaration |
1519 sink in [ headerDeclaration .getNameArg ( ) , headerDeclaration .getValueArg ( ) ]
1620 )
1721 }
Original file line number Diff line number Diff line change 11/**
22 * @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 .
55 * @kind path-problem
66 * @problem.severity error
7+ * @security-severity 6.1
8+ * @precision high
79 * @id py/header-injection
810 * @tags security
9- * experimental
1011 * external/cwe/cwe-113
1112 * external/cwe/cwe-079
1213 */
1314
14- // determine precision above
1515import python
16- import experimental. semmle.python.security.injection.HTTPHeaders
16+ import semmle.python.security.dataflow.HttpHeaderInjectionQuery
1717import HeaderInjectionFlow:: PathGraph
1818
1919from 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 {
217217}
218218
219219/** Provides classes for modeling HTTP Header APIs. */
220- module HeaderDeclaration {
220+ deprecated module HeaderDeclaration {
221221 /**
222222 * A data-flow node that collects functions setting HTTP Headers.
223223 *
224224 * Extend this class to model new APIs. If you want to refine existing API models,
225225 * extend `HeaderDeclaration` instead.
226226 */
227- abstract class Range extends DataFlow:: Node {
227+ abstract deprecated class Range extends DataFlow:: Node {
228228 /**
229229 * Gets the argument containing the header name.
230230 */
@@ -243,7 +243,7 @@ module HeaderDeclaration {
243243 * Extend this class to refine existing API models. If you want to model new APIs,
244244 * extend `HeaderDeclaration::Range` instead.
245245 */
246- class HeaderDeclaration extends DataFlow:: Node instanceof HeaderDeclaration:: Range {
246+ deprecated class HeaderDeclaration extends DataFlow:: Node instanceof HeaderDeclaration:: Range {
247247 /**
248248 * Gets the argument containing the header name.
249249 */
You can’t perform that action at this time.
0 commit comments