Skip to content

io.ratpack:ratpack-core vulnerable to Improper Neutralization of Special Elements in Output ('Injection')

High severity GitHub Reviewed Published Oct 17, 2019 in ratpack/ratpack • Updated Jan 11, 2023

Package

maven io.ratpack:ratpack-core (Maven)

Affected versions

< 1.7.5

Patched versions

1.7.5

Description

CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')

Versions of Ratpack 0.9.1 through and including 1.7.4 are vulnerable to HTTP Response Splitting,
if untrusted and unsanitized data is used to populate the headers of an HTTP response.
An attacker can utilize this vulnerability to have the server issue any HTTP response they specify.

If your application uses arbitrary user input as the value of a response header it is vulnerable.
If your application does not use arbitrary values as response header values, it is not vulnerable.

Previously, Ratpack did not validate response header values.
Now, adding a header value that contains the header value termination characters (CRLF) produces a runtime exception.
Since there is no mechanism for escaping or encoding the termination characters in a String, a runtime exception is necessary.

As potentially dangerous values now cause runtime exceptions, it is a good idea to continue to validate and sanitize any user-supplied values being used as response headers.

We would like to thank Jonathan Leitschuh for reporting this vulnerability.

Vulnerable Example

The following example server uses a query parameter value as a response header, without validating or sanitizing it.

RatpackServer startedServer =  RatpackServer.start(server -> {
    server.handlers(chain -> chain.all(ctx -> {
        // User supplied query parameter
        String header = ctx.getRequest().getQueryParams().get("header");
        // User supplied data used to populate a header value.
        ctx.header("the-header", header)
            .render("OK!");
    }));
});

Sending a request to the server with the following value for the header query param would allow the execution of arbitrary Javascript.

Content-Type: text/html
X-XSS-Protection: 0

<script>alert(document.domain)</script>

Impact

  • Cross-User Defacement
  • Cache Poisoning
  • Cross-Site Scripting
  • Page Hijacking

Patches

This vulnerability has been patched in Ratpack version 1.7.5.

Root Cause

The root cause was due to using the netty DefaultHttpHeaders object with verification disabled.

https://github.com/ratpack/ratpack/blob/af1e8c8590f164d7dd84d4212886fad4ead99080/ratpack-core/src/main/java/ratpack/server/internal/NettyHandlerAdapter.java#L159

This vulnerability is now more clearly documented in the Netty documentation: netty/netty#9646

Workarounds

The workaround for this vulnerability is to either not use arbitrary input as response header values or validate such values before being used to ensure they don't contain a carriage return and/or line feed characters.

References

For more information

If you have any questions or comments about this advisory:

References

@ldaley ldaley published to ratpack/ratpack Oct 17, 2019
Published to the GitHub Advisory Database Oct 21, 2019
Reviewed Jun 16, 2020
Last updated Jan 11, 2023

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

EPSS score

0.206%
(59th percentile)

Weaknesses

CVE ID

CVE-2019-17513

GHSA ID

GHSA-mvqp-q37c-wf9j

Source code

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.