Advisory

RUSTSEC-2021-0157

Also known as: GHSA-69v2-w9vg-4g83

Summary

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

Details

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:

<div style='background:url("cid:\");EVIL_CSS_HERE;background:url(\"cid:")'>

Would erroneously "sanitize" to:

<div style='background:url("cid:");EVIL_CSS_HERE;background:url("cid:")'>

---

This vulnerability was reported by Uttej Badwane

Severity

Not rated by the source.

Dates

Published
2021-10-10 12:00 UTC
Modified
2026-10-12 18:15 UTC

Affected packages and fixes

ammonia

crates.io · All systems

Affected

  • introduced 0.0.0-0, fixed 4.1.7, introduced 4.2.0, fixed 4.2.3 (semver)

Fixed versions

4.1.7, 4.2.3

Fix

  • Fixed version 4.1.7
    cargo update -p ammonia --precise 4.1.7
  • Fixed version 4.2.3
    cargo update -p ammonia --precise 4.2.3

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences