Ruby/loofah/0.4.2
Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
Loofah also includes some HTML sanitizers based on html5lib's safelist, which are a specific application of the general transformation functionality.
https://rubygems.org/gems/loofah
UNKNOWN
10 Security Vulnerabilities
Inefficient Regular Expression Complexity in Loofah
- https://github.com/flavorjones/loofah/security/advisories/GHSA-486f-hjj9-9vhh
- https://github.com/flavorjones/loofah/commit/a6e0a1ab90675a17b1b2be189129d94139e4b143
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/CVE-2022-23514.yml
- https://github.com/advisories/GHSA-486f-hjj9-9vhh
- https://nvd.nist.gov/vuln/detail/CVE-2022-23514
- https://hackerone.com/reports/1684163
- https://lists.debian.org/debian-lts-announce/2023/09/msg00011.html
- https://lists.debian.org/debian-lts-announce/2024/09/msg00044.html
Summary
Loofah < 2.19.1 contains an inefficient regular expression that is susceptible to excessive backtracking when attempting to sanitize certain SVG attributes. This may lead to a denial of service through CPU resource consumption.
Mitigation
Upgrade to Loofah >= 2.19.1.
Severity
The Loofah maintainers have evaluated this as High Severity 7.5 (CVSS3.1).
References
- CWE - CWE-1333: Inefficient Regular Expression Complexity (4.9)
- https://hackerone.com/reports/1684163
Credit
This vulnerability was responsibly reported by @ooooooo-q (https://github.com/ooooooo-q).
Loofah Allows Cross-site Scripting
- https://nvd.nist.gov/vuln/detail/CVE-2019-15587
- https://github.com/advisories/GHSA-c3gv-9cxf-6f57
- https://github.com/flavorjones/loofah/issues/171
- https://hackerone.com/reports/709009
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4WK2UG7ORKRQOJ6E4XJ2NVIHYJES6BYZ/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XMCWPLYPNIWYAY443IZZJ4IHBBLIHBP5/
- https://security.netapp.com/advisory/ntap-20191122-0003/
- https://usn.ubuntu.com/4498-1/
- https://www.debian.org/security/2019/dsa-4554
- https://github.com/flavorjones/loofah/commit/0c6617af440879ce97440f6eb6c58636456dc8ec
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/CVE-2019-15587.yml
In the Loofah gem for Ruby through v2.3.0, unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
Loofah Cross-site Scripting vulnerability
In the Loofah gem for Ruby, through version 2.2.2, unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished. Users are advised to upgrade to version 2.2.3.
See https://github.com/flavorjones/loofah/issues/154 for more details.
Cross-site Scripting in loofah
- https://nvd.nist.gov/vuln/detail/CVE-2018-8048
- https://github.com/advisories/GHSA-x7rv-cr6v-4vm4
- https://github.com/flavorjones/loofah/issues/144
- https://security.netapp.com/advisory/ntap-20191122-0003/
- https://www.debian.org/security/2018/dsa-4171
- http://www.openwall.com/lists/oss-security/2018/03/19/5
- https://github.com/flavorjones/loofah/commit/f739cf8eac5851f328b8044281d6653f74eff116
- https://github.com/sparklemotion/nokogiri/pull/1746
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/CVE-2018-8048.yml
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2018-8048.yml
Loofah allows non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments.
Users are affected if running Loofah < 2.2.1, but only:
- when running on MRI or RBX,
- in combination with libxml2 >= 2.9.2.
JRuby users are not affected.
Loofah XSS Vulnerability
In the Loofah gem, through v2.2.2, unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
Loofah XSS Vulnerability
Loofah allows non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments.
Loofah XSS Vulnerability
In the Loofah gem, through v2.3.0, unsanitized JavaScript may occur in sanitized output when a crafted SVG element is republished.
Inefficient Regular Expression Complexity in Loofah
Summary
Loofah < 2.19.1 contains an inefficient regular expression that is susceptible to excessive backtracking when attempting to sanitize certain SVG attributes. This may lead to a denial of service through CPU resource consumption.
Mitigation
Upgrade to Loofah >= 2.19.1.
SVG `href` attribute bypasses local-reference restriction in Loofah
Summary
Loofah's HTML5 sanitizer restricted only the xlink:href attribute on certain SVG elements to local, same-document references. Browsers also accept a plain href attribute as an alternative to the deprecated xlink:href per the SVG 2 spec, but Loofah did not apply the same restriction to it, allowing those elements to reference arbitrary external documents.
Impact
SVG
Applications that sanitize user-supplied SVG (directly, or as part of HTML) with Loofah's default allowlist are affected.
Credit
Found by the maintainer, Mike Dalessio, during a security audit.
Loofah HTML and XSS injection vulnerability
Loofah Gem for Ruby contains a flaw that allows a remote cross-site scripting (XSS) attack. This flaw exists because the Loofah::HTML::Document#text function passes properly sanitized user-supplied input to the Loofah::XssFoliate and Loofah::Helpers#strip_tags functions which convert input back to text. This may allow an attacker to create a specially crafted request that would execute arbitrary script code in a user's browser within the trust relationship between their browser and the server.
65 Other Versions
| Version | License | Security | Released | |
|---|---|---|---|---|
| 2.25.2 | MIT | 2026-07-15 - 19:57 | 2 months | |
| 2.25.1 | MIT | 3 | 2026-03-17 - 17:35 | 6 months |
| 2.25.0 | MIT | 5 | 2025-12-15 - 21:18 | 9 months |
| 2.24.1 | MIT | 1 | 2025-05-12 - 12:32 | over 1 year |
| 2.24.0 | MIT | 1 | 2025-01-01 - 03:05 | over 1 year |
| 2.23.1 | MIT | 1 | 2024-10-25 - 12:43 | almost 2 years |
| 2.23.0 | MIT | 1 | 2024-10-24 - 12:59 | almost 2 years |
| 2.22.0 | MIT | 1 | 2023-11-13 - 21:41 | almost 3 years |
| 2.21.4 | MIT | 1 | 2023-10-10 - 17:55 | almost 3 years |
| 2.21.3 | MIT | 1 | 2023-05-15 - 21:10 | over 3 years |
| 2.21.2 | MIT | 1 | 2023-05-11 - 15:39 | over 3 years |
| 2.21.1 | MIT | 1 | 2023-05-10 - 14:39 | over 3 years |
| 2.21.0 | MIT | 1 | 2023-05-10 - 13:50 | over 3 years |
| 2.21.0.rc1 | MIT | 1 | 2023-04-03 - 02:21 | over 3 years |
| 2.20.0 | MIT | 1 | 2023-04-01 - 17:07 | over 3 years |
| 2.19.1 | MIT | 1 | 2022-12-13 - 13:22 | almost 4 years |
| 2.19.0 | MIT | 7 | 2022-09-14 - 13:38 | about 4 years |
| 2.18.0 | MIT | 7 | 2022-05-11 - 18:42 | over 4 years |
| 2.17.0 | MIT | 7 | 2022-04-28 - 13:35 | over 4 years |
| 2.16.0 | MIT | 7 | 2022-04-01 - 18:27 | over 4 years |
| 2.15.0 | MIT | 7 | 2022-03-14 - 17:09 | over 4 years |
| 2.14.0 | MIT | 7 | 2022-02-11 - 19:10 | over 4 years |
| 2.13.0 | MIT | 7 | 2021-12-10 - 05:21 | almost 5 years |
| 2.12.0 | MIT | 7 | 2021-08-11 - 17:30 | about 5 years |
| 2.11.0 | MIT | 7 | 2021-07-31 - 21:31 | about 5 years |
| 2.10.0 | MIT | 7 | 2021-06-06 - 17:01 | over 5 years |
| 2.9.1 | MIT | 7 | 2021-04-07 - 15:23 | over 5 years |
| 2.9.0 | MIT | 7 | 2021-01-14 - 21:36 | over 5 years |
| 2.8.0 | MIT | 7 | 2020-11-25 - 21:16 | almost 6 years |
| 2.7.0 | MIT | 7 | 2020-08-26 - 19:33 | about 6 years |
| 2.6.0 | MIT | 7 | 2020-06-16 - 21:22 | about 6 years |
| 2.5.0 | MIT | 7 | 2020-04-05 - 20:51 | over 6 years |
| 2.4.0 | MIT | 7 | 2019-11-25 - 18:45 | almost 7 years |
| 2.3.1 | MIT | 7 | 2019-10-22 - 13:14 | almost 7 years |
| 2.3.0 | MIT | 9 | 2019-09-28 - 17:37 | almost 7 years |
| 2.2.3 | MIT | 9 | 2018-10-30 - 13:01 | almost 8 years |
| 2.2.2 | MIT | 11 | 2018-03-22 - 15:10 | over 8 years |
| 2.2.1 | MIT | 11 | 2018-03-19 - 20:32 | over 8 years |
| 2.2.0 | MIT | 13 | 2018-02-11 - 22:23 | over 8 years |
| 2.1.1 | MIT | 11 | 2017-09-25 - 01:11 | almost 9 years |
| 2.1.0 | MIT | 11 | 2017-09-24 - 20:48 | almost 9 years |
| 2.1.0.rc2 | MIT | 9 | 2016-01-11 - 18:31 | over 10 years |
| 2.1.0.rc1 | MIT | 9 | 2015-08-17 - 23:21 | about 11 years |
| 2.0.3 | MIT | 9 | 2015-08-17 - 18:13 | about 11 years |
| 2.0.2 | MIT | 9 | 2015-05-05 - 19:59 | over 11 years |
| 2.0.1 | MIT | 9 | 2014-08-21 - 21:28 | about 12 years |
| 2.0.0 | MIT | 9 | 2014-05-09 - 22:51 | over 12 years |
| 1.2.1 | UNKNOWN | 9 | 2012-04-14 - 19:08 | over 14 years |
| 1.2.0 | UNKNOWN | 9 | 2011-08-08 - 16:54 | about 15 years |
| 1.1.0 | UNKNOWN | 9 | 2011-08-08 - 05:30 | about 15 years |
