CVE-2021-4231: @angular/core Cross-Site Scripting Vulnerability
MODERATECVE-2021-4231 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @angular/core libraries in the npm ecosystem. The issue involves angular vulnerable to cross-site scripting. Remediation is available by upgrading affected packages to version 11.0.5, 11.1.0-next.3, 10.2.5.
CVE-2021-4231 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2021-4231
To remediate this vulnerability, upgrade all affected @angular/core dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @angular/core@11.0.5
npm install @angular/core@11.1.0-next.3
npm install @angular/core@10.2.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @angular/core
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-4231, inspect your project dependencies using npm:
npm ls @angular/core
Analyze the terminal output to locate any version of @angular/core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 11.0.5), your application is affected.
Note: The npm ls @angular/core 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/core, 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
CVE-2021-4231 Affected @angular/core Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@angular/core
|
npm |
≥ 11.0.0
< 11.0.5
|
11.0.5
|
|
@angular/core
|
npm |
≥ 11.1.0-next.0
< 11.1.0-next.3
|
11.1.0-next.3
|
|
@angular/core
|
npm |
< 10.2.5
|
10.2.5
|
References
Frequently Asked Questions
What is CVE-2021-4231?
Which @angular/core versions are affected?
What version fixes CVE-2021-4231?
Is @angular/core affected?
What is the CVSS score of CVE-2021-4231?
What CWE is associated with CVE-2021-4231?
How can I check npm dependencies for CVE-2021-4231?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-c75v-2vq8-878f",
"modified" : "2025-11-20T21:47:22Z",
"published" : "2022-05-27T00:01:08Z",
"aliases" : [ "CVE-2021-4231" ],
"summary" : "Angular vulnerable to Cross-site Scripting",
"details" : "A vulnerability was found in Angular up to 11.0.4/11.1.0-next.2. It has been classified as problematic. Affected is the handling of comments. The manipulation leads to cross site scripting. It is possible to launch the attack remotely but it might require an authentication first. Upgrading to version 10.2.5, 11.0.5 or 11.1.0-next.3 is advised to to address this issue.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@angular/core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "11.0.0"
}, {
"fixed" : "11.0.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@angular/core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "11.1.0-next.0"
}, {
"fixed" : "11.1.0-next.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 11.1.0-next.2"
}
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@angular/core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "10.2.5"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-4231"
}, {
"type" : "WEB",
"url" : "https://github.com/angular/angular/issues/40136"
}, {
"type" : "WEB",
"url" : "https://github.com/angular/angular/commit/0aa220bc0000fc4d1651ec388975bbf5baa1da36"
}, {
"type" : "WEB",
"url" : "https://github.com/angular/angular/commit/47d9b6d72dab9d60c96bc1c3604219f6385649ea"
}, {
"type" : "WEB",
"url" : "https://github.com/angular/angular/commit/ba8da742e3b243e8f43d4c63aa842b44e14f2b09"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/angular/angular"
}, {
"type" : "WEB",
"url" : "https://security.snyk.io/vuln/SNYK-JS-ANGULARCORE-1070902"
}, {
"type" : "WEB",
"url" : "https://vuldb.com/?id.181356"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-06-02T18:58:52Z",
"nvd_published_at" : "2022-05-26T14:15:00Z"
}
}