GHSA-345x-3rq2-jfrm
Loofah: SVG `<textPath>` and `<mpath>` bypass local-reference restriction
Quick fix
GHSA-345x-3rq2-jfrm — loofah: upgrade to the fixed version with the command below.
bundle update loofahDetails
## Summary
Loofah restricts `href` and `xlink:href` on certain SVG elements to same-document references. Two elements escaped the restriction:
- `<textPath>`: `SVG_ALLOW_LOCAL_HREF` listed it in lowercase as `textpath`, but the HTML5 parser names the element `textPath` inside `<svg>`, so the check never matched on the HTML5 path. - `<mpath>`: absent from `SVG_ALLOW_LOCAL_HREF`, so its references were never restricted on either path.
`rails-html-sanitizer` reuses this safelist in its `PermitScrubber`, so it is affected too.
## Impact
An external `href` or `xlink:href` on `<textPath>` or `<mpath>` survives sanitization. Firefox fetches the URL when rendering the content, which leaks the viewer's IP address, user agent, and referrer, and can reach hosts routable only from the viewer's network. Chrome and WebKit do not fetch external references on these elements. The impact is a network request to an attacker-chosen URL, not script execution.
Applications that sanitize user-supplied SVG, directly or inside HTML, with Loofah's default allowlist or with `rails-html-sanitizer` with SVG elements permitted are affected.
## Mitigation
Upgrade to Loofah >= 2.25.3.
Are you affected?
Enter the version of the package you're using.
Affected packages
References
- https://github.com/flavorjones/loofah/security/advisories/GHSA-345x-3rq2-jfrm[WEB]
- https://github.com/flavorjones/loofah/pull/324[WEB]
- https://github.com/flavorjones/loofah/commit/cdd6ff7fb51998eb181bd2da925ddbcfcc8a3b96[WEB]
- https://github.com/flavorjones/loofah[PACKAGE]
- https://github.com/flavorjones/loofah/releases/tag/v2.25.3[WEB]
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/GHSA-345x-3rq2-jfrm.yml[WEB]
Check it before you install it
One call answers whether to add this package: known advisories, CISA KEV, and whether the name is a hallucinated or freshly squatted one. No key needed to try it.
curl -s https://vdb.ai.kr/v1/ai/check-packages \
-H 'Content-Type: application/json' \
-d '{"packages":["pkg:gem/loofah"]}'