CVE-2020-5217: Secure headers Directive Injection When Using Dynamic Vulnerability
MODERATECVE-2020-5217 is a MODERATE (CVSS 4.4) directive injection when using dynamic vulnerability (CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')) affecting Secure headers libraries in the RubyGems ecosystem. The issue involves directive injection when using dynamic overrides with user input. Remediation is available by upgrading affected packages to version 6.2.0, 5.1.0, 3.8.0.
CVE-2020-5217 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-5217
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.2.0
Upgrade secure_headers to 5.1.0
Upgrade secure_headers to 3.8.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-5217, 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.2.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-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection'), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before using the input in a dynamic evaluation call (e.g. "eval"). 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-5217 Affected Secure headers Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
secure_headers
|
RubyGems |
≥ 6.0.0
< 6.2.0
|
6.2.0
|
|
secure_headers
|
RubyGems |
≥ 5.0.0
< 5.1.0
|
5.1.0
|
|
secure_headers
|
RubyGems |
< 3.8.0
|
3.8.0
|
References
Frequently Asked Questions
What is CVE-2020-5217?
Which Secure headers versions are affected?
What version fixes CVE-2020-5217?
Is secure_headers affected?
What is the CVSS score of CVE-2020-5217?
What CWE is associated with CVE-2020-5217?
How can I check RubyGems dependencies for CVE-2020-5217?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xq52-rv6w-397c",
"modified" : "2023-05-16T16:09:56Z",
"published" : "2020-01-23T02:28:11Z",
"aliases" : [ "CVE-2020-5217" ],
"summary" : "Directive injection when using dynamic overrides with user input",
"details" : "### Impact\n\nIf user-supplied input was passed into `append/override_content_security_policy_directives`, a semicolon could be injected leading to directive injection.\n\nThis could be used to e.g. override a `script-src` directive. Duplicate directives are ignored and the first one wins. The directives in `secure_headers` are sorted alphabetically so they pretty much all come before `script-src`. A previously undefined directive would receive a value even if `SecureHeaders::OPT_OUT` was supplied.\n\nThe fixed versions will silently convert the semicolons to spaces and emit a deprecation warning when this happens. This will result in innocuous browser console messages if being exploited/accidentally used. In future releases, we will raise application errors resulting in 500s.\n\n> Duplicate script-src directives detected. All but the first instance will be ignored.\n\nSee https://www.w3.org/TR/CSP3/#parse-serialized-policy\n\n> Note: In this case, the user agent SHOULD notify developers that a duplicate directive was ignored. A console warning might be appropriate, for example.\n\n### Patches\n\nDepending on what major version you are using, the fixed versions are 6.2.0, 5.1.0, 3.8.0.\n\n### Workarounds\n\nIf you are passing user input into the above methods, you could filter out the input:\n\n```ruby\noverride_content_security_policy_directives(:frame_src, [user_input.gsub(\";\", \" \")])\n```\n\n### References\n\nReported in https://github.com/twitter/secure_headers/issues/418\nhttps://www.w3.org/TR/CSP3/#parse-serialized-policy\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/issues/new)\n* DM @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.2.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "secure_headers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0"
}, {
"fixed" : "5.1.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "secure_headers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.8.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/security/advisories/GHSA-xq52-rv6w-397c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-5217"
}, {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/issues/418"
}, {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/pull/421"
}, {
"type" : "WEB",
"url" : "https://github.com/twitter/secure_headers/commit/936a160e3e9659737a9f9eafce13eea36b5c9fa3"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/secure_headers/CVE-2020-5217.yml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twitter/secure_headers"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-95" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-01-23T02:12:03Z",
"nvd_published_at" : null
}
}