GHSA-p2g9-94wh-65c2 Space bug in `clean_text`
Attackers can inject HTML attributes via unquoted fields due to incorrect whitespace handling in the clean_text function.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is GHSA-p2g9-94wh-65c2?
GHSA-p2g9-94wh-65c2 is a cross-site scripting vulnerability in ammonia, published on 19 Jan 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
An incorrect mapping from HTML specification to ASCII codes was used. Because HTML treats the Form Feed as whitespace, code like this has an injection bug:
let html = format!("<div title={}>", clean_text(user_supplied_string));
Applications are not affected if they quote their attributes, or if they don't use clean_text at all.
Which versions are affected by GHSA-p2g9-94wh-65c2?
3 open source packages ship an affected version, including ammonia.
| Package | Affected | Fixed in |
|---|---|---|
ammonia crates.io | From 3.0.0 | 3.1.3 |
ammonia crates.io | From 3.0.0 | 3.1.3 |
ammonia crates.io | From 3.0.0 | 3.1.3 |
How do I fix GHSA-p2g9-94wh-65c2?
Upgrade ammonia to 3.1.3 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
Is GHSA-p2g9-94wh-65c2 being exploited?
There is no known exploitation of GHSA-p2g9-94wh-65c2 in the wild and no public exploit code.
Sources
Also known as RUSTSEC-2022-0003.