|
| 1 | +--- |
| 2 | +gem: phlex |
| 3 | +cve: 2024-28199 |
| 4 | +ghsa: 242p-4v39-2v8g |
| 5 | +url: https://github.com/phlex-ruby/phlex/security/advisories/GHSA-242p-4v39-2v8g |
| 6 | +title: Cross-site Scripting (XSS) possible with maliciously |
| 7 | + formed HTML attribute names and values in Phlex |
| 8 | +date: 2024-03-12 |
| 9 | +description: | |
| 10 | + There is a potential cross-site scripting (XSS) vulnerability that |
| 11 | + can be exploited via maliciously crafted user data. This was due |
| 12 | + to improper case-sensitivity in the code that was meant to prevent |
| 13 | + these attacks. |
| 14 | +
|
| 15 | + ### Impact |
| 16 | +
|
| 17 | + If you render an `<a>` tag with an `href` attribute set to a |
| 18 | + user-provided link, that link could potentially execute JavaScript |
| 19 | + when clicked by another user. |
| 20 | +
|
| 21 | + ```ruby |
| 22 | + a(href: user_profile) { "Profile" } |
| 23 | + ``` |
| 24 | +
|
| 25 | + If you splat user-provided attributes when rendering any HTML or |
| 26 | + SVG tag, malicious event attributes could be included in the output, |
| 27 | + executing JavaScript when the events are triggered by another user. |
| 28 | +
|
| 29 | + ```ruby |
| 30 | + h1(**JSON.parse(user_attributes)) |
| 31 | + ``` |
| 32 | +
|
| 33 | + ### Patches |
| 34 | +
|
| 35 | + Patches are [available on RubyGems](https://rubygems.org/gems/phlex) |
| 36 | + for all `1.x` minor versions. The patched versions are: |
| 37 | +
|
| 38 | + - [1.9.1](https://rubygems.org/gems/phlex/versions/1.9.1) |
| 39 | + - [1.8.2](https://rubygems.org/gems/phlex/versions/1.8.2) |
| 40 | + - [1.7.1](https://rubygems.org/gems/phlex/versions/1.7.1) |
| 41 | + - [1.6.2](https://rubygems.org/gems/phlex/versions/1.6.2) |
| 42 | + - [1.5.2](https://rubygems.org/gems/phlex/versions/1.5.2) |
| 43 | + - [1.4.1](https://rubygems.org/gems/phlex/versions/1.4.1) |
| 44 | + - [1.3.3](https://rubygems.org/gems/phlex/versions/1.3.3) |
| 45 | + - [1.2.2](https://rubygems.org/gems/phlex/versions/1.2.2) |
| 46 | + - [1.1.1](https://rubygems.org/gems/phlex/versions/1.1.1) |
| 47 | + - [1.0.1](https://rubygems.org/gems/phlex/versions/1.0.1) |
| 48 | +
|
| 49 | + If you are on `main`, it has been patched since |
| 50 | + [`aa50c60`](https://github.com/phlex-ruby/phlex/commit/aa50c604cdee1d0ce7ef068a4c66cbd5d43f96a1) |
| 51 | +
|
| 52 | + ### Workarounds |
| 53 | +
|
| 54 | + Configuring a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) |
| 55 | + that does not allow [`unsafe-inline`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy#unsafe-inline) |
| 56 | + would effectively prevent this vulnerability from being exploited. |
| 57 | +
|
| 58 | + ### References |
| 59 | +
|
| 60 | + In addition to upgrading to a patched version of Phlex, we strongly |
| 61 | + recommend configuring a Content Security Policy header that does not |
| 62 | + allow `unsafe-inline`. Here’s how you can configure a Content Security |
| 63 | + Policy header in Rails. |
| 64 | + https://guides.rubyonrails.org/security.html#content-security-policy-header |
| 65 | +
|
| 66 | +cvss_v3: 7.1 |
| 67 | +patched_versions: |
| 68 | + - "~> 1.0.1" |
| 69 | + - "~> 1.1.1" |
| 70 | + - "~> 1.2.2" |
| 71 | + - "~> 1.3.3" |
| 72 | + - "~> 1.4.1" |
| 73 | + - "~> 1.5.2" |
| 74 | + - "~> 1.6.2" |
| 75 | + - "~> 1.7.1" |
| 76 | + - "~> 1.8.2" |
| 77 | + - ">= 1.9.1" |
| 78 | +related: |
| 79 | + url: |
| 80 | + - https://nvd.nist.gov/vuln/detail/CVE-2024-28199 |
| 81 | + - https://github.com/phlex-ruby/phlex/security/advisories/GHSA-242p-4v39-2v8g |
| 82 | + - https://github.com/phlex-ruby/phlex/commit/aa50c604cdee1d0ce7ef068a4c66cbd5d43f96a1 |
| 83 | + - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy |
| 84 | + - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy#unsafe-inline |
| 85 | + - https://github.com/advisories/GHSA-242p-4v39-2v8g |
0 commit comments