GHSA-5cp4-xmrw-59wf: Angular Cross-Site Scripting Vulnerability

MODERATE
CVSS 5.0
CWE-79
Published
Advisory Summary

GHSA-5cp4-xmrw-59wf is a MODERATE (CVSS 5.0) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Angular libraries in the npm ecosystem. The issue involves xss via jqlite dom manipulation functions in angularjs. Remediation is available by upgrading affected packages to version 1.8.0.

GHSA-5cp4-xmrw-59wf at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-5cp4-xmrw-59wf
Severity MODERATE
CVSS v3.1 Base Score 5.0
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Angular
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix GHSA-5cp4-xmrw-59wf

To remediate this vulnerability, upgrade all affected Angular dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

angular fixed: 1.8.0
npm install angular@1.8.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls angular

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-5cp4-xmrw-59wf, inspect your project dependencies using npm:

npm ls angular

Analyze the terminal output to locate any version of Angular in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.8.0), your application is affected.

Note: The npm ls angular command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Angular, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://github.com/angular/angular.js/blob/418355f1cf9a9a9827ae81d257966e6acfb5623a/src/jqLite.js#L218). If `jqLiteBuildFragment` is called (e.g. via `new JQLite(aString)`) with user-controlled HTML string that was sanitized (e.g. with [DOMPurify](https://github.com/cure53/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](https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/). ### Proof of concept ```javascript const inertPayload = `<div><style><style/><img src=x onerror="alert(1337)"/>`  ``` Note that the style element is not closed and `<img` would be a text node inside the style if inserted into the DOM as-is. As such, some HTML sanitizers would leave the `<img` as is without processing it and stripping the `onerror` attribute. ```javascript angular.element(document).append(inertPayload); ``` This will alert, as `<style/>` will be replaced with `<style></style>` 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 <3.5.0](https://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2). ### Workarounds Changing sanitizer configuration not to allow certain tag grouping (e.g. `<option><style></option>`) 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

GHSA-5cp4-xmrw-59wf Affected Angular Versions

1 component(s)
Fixed Versions:
1.8.0
Product / Package Ecosystem Affected Versions Fixed Version
angular
npm
< 1.8.0
1.8.0

References

Frequently Asked Questions

What is GHSA-5cp4-xmrw-59wf?
GHSA-5cp4-xmrw-59wf is a security vulnerability in Angular involving XSS via JQLite DOM manipulation functions in AngularJS under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Angular versions are affected?
Affected versions include releases prior to 1.8.0 across affected packages: angular.
What version fixes GHSA-5cp4-xmrw-59wf?
Upgrading to 1.8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is angular affected?
Yes, angular is affected in releases prior to 1.8.0. Upgrade your dependency to 1.8.0 or later.
What is the CVSS score of GHSA-5cp4-xmrw-59wf?
GHSA-5cp4-xmrw-59wf has a CVSS v3.1 base score of 5.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with GHSA-5cp4-xmrw-59wf?
GHSA-5cp4-xmrw-59wf is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for GHSA-5cp4-xmrw-59wf?
Run the dependency tree command: 'npm ls angular'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5cp4-xmrw-59wf",
  "modified" : "2021-10-08T21:25:58Z",
  "published" : "2020-08-05T21:47:02Z",
  "aliases" : [ ],
  "summary" : "XSS via JQLite DOM manipulation functions in AngularJS",
  "details" : "### Summary\nXSS 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`.\n\n### Description\n\nJQLite (DOM manipulation library that's part of AngularJS) manipulates input HTML before inserting it to the DOM in `jqLiteBuildFragment`.\n\nOne of the modifications performed [expands an XHTML self-closing tag](https://github.com/angular/angular.js/blob/418355f1cf9a9a9827ae81d257966e6acfb5623a/src/jqLite.js#L218).\n\nIf `jqLiteBuildFragment` is called (e.g. via `new JQLite(aString)`) with user-controlled HTML string that was sanitized (e.g. with [DOMPurify](https://github.com/cure53/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.\n\nThis is similar to a bug in jQuery `htmlPrefilter` function that was [fixed in 3.5.0](https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/).\n\n### Proof of concept\n\n```javascript\nconst inertPayload = `<div><style><style/><img src=x onerror=\"alert(1337)\"/>` \n```\nNote that the style element is not closed and `<img` would be a text node inside the style if inserted into the DOM as-is.\nAs such, some HTML sanitizers would leave the `<img` as is without processing it and stripping the `onerror` attribute.\n\n```javascript\nangular.element(document).append(inertPayload);\n```\nThis will alert, as `<style/>` will be replaced with `<style></style>` before adding it to the DOM, closing the style element early and reactivating `img`.\n\n### Patches\nThe 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 <3.5.0](https://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2).\n\n### Workarounds\nChanging sanitizer configuration not to allow certain tag grouping (e.g. `<option><style></option>`) 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.\n\n### References\nhttps://github.com/advisories/GHSA-mhp6-pxh8-r675\nhttps://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2\nhttps://github.com/jquery/jquery/security/advisories/GHSA-jpcq-cgw6-v4j6\nhttps://blog.jquery.com/2020/04/10/jquery-3-5-0-released/\nhttps://snyk.io/vuln/SNYK-JS-ANGULAR-570058",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "angular"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.8.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/google/security-research/security/advisories/GHSA-5cp4-xmrw-59wf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jquery/jquery/security/advisories/GHSA-gxr4-xjj5-5px2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jquery/jquery/security/advisories/GHSA-jpcq-cgw6-v4j6"
  }, {
    "type" : "WEB",
    "url" : "https://blog.jquery.com/2020/04/10/jquery-3-5-0-released"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-mhp6-pxh8-r675"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/angular/angular.js"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-ANGULAR-570058"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-08-05T21:46:46Z",
    "nvd_published_at" : null
  }
}