GitHub Advisoryadvisory · npm
GHSA-5cp4-xmrw-59wf XSS via JQLite DOM manipulation functions in AngularJS
MEDIUM
Official page ↗
- Ecosystem
- npm
- Packages
- angular
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L
- Weaknesses
- CWE-79
- Reviewed
- 2020-08-05
Affected packages
• npm angular: < 1.8.0 → fixed in 1.8.0
Description
Summary
XSS may be triggered in AngularJS applications that sanitize user-controlled HTML snippets before passing them to `JQLite` methods like `JQLite.prepend`, `JQLite.after`, `JQLite.append`, `JQLite.replaceWith`, `JQLite.append`, `new JQLite` and `angular.element`.
Description
JQLite (DOM manipulation library that's part of AngularJS) manipulates input HTML before inserting it to the DOM in `jqLiteBuildFragment`.
One of the modifications performed expands an XHTML self-closing tag.
If `jqLiteBuildFragment` is called (e.g. via `new JQLite(aString)`) with user-controlled HTML string that was sanitized (e.g. with DOMPurify), the transformation done by JQLite may modify some forms of an inert, sanitized payload into a payload containing JavaScript - and trigger an XSS when the payload is inserted into DOM.
This is similar to a bug in jQuery `htmlPrefilter` function that was fixed in 3.5.0.
Proof of concept
```javascript
const inertPayload = ``
```
Note that the style element is not closed and `` will be replaced with `` before adding it to the DOM, closing the style element early and reactivating `img`.
Patches
The issue is patched in `JQLite` bundled with angular 1.8.0. AngularJS users using JQuery should upgrade JQuery to 3.5.0, as a similar vulnerability [affects jQuery `) or inline style elements may stop certain exploitation vectors, but it's uncertain if all possible exploitation vectors would be covered. Upgrade of AngularJS to 1.8.0 is recommended.
References
https://github.com/advisories/GHSA-mhp6-pxh8-r675
https://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2
https://github.com/jquery/jquery/security/advisories/GHSA-jpcq-cgw6-v4j6
https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/
https://snyk.io/vuln/SNYK-JS-ANGULAR-570058
Related
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness
References
- https://github.com/google/security-research/security/advisories/GHSA-5cp4-xmrw-59wf web
- https://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2 web
- https://github.com/jquery/jquery/security/advisories/GHSA-jpcq-cgw6-v4j6 web
- https://blog.jquery.com/2020/04/10/jquery-3-5-0-released web
- https://github.com/advisories/GHSA-mhp6-pxh8-r675 advisory
- https://github.com/angular/angular.js package
- https://snyk.io/vuln/SNYK-JS-ANGULAR-570058 web