What’s Vulnerable › Vulnerabilities
RUSTSEC-2021-0157: Incorrect escaping for `url("")` functions in CSS style attributes
- Severity: unknown
- Exploited in the wild: not listed in CISA KEV
- Public exploit or detection template: none known
- Published: 2021-10-10 · updated 2026-10-12
Description
In some cases, quotation marks in CSS url() functions are not escaped. This allows CSS injection. This feature is not enabled by default, so an application is vulnerable if, and only if, the style attribute is allowed and filter_style_properties is used. As an example, this snippet: ```html <div style='background:url("cid:\");EVIL_CSS_HERE;background:url(\"cid:")'> ``` Would erroneously "sanitize" to: ```html <div style='background:url("cid:");EVIL_CSS_HERE;background:url("cid:")'> ``` --- This vulnerability was reported by Uttej Badwane
Affected products
- Crates.Io Ammonia: from 0.0.0-0 before 4.1.7; from 4.2.0 before 4.2.3 — fixed in 4.1.7, 4.2.3
How to fix
Upgrade to a fixed version: Crates.Io Ammonia 4.1.7, 4.2.3. Check the vendor advisory for mitigations.
References
- https://crates.io/crates/ammonia
- https://rustsec.org/advisories/RUSTSEC-2021-0157.html
- https://github.com/rust-ammonia/ammonia/pull/259
Get alerted when RUSTSEC-2021-0157 or the next vulnerability affects your stack