Skip to content
XSS Advisory Advanced

GHSL-2020-099: mXSS vulnerability in AngularJS

AngularJS's jqLite contains a port of jQuery's htmlPrefilter that can mutate sanitised HTML into dangerous HTML, enabling mutation XSS. An attacker could execute arbitrary JavaScript if a developer sanitises untrusted HTML and then passes it to AngularJS's element function.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

Latest vulnerable version: 1.7.9 (master, 418355f1cf9a9a9827ae81d257966e6acfb5623a)

pwntester, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the htmlPrefilter regular expression that expands self-closing tags can alter the structure of already-sanitised HTML, creating new tags and attributes that were not present before.

Impact

This issue may lead to a Cross-Site Scripting vulnerability (mXSS).

What the attacker needed

Application sanitises untrusted HTML then passes it to…; attacker can supply HTML input

The fix

The vulnerability was fixed in a later release of AngularJS.

How it was found

  1. Sanitise untrusted HTML with a tool such as DOMPurify.
  2. Pass the sanitised HTML to AngularJS's element function, which applies the htmlPrefilter logic.
  3. The filter expands self-closing tags and mutates the HTML into a dangerous form.
  4. The mutated HTML is inserted into the page, causing script execution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Mutation XSS (mXSS) happens when HTML that looks safe after sanitising changes into dangerous HTML when a browser or library re-parses it. Here, a function that expands self-closing tags can turn a harmless-looking attribute into an executable event handler. If a website uses this AngularJS function on user-supplied HTML, an attacker could run their own script in a victim's browser.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Alvaro Muñoz

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.