CVE-2020-5216 Limited header injection when using dynamic overrides with user input in RubyGems secure_headers

Medium 4.4 Published Updated

Attackers can inject newlines into Content-Security-Policy headers via user input, bypassing security restrictions in Ruby applications using the secure_headers gem.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2020-5216?

CVE-2020-5216 is a medium-severity vulnerability in Twitter secure_headers, published on 23 Jan 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

Official description

In Secure Headers (RubyGem secure_headers), a directive injection vulnerability is present in versions before 3.9.0, 5.2.0, and 6.3.0. If user-supplied input was passed into append/override_content_security_policy_directives, a newline could be injected leading to limited header injection. Upon 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. This has been fixed in 6.3.0, 5.2.0, and 3.9.0.

Weakness: CWE-74, CWE-113

Which versions are affected by CVE-2020-5216?

6 open source packages ship an affected version, including secure_headers. It affects 1 product.

PackageAffectedFixed in
secure_headers RubyGemsAll versions3.9.0
secure_headers RubyGemsAll versions3.9.0
secure_headers RubyGemsFrom 5.0.05.2.0
secure_headers RubyGemsFrom 5.0.05.2.0
secure_headers RubyGemsFrom 6.0.06.3.0
secure_headers RubyGemsFrom 6.0.06.3.0

Products include Twitter Secure Headers.

How do I fix CVE-2020-5216?

Upgrade secure_headers to a fixed version for your release line: 3.9.0, 5.2.0 or 6.3.0.

Is CVE-2020-5216 being exploited?

There is no known exploitation of CVE-2020-5216 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2020-5216, GHSA-w978-rmpf-qmwg, UBUNTU-CVE-2020-5216.

Is CVE-2020-5216 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free