1
+ /**
2
+ * @name Insecure http parser
3
+ * @description Using an insecure http parser can lead to http smuggling attacks.
4
+ * @kind problem
5
+ * @problem.severity warning
6
+ * @security-severity 6.0
7
+ * @precision high
8
+ * @id js/insecure-http-parser
9
+ * @tags security
10
+ * external/cwe/cwe-444
11
+ */
12
+
13
+ import javascript
14
+
15
+ // from DataFlow::CallNode call
16
+ // where
17
+ // call = DataFlow::moduleMember(importLib(), memberCall()).getACall() and
18
+ // call.getOptionArgument(0, "insecureHTTPParser").analyze().getABooleanValue() = true or
19
+ // call.getOptionArgument(1, "insecureHTTPParser").analyze().getABooleanValue() = true
20
+ // select call.getOptionArgument(0, "insecureHTTPParser"),
21
+ // "This argument allows the use of an insecure parser that accepts invalid HTTP headers."
22
+
23
+ /** Gets options argument for a potential http or https connection */
24
+ DataFlow:: InvokeNode nodeInvocation ( ) {
25
+ result instanceof ClientRequest
26
+ or
27
+ result instanceof Http:: ServerDefinition
28
+ }
29
+
30
+ /** Gets an options object for an http or https connection. */
31
+ DataFlow:: ObjectLiteralNode nodeOptions ( ) { result .flowsTo ( nodeInvocation ( ) .getAnArgument ( ) ) }
32
+
33
+ from DataFlow:: PropWrite disable
34
+ where
35
+ disable = nodeOptions ( ) .getAPropertyWrite ( "insecureHTTPParser" )
36
+ or
37
+ // the same thing, but with API-nodes if they happen to be available
38
+ exists ( API:: Node nodeInvk | nodeInvk .getAnInvocation ( ) = nodeInvocation ( ) |
39
+ disable .getRhs ( ) = nodeInvk .getAParameter ( ) .getMember ( "insecureHTTPParser" ) .asSink ( )
40
+ )
41
+ and
42
+ disable .getRhs ( ) .( AnalyzedNode ) .getTheBooleanValue ( ) = true
43
+ select disable , "Allowing invalid HTTP headers is strongly discouraged."
0 commit comments