Email me

Rust advisories / ammonia

VulnerabilityRUSTSEC-2026-0373 · ammonia

RUSTSEC-2026-0373: Missing case-insensitive matching for CSS url function

Short answerA security vulnerability in the ammonia crate: Missing case-insensitive matching for CSS url function. No severity score was published. Fixed in 4.1.8, 4.2.4: update to a fixed version.

Crateammonia
TypeVulnerability (format-injection)
Affected versionsBefore 4.1.8; from 4.2.0 before 4.2.4.
Fixed in4.1.8, 4.2.4
Severitynot scored
Published2026-10-16
Last changed2026-10-17
Also known asGHSA-x43w-36pp-96g3

What to do

  1. See which version you have: cargo tree -i ammonia (it also shows which of your dependencies pulls it in).
  2. Update within your version requirement: cargo update -p ammonia. If the fix is a newer major or minor than your requirement allows, raise it in Cargo.toml (for example ammonia = "4.2.4") or update the dependency that pulls it in.
  3. Check again with cargo audit, or paste your Cargo.lock into our Cargo.toml checker.

Details from the advisory

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(&quot;https://evil.com/ping&quot;);">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.

References

From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.

Other advisories for ammonia

Full security history of ammonia

Up next

Same crateammonia: security historyEvery advisory for this crate, and whether it is safe to use today.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ