Skip to content
OpenAdvisories
Unscored GHSA-69v2-w9vg-4g83 RUSTSEC-2021-0157

Incorrect escaping for `url("")` functions in CSS style attributes

Published Oct 10, 2021 · Updated Oct 12, 2026 · Assigned by RUSTSEC

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 packages

EcosystemPackageAffectedFixedRecord
crates.io ammonia >= 0.0.0-0, < 4.1.7 · >= 4.2.0, < 4.2.3 4.1.7, 4.2.3 RUSTSEC-2021-0157

References