CVE-2020-6858: Styx api HTTP Response Splitting Vulnerability

MODERATE
Advisory Identifier: GHSA-6v7p-v754-j89v
CVSS 6.5
CWE-74
Published
Advisory Summary

CVE-2020-6858 is a MODERATE (CVSS 6.5) http response splitting vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Styx api libraries in the Maven ecosystem. The issue involves http response splitting in styx. Remediation is available by upgrading affected packages to version 1.0.0-rc1.

CVE-2020-6858 at a Glance

CVE Identifier CVE-2020-6858
GHSA Identifier GHSA-6v7p-v754-j89v
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Styx api
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2020-6858

To remediate this vulnerability, upgrade all affected Styx api dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

com.hotels.styx:styx-api fixed: 1.0.0-rc1
<dependency>
    <groupId>com.hotels.styx</groupId>
    <artifactId>styx-api</artifactId>
    <version>1.0.0-rc1</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=com.hotels.styx

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2020-6858, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.hotels.styx

Analyze the terminal output to locate any version of Styx api in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0-rc1), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.hotels.styx command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where 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. In Styx api, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# Vulnerability Styx is vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers (&#39;HTTP Response Splitting&#39;). # Vulnerable Component The vulnerable component is the `com.hotels.styx.api.HttpHeaders.Builder` due to disabling the HTTP Header validation built into Netty in these locations: https://github.com/HotelsDotCom/styx/blob/e1d578e9b9c38df9cd19c21dc2eb9b949d85b558/components/api/src/main/java/com/hotels/styx/api/HttpHeaders.java#L145 https://github.com/HotelsDotCom/styx/blob/e1d578e9b9c38df9cd19c21dc2eb9b949d85b558/components/api/src/main/java/com/hotels/styx/api/HttpHeaders.java#L145 `new DefaultHttpHeaders(false)` disables the built-in validation in Netty. Either use the default constructor or `new DefaultHttpHeaders(true` instead. Additionally, another vulnerable component is the StyxToNettyResponseTranslator due to also disabling the HTTP Header validation built into netty in this location. https://github.com/HotelsDotCom/styx/blob/8d60e5493e65d0d536afc0b350dcb02d24e0f7a7/components/server/src/main/java/com/hotels/styx/server/netty/connectors/StyxToNettyResponseTranslator.java#L30 `DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, false); ` `new DefaultHttpResponse(version, httpResponseStatus, false);` disables the built-in validation in Netty. Please use the constructor `new DefaultHttpResponse(version, httpResponseStatus, true);` # Proof of Concept The following test plugin proves that there is no header validation occurring. ```java static class VulnerablePlugin implements Plugin { @Override public Eventual&lt;LiveHttpResponse&gt; intercept(LiveHttpRequest request, Chain chain) { String header = request.queryParam(&quot;header-value&quot;).get(); LiveHttpRequest newRequest = request.newBuilder() .header(&quot;myRequestHeader&quot;, header) .build(); return chain.proceed(newRequest).map(response -&gt; response.newBuilder().header(&quot;myResponseHeader&quot;, header).build() ) ; } } @Test public void simpleHeaderInjectionVulnerabilityPOC() { Plugin vulnerablePlugin = new VulnerablePlugin(); // a simple way to mock the downstream system HttpInterceptor.Chain chain = request -&gt; { assertThat(request.header(&quot;myRequestHeader&quot;).orElse(null), is(&quot;test\r\nAnother: CRLF_Injection&quot;)); return Eventual.of(response(OK).build()); }; // an example request you expect your plugin to receive String encodedGet = URLEncoder.encode(&quot;test\r\nAnother: CRLF_Injection&quot;); LiveHttpRequest request = get(&quot;/foo?header-value=&quot; + encodedGet) .build(); // since this is a test, we want to wait for the response LiveHttpResponse response = Mono.from(vulnerablePlugin.intercept(request, chain)).block(); assertThat(response.header(&quot;myResponseHeader&quot;).orElse(null), is(&quot;test\r\nAnother: CRLF_Injection&quot;)); } ``` Additionally, if you run this LiveHttpResponse from this test through the `StyxToNettyResponseTranslator::toNettyResponse`, ideally, it would have caused an exception to be thrown. In its current state, it does not. # Similar Vulnerabilities There have been reports of similar vulnerabilities in other popular libraries. GHSA-35fr-h7jr-hh86 -&gt; CVE-2019-16771 GHSA-mvqp-q37c-wf9j -&gt; CVE-2019-17513 # Finding This vulnerability was found due to this query that [Jonathan Leitschuh](https://twitter.com/jlleitschuh) contributed to the Semmle QL project. https://lgtm.com/rules/1510696449842/alerts/

CVE-2020-6858 Affected Styx api Versions

1 component(s)
Fixed Versions:
1.0.0-rc1
Product / Package Ecosystem Affected Versions Fixed Version
com.hotels.styx:styx-api
Maven
< 1.0.0-rc1
1.0.0-rc1

References

Frequently Asked Questions

What is CVE-2020-6858?
CVE-2020-6858 is a security vulnerability in Styx api involving HTTP Response Splitting in Styx under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Styx api versions are affected?
Affected versions include releases prior to 1.0.0-rc1 across affected packages: com.hotels.styx:styx-api.
What version fixes CVE-2020-6858?
Upgrading to 1.0.0-rc1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is styx-api affected?
Yes, com.hotels.styx:styx-api is affected in releases prior to 1.0.0-rc1. Upgrade your dependency to 1.0.0-rc1 or later.
What is the CVSS score of CVE-2020-6858?
CVE-2020-6858 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2020-6858?
CVE-2020-6858 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (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.).
How can I check Maven dependencies for CVE-2020-6858?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.hotels.styx'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6v7p-v754-j89v",
  "modified" : "2021-08-19T19:37:59Z",
  "published" : "2020-03-03T15:32:03Z",
  "aliases" : [ "CVE-2020-6858" ],
  "summary" : "HTTP Response Splitting in Styx",
  "details" : "# Vulnerability\nStyx is vulnerable to CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers (&#39;HTTP Response Splitting&#39;).\n\n# Vulnerable Component\nThe vulnerable component is the `com.hotels.styx.api.HttpHeaders.Builder` due to disabling the HTTP Header validation built into Netty in these locations:\n\nhttps://github.com/HotelsDotCom/styx/blob/e1d578e9b9c38df9cd19c21dc2eb9b949d85b558/components/api/src/main/java/com/hotels/styx/api/HttpHeaders.java#L145\n\nhttps://github.com/HotelsDotCom/styx/blob/e1d578e9b9c38df9cd19c21dc2eb9b949d85b558/components/api/src/main/java/com/hotels/styx/api/HttpHeaders.java#L145\n\n`new DefaultHttpHeaders(false)` disables the built-in validation in Netty. Either use the default constructor or `new DefaultHttpHeaders(true`  instead.\n\nAdditionally, another vulnerable component is the StyxToNettyResponseTranslator due to also disabling the HTTP Header validation built into netty in this location.\n\nhttps://github.com/HotelsDotCom/styx/blob/8d60e5493e65d0d536afc0b350dcb02d24e0f7a7/components/server/src/main/java/com/hotels/styx/server/netty/connectors/StyxToNettyResponseTranslator.java#L30\n\n `DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, false); `\n`new DefaultHttpResponse(version, httpResponseStatus, false);` disables the built-in validation in Netty. Please use the constructor `new DefaultHttpResponse(version, httpResponseStatus, true);`\n\n# Proof of Concept\nThe following test plugin proves that there is no header validation occurring.\n\n```java\n    static class VulnerablePlugin implements Plugin {\n\n        @Override\n        public Eventual&lt;LiveHttpResponse&gt; intercept(LiveHttpRequest request, Chain chain) {\n            String header = request.queryParam(&quot;header-value&quot;).get();\n            LiveHttpRequest newRequest = request.newBuilder()\n                .header(&quot;myRequestHeader&quot;, header)\n                .build();\n            return chain.proceed(newRequest).map(response -&gt;\n                response.newBuilder().header(&quot;myResponseHeader&quot;, header).build()\n            ) ;\n        }\n\n    }\n\n    @Test\n    public void simpleHeaderInjectionVulnerabilityPOC() {\n        Plugin vulnerablePlugin = new VulnerablePlugin();\n        // a simple way to mock the downstream system\n        HttpInterceptor.Chain chain = request -&gt; {\n            assertThat(request.header(&quot;myRequestHeader&quot;).orElse(null), is(&quot;test\\r\\nAnother: CRLF_Injection&quot;));\n            return Eventual.of(response(OK).build());\n        };\n\n        // an example request you expect your plugin to receive\n        String encodedGet = URLEncoder.encode(&quot;test\\r\\nAnother: CRLF_Injection&quot;);\n        LiveHttpRequest request = get(&quot;/foo?header-value=&quot; + encodedGet)\n            .build();\n\n        // since this is a test, we want to wait for the response\n        LiveHttpResponse response = Mono.from(vulnerablePlugin.intercept(request, chain)).block();\n\n        assertThat(response.header(&quot;myResponseHeader&quot;).orElse(null), is(&quot;test\\r\\nAnother: CRLF_Injection&quot;));\n    }\n```\nAdditionally, if you run this LiveHttpResponse from this test through the `StyxToNettyResponseTranslator::toNettyResponse`, ideally, it would have caused an exception to be thrown. In its current state, it does not.\n\n# Similar Vulnerabilities\nThere have been reports of similar vulnerabilities in other popular libraries.\n\nGHSA-35fr-h7jr-hh86 -&gt; CVE-2019-16771\nGHSA-mvqp-q37c-wf9j -&gt; CVE-2019-17513\n\n\n# Finding\nThis vulnerability was found due to this query that [Jonathan Leitschuh](https://twitter.com/jlleitschuh) contributed to the Semmle QL project.\nhttps://lgtm.com/rules/1510696449842/alerts/",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.hotels.styx:styx-api"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.0-rc1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.0.0.beta8"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/HotelsDotCom/styx/security/advisories/GHSA-6v7p-v754-j89v"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-6858"
  }, {
    "type" : "WEB",
    "url" : "https://twitter.com/JLLeitschuh"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-03-03T15:31:22Z",
    "nvd_published_at" : null
  }
}