Skip to content

Commit dcbd6e0

Browse files
committed
Add CWE-113 check for io.netty.handler.codec.http.DefaultHttpHeaders
Closes #2185
1 parent fe2988a commit dcbd6e0

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-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 CLRF 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java
2+
3+
from ClassInstanceExpr new
4+
where
5+
new.getConstructedType().hasQualifiedName("io.netty.handler.codec.http", "DefaultHttpHeaders") and
6+
new.getArgument(0).getProperExpr().(BooleanLiteral).getBooleanValue() = false
7+
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)