3
3
* @description Using an insecure http parser can lead to http smuggling attacks.
4
4
* @kind problem
5
5
* @problem.severity warning
6
- * @security-severity 6 .0
6
+ * @security-severity 9 .0
7
7
* @precision high
8
8
* @id js/insecure-http-parser
9
9
* @tags security
12
12
13
13
import javascript
14
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
15
/** Gets options argument for a potential http or https connection */
24
16
DataFlow:: InvokeNode nodeInvocation ( ) {
25
17
result instanceof ClientRequest
@@ -32,12 +24,19 @@ DataFlow::ObjectLiteralNode nodeOptions() { result.flowsTo(nodeInvocation().getA
32
24
33
25
from DataFlow:: PropWrite disable
34
26
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 ( )
27
+ exists ( DataFlow:: SourceNode env |
28
+ env = NodeJSLib:: process ( ) .getAPropertyRead ( "env" ) and
29
+ disable = env .getAPropertyWrite ( "NODE_OPTIONS" ) and
30
+ disable .getRhs ( ) .getStringValue ( ) .regexpMatch ( ".*--insecure-http-parser.*" )
40
31
)
41
- and
32
+ or
33
+ (
34
+ disable = nodeOptions ( ) .getAPropertyWrite ( "insecureHTTPParser" )
35
+ or
36
+ // the same thing, but with API-nodes if they happen to be available
37
+ exists ( API:: Node nodeInvk | nodeInvk .getAnInvocation ( ) = nodeInvocation ( ) |
38
+ disable .getRhs ( ) = nodeInvk .getAParameter ( ) .getMember ( "insecureHTTPParser" ) .asSink ( )
39
+ )
40
+ ) and
42
41
disable .getRhs ( ) .( AnalyzedNode ) .getTheBooleanValue ( ) = true
43
- select disable , "Allowing invalid HTTP headers is strongly discouraged."
42
+ select disable , "Allowing invalid HTTP headers is strongly discouraged."
0 commit comments