RUSTSEC-2026-0373 GHSA-x43w-36pp-96g3
Missing case-insensitive matching for CSS url function
- Severity
- Not rated yet
- No source has published a CVSS score yet
- Exploit chance (EPSS)
- —
- No score published
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- —
- Not classified
- Fix
4.2.4- Upgrade ammonia to this version or later
Description
URL filtering, such as relative URLs and URL scheme limits, is not always applied when CSS sanitization is used.
When the inner URL is quoted, CSS url("") is matched case-sensitively,
when it should be matched case-insensitively.
As a result, while url("") gets the intended domain name filtering,
URL("") does not.
The following example shows how an application needs to be configured to trigger this bug.
let mut builder = Builder::new();
// allow inline styles
builder.filter_style_properties(hashset!["background-image"]);
builder.add_generic_attributes(&["style"]);
// notice that "http" URLs aren't allowed
builder.url_schemes(["cid"].into());
// attacker-controlled, presumably
let cleaned = builder.clean(r#"<div style='background:URL("https://evil.com/ping");'>"#);
// this is the expected result
assert_eq!(String::from(&cleaned), r#"<div style="">ok</p>"#);
// this is the result that the vulnerable version actually gets
assert_eq!(String::from(&cleaned), r#"<div style="background-image:URL("https://evil.com/ping");">ok</p>"#);
This can be used to inject tracking pixels where the application intended to prevent them. It does not allow XSS, and its usefulness for data exfiltration is limited.
This vulnerability was reported by Louis Li.
Affected versions
crates.io
| Package | Vulnerable | Fixed in |
|---|---|---|
| ammonia | >= 0.0.0-0, < 4.1.8>= 4.2.0, < 4.2.4 |
4.1.84.2.4 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
ammonia crates.io → 4.2.4
- cargo
cargo update -p ammonia --precise 4.2.4
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-m6mh-2hw2-555x Ammonia: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | Medium | Also affects ammonia |
| GHSA-9jh8-v38h-cvhr ammonia: mXSS via MathML `annotation-xml` encoding strip | Medium | Also affects ammonia |
| GHSA-mm7x-qfjj-5g2c Ammonia incorrectly handles embedded SVG and MathML leading to mutation XSS after removal | Low | Also affects ammonia |
| GHSA-p2g9-94wh-65c2 Space bug in `clean_text` | Medium | Also affects ammonia |
| RUSTSEC-2021-0157 Incorrect escaping for `url("")` functions in CSS style attributes | Not rated yet | Also affects ammonia |
| RUSTSEC-2021-0158 XSS in ammonia via SVG `animateMotion`, `animateTransform`, and/or `animateColor` tags | Not rated yet | Also affects ammonia |
| GHSA-5325-xw5m-phm3 Cross-site Scripting in ammonia | Medium | Also affects ammonia |
| GHSA-5hp8-35wj-m525 Uncontrolled recursion in ammonia | High | Also affects ammonia |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor