From cde6a6d7d1d7bc20318d6583379985a460a88bcd Mon Sep 17 00:00:00 2001 From: Jonathan Leitschuh Date: Thu, 10 Oct 2019 14:47:28 -0400 Subject: [PATCH] [DOC] Add CWE-113 warning to DefaultHttpHeaders constructor (#9646) ### Motivation: I've now found two libraries that use Netty to be vulnerable to [CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')](https://cwe.mitre.org/data/definitions/113.html) due to using `new DefaultHttpHeaders(false)`. Some part of me hopes that this warning will help dissuade library authors from disabling this important security check. ### Modification: Add documentation to `DefaultHttpHeaders(boolean)` to warn about the implications of `false`. ### Result: This improves the documentation on `DefaultHttpHeaders`. --- .../netty/handler/codec/http/DefaultHttpHeaders.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java index fc1b615dc6..ab956cad05 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpHeaders.java @@ -72,6 +72,18 @@ public class DefaultHttpHeaders extends HttpHeaders { this(true); } + /** + * Warning! Setting validate to false will mean that Netty won't + * validate & protect against user-supplied header values that are malicious. + * This can leave your server implementation vulnerable to + * + * CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting') + * . + * When disabling this validation, it is the responsibility of the caller to ensure that the values supplied + * do not contain a non-url-escaped carriage return (CR) and/or line feed (LF) characters. + * + * @param validate Should Netty validate Header values to ensure they aren't malicious. + */ public DefaultHttpHeaders(boolean validate) { this(validate, nameValidator(validate)); }