Junglewise Threat Intelligence

AngularJS XSS via JQLite DOM manipulation

Severity: low · CVSS 3.1 · Published 2020-08-05

Technologies: angular (npm). Vendors: Google, npm.

Executive brief

AngularJS is a popular JavaScript framework used to build dynamic web applications. A cross-site scripting (XSS) vulnerability in its DOM manipulation library (JQLite) allows attackers to inject malicious JavaScript code into web pages, even when HTML input has been sanitized by security libraries. An attacker can exploit this by crafting specially formatted HTML that bypasses sanitizers, potentially stealing user credentials, sessions, or performing actions on behalf of users.

Technical details

JQLite (AngularJS's built-in DOM manipulation library) uses regex-based HTML transformation in the jqLiteBuildFragment function to normalize XHTML self-closing tags before DOM insertion. When user-controlled HTML that has been sanitized by libraries like DOMPurify is passed to JQLite methods (append, prepend, after, replaceWith, or new JQLite), the tag expansion can inadvertently reactivate previously inert payloads. For example, a sanitizer may preserve `<style/><img src=x onerror="alert(1337)"/>` as safe (the img is inert inside an unclosed style element), but JQLite's transformation converts `<style/>` to `<style></style>`, closing the style element and reactivating the img tag's onerror handler. This vulnerability requires the application to use JQLite methods with sanitized HTML; a network attack vector; and user interaction to view the malicious content. The issue is patched in AngularJS 1.8.0. Applications using jQuery instead of JQLite should upgrade jQuery to 3.5.0, which contains a similar fix.

Affected products

  • Google AngularJS <1.8.0

Timeline

  • 2020-08-05: disclosed: Advisory GHSA-5cp4-xmrw-59wf published
  • 2020-08-05: patched: AngularJS 1.8.0 released with fix

References

Related threats