{"id":"CVE-2020-5217","aliases":["CVE-2020-5217","GHSA-xq52-rv6w-397c"],"related":[],"kind":"vulnerability","state":"published","title":"Directive 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.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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","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.8.0, 5.1.0 y 6.2.0. Si una entrada suministrada por el usuario fue pasada a append/override_content_security_policy_directives, se podría inyectar un punto y coma conllevando a una inyección de directiva. Esto podría ser usado para, por ejemplo anular una directiva script-src. Las directivas duplicadas son ignoradas y la primera gana. Las directivas en secure_headers están ordenadas alfabéticamente, por lo que casi todas van antes de script-src. Una directiva previamente indefinida recibiría un valor inclusive si la función SecureHeaders::OPT_OUT fue suministrada. Las versiones corregidas convertirán silenciosamente los puntos y comas en espacios y emitirán una advertencia de desaprobación cuando esto suceda. Esto resultará en mensajes inocuos de la consola del navegador si está siendo explotada o usada accidentalmente. En futuras versiones, generaremos errores de aplicación resultando en 500. Según la versión principal que esté usando, las versiones corregidas son 6.2.0, 5.1.0, 3.8.0.","source":"nvd"}],"published":"2020-01-23T02:15:17.000Z","modified":"2026-09-10T03:48:42.355Z","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-95"],"affected":[{"ranges":[{"version":"< 3.8.0","status":"affected"},{"version":">= 5.0.0, < 5.1.0","status":"affected"},{"version":">= 6.0.0, < 6.2.0","status":"affected"}],"vendor":"Twitter","product":"secure_headers","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"6.0.0","status":"affected","fixed":"6.2.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"5.0.0","status":"affected","fixed":"5.1.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.8.0"}],"ecosystem":"RubyGems","package":"secure_headers","purl":"pkg:gem/secure_headers","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.8.0"},{"status":"affected","introduced":"5.0.0","fixed":"5.1.0"},{"status":"affected","introduced":"6.0.0","fixed":"6.2.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-xq52-rv6w-397c","tags":["mitigation","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twitter/secure_headers/issues/418","tags":["exploit","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twitter/secure_headers/pull/421","tags":["third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/twitter/secure_headers/commit/936a160e3e9659737a9f9eafce13eea36b5c9fa3","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2020-5217","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/secure_headers/CVE-2020-5217.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-5217","url":"https://www.cve.org/CVERecord?id=CVE-2020-5217","licence":"CVE Terms of Use","modified":"2024-08-04T08:22:08.919Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xq52-rv6w-397c","url":"https://github.com/advisories/GHSA-xq52-rv6w-397c","licence":"CC-BY-4.0","modified":"2026-09-10T03:48:42.355Z"},{"source":"nvd","name":"NVD","id":"CVE-2020-5217","url":"https://nvd.nist.gov/vuln/detail/CVE-2020-5217","licence":"Public domain","modified":"2026-06-17T03:21:02.700Z"}],"updatedAt":"2026-11-25T22:57:50.661Z","epss":{"score":0.0183,"percentile":0.79482,"date":"2026-12-01T12:00:22.000Z"}}