CVE-2019-17513 (published 2019-10-18T03:15Z)

An issue was discovered in Ratpack before 1.7.5. Due to a misuse of the Netty library class DefaultHttpHeaders, there is no validation that headers lack HTTP control characters. Thus, if untrusted data is used to construct HTTP headers with Ratpack, HTTP Response Splitting can occur.

Severity: MEDIUM
CVSS v2 base score: 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N)

Weakness information:
cwe_id: CWE-74
cwe_name: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
description: The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
extended_description: Software or other automated logic has certain assumptions about what constitutes data and control respectively. It is the lack of verification of these assumptions for user-controlled input that leads to injection problems. Injection problems encompass a wide variety of issues -- all mitigated in very different ways and usually attempted in order to alter the control flow of the process. For this reason, the most effective way to discuss these weaknesses is to note the distinct features that classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed.
         

Fix information:
repo_url: https://github.com/ratpack/ratpack
commit_details: repo_url: https://github.com/ratpack/ratpack
author: Luke Daley
author_date: 2019-10-09 09:43:23+10:00
msg: Add test for response header validation
repository: repo_url: https://github.com/ratpack/ratpack
repo_name: ratpack/ratpack
description: Lean & powerful HTTP apps
repo_language: Java
owner: ratpack
file_changes: filename: ResponseHeaderValidationSpec.groovy
change_type: ModificationType.ADD
diff: @@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ratpack.http
+
+import ratpack.test.internal.RatpackGroovyDslSpec
+
+class ResponseHeaderValidationSpec extends RatpackGroovyDslSpec {
+
+  def "invalid header values yield exception"() {
+    when:
+    handlers {
+      all {
+        try {
+          header("Test", "value\r\nAnotherHeader: another value")
+          render "ok"
+        } catch (e) {
+          render e.toString()
+        }
+      }
+    }
+
+    then:
+    def response = get()
+    response.headers.names == ['content-type', 'content-length'].toSet()
+    response.body.text == "java.lang.IllegalArgumentException: only ' ' and '\\t' are allowed after '\\n': value\r\nAnotherHeader: another value"
+  }
+
+}

programming_language: Scala
repo_url: https://github.com/ratpack/ratpack
commit_details: repo_url: https://github.com/ratpack/ratpack
author: Luke Daley
author_date: 2019-10-09 09:24:24+10:00
msg: Enable HTTP header validation
repository: repo_url: https://github.com/ratpack/ratpack
repo_name: ratpack/ratpack
description: Lean & powerful HTTP apps
repo_language: Java
owner: ratpack
file_changes: filename: NettyHandlerAdapter.java
change_type: ModificationType.MODIFY
diff: @@ -156,7 +156,7 @@ public class NettyHandlerAdapter extends ChannelInboundHandlerAdapter {
       channel.attr(CLIENT_CERT_KEY).get()
     );
 
-    HttpHeaders nettyHeaders = new DefaultHttpHeaders(false);
+    HttpHeaders nettyHeaders = new DefaultHttpHeaders();
     MutableHeaders responseHeaders = new NettyHeadersBackedMutableHeaders(nettyHeaders);
     AtomicBoolean transmitted = new AtomicBoolean(false);
 

programming_language: Java