Patchfirst
CVE-2020-5217 Medium · 4.4 EPSS 1.8%

Directive injection when using dynamic overrides with user input in RubyGems secure_headers

Twitter · secure_headers

Official description · CVE.org

In Secure Headers (RubyGem secure_headers), a directive injection vulnerability is present in versions before 3.8.0, 5.1.0, and 6.2.0. If user-supplied input was passed into append/override_content_security_policy_directives, a semicolon could be injected leading to directive injection. This 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. The 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. Depending on what major version you are using, the fixed versions are 6.2.0, 5.1.0, 3.8.0.

Breakdown
18.8 / 100
Exploited
Not confirmed
Reports
0
Tactics
2/15

How an attack unfolds

Based on mappings. Select a step to see the evidence.
  1. What they do

  2. What can follow

Disclosed on 23 Jan 2020. No public exploit code or confirmed exploitation is recorded.

2 related vulnerabilities in the same code on the same day. The latest fix listed for secure_headers is 7.3.0.

Linked vulnerabilitiesLinked by evidence that a fix failed or the same code was patched again. Oldest first.

  1. CVE-2020-5216Limited header injection when using dynamic overrides with user…23 Jan 2020
  2. relatedHigh

    Why these are linked:

    • Fixed one release later6.2.0 → 6.3.0 (secure_headers)
    • Fixed one release later5.1.0 → 5.2.0 (secure_headers)
    • Same code patched: content_security_policy.rb (machine-matched)Functions: build_source_list_directivecommit 3016957commit 936a160
    • Similar weakness in the same product (machine-matched)same product + description similarity
    This CVECVE-2020-5217Directive injection when using dynamic overrides with user input…23 Jan 2020

Fixes in secure_headersRubyGems package, by fixed version. Earlier and later fixes in the same package, not necessarily the same bug.

  1. 6.2.0CVE-2020-521723 Jan 2020
  2. 6.3.0CVE-2020-521623 Jan 2020
  3. 7.3.0CVE-2026-5416317 Jul 2026Latest listed

techniques

2 , grouped by in kill-chain order 2

ExecutionTA0002

MITRE CTID mapping of the CVE · primary impact

CollectionTA0009

MITRE CTID mapping of the CVE · follow-on activity

Detection

0 rules for this CVE · 97 general rules for its techniques

Rules for this CVE

0 that reference CVE-2020-5217 directly.

CVE-specific rules are not available in this build. Search SigmaHQ ↗

General rules for this CVE’s techniques

These detect the technique in general, not this specific vulnerability.

Sigma rules © SigmaHQ, Detection Rule License 1.1; linked, not reproduced.

Am I affected? What do I upgrade to?

From GitHub Security Advisories and OSV

1 package in 1 ecosystem. Main package: secure_headers.

RubyGemssecure_headersGHSA-xq52-rv6w-397c

Upgrade to 6.2.0 or later

Gemfilegem "secure_headers", ">= 6.2.0"

The first fix for CVE-2020-5217. No other CVE tracked by Patchfirst affects this package.

Affected versions, by release line

If you runUpgrade to
6.0.0 up to 6.2.06.2.0
5.0.0 up to 5.1.05.1.0
All versions before 3.8.03.8.0

“Up to” means the second version is the fix and is not affected.

Check your lockfile against all CVEs

What security researchers reported

Not named in any threat report yet

References

4 links, grouped by NVD tag
↑ ↓ chooseEnter openEsc close