Executive brief
The secure_headers library, used to protect web applications by managing security headers, contains a flaw in how it handles certain Content Security Policy (CSP) settings. If an application allows user-provided input to influence specific CSP directives (like sandbox or reporting endpoints), an attacker can bypass the security policy. This could allow an attacker to execute malicious scripts (XSS) or intercept security reports, potentially leading to unauthorized access to user data or session hijacking.
Technical details
The secure_headers gem (prior to version 7.3.0) fails to sanitize semicolons (;), carriage returns (\r), and newlines (\n) in the build_sandbox_list_directive, build_media_type_list_directive, and build_report_to_directive builders. When an application uses SecureHeaders.override_content_security_policy_directives or similar append APIs with untrusted input for these specific directives, an attacker can inject a semicolon followed by a new script-src directive. Because these directives are processed alphabetically before the legitimate script-src, the injected 'unsafe-inline' policy takes precedence due to the CSP first-occurrence rule. This effectively disables the application's intended script protections and can also be used to redirect CSP violation reports to attacker-controlled infrastructure.
Affected products
- GitHub secure_headers <= 7.2.0
Timeline
- 2026-06-03: patched: Fix committed and version 7.3.0 released.
- 2026-07-17: disclosed: CVE-2026-54163 published.