Skip to content

Commit 0ffcf9c

Browse files
authored
Merge pull request #2192 from JLLeitschuh/feature/JLL/http_response_splitting_netty
Add CWE-113 check for io.netty.handler.codec.http.DefaultHttpHeaders
2 parents 70b114b + 934eed9 commit 0ffcf9c

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import io.netty.handler.codec.http.DefaultHttpHeaders;
2+
3+
public class ResponseSplitting {
4+
// BAD: Disables the internal response splitting verification
5+
private final DefaultHttpHeaders badHeaders = new DefaultHttpHeaders(false);
6+
7+
// GOOD: Verifies headers passed don't contain CRLF characters
8+
private final DefaultHttpHeaders badHeaders = new DefaultHttpHeaders();
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
<include src="ResponseSplitting.qhelp" /></qhelp>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @name Disabled Netty HTTP header validation
3+
* @description Disabling HTTP header validation makes code vulnerable to
4+
* attack by header splitting if user input is written directly to
5+
* an HTTP header.
6+
* @kind problem
7+
* @problem.severity error
8+
* @precision high
9+
* @id java/netty-http-response-splitting
10+
* @tags security
11+
* external/cwe/cwe-113
12+
*/
13+
14+
import java
15+
16+
from ClassInstanceExpr new
17+
where
18+
new.getConstructedType().hasQualifiedName("io.netty.handler.codec.http", "DefaultHttpHeaders") and
19+
new.getArgument(0).getProperExpr().(BooleanLiteral).getBooleanValue() = false
20+
select new, "Response-splitting vulnerability due to verification being disabled."

java/ql/src/Security/CWE/CWE-113/ResponseSplitting.qhelp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ characters, thus avoiding the potential problem.</p>
2626
<sample src="ResponseSplitting.java" />
2727
</example>
2828

29+
<example>
30+
<p>The following example shows the use of the library 'netty' with HTTP response-splitting verification configurations.
31+
The second way will verify the parameters before using them to build the HTTP response.</p>
32+
33+
<sample src="NettyResponseSplitting.java" />
34+
</example>
35+
2936
<references>
3037
<li>
3138
InfosecWriters: <a href="http://www.infosecwriters.com/Papers/DCrab_HTTP_Response.pdf">HTTP response splitting</a>.

0 commit comments

Comments
 (0)