# CVE-2021-4231: Angular Comment cross site scripting

> Remote attackers can execute arbitrary scripts via comment handling in Angular, potentially compromising user sessions or data.

- **Severity:** Low 3.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 26 May 2022
- **Updated:** 15 Apr 2025
- **Also known as:** CLSA-2026-1775176151, CLSA-2026-1775176154, CLSA-2026-1780707086, CLSA-2026-1783213293, CLSA-2026-1792161091, CLSA-2026-1792161093, CLSA-2026-1792161247, CLSA-2026-1792163477, CLSA-2026-1792163480, CLSA-2026-1792163638, CLSA-2026-1792208144, CLSA-2026-1792208452, CLSA-2026-1792208453, CLSA-2026-1792250472, CLSA-2026-1792250474, CLSA-2026-1792250532, CLSA-2026-1792281146, CLSA-2026-1792281699, CLSA-2026-1792281701, CLSA-2026-1792325299, CLSA-2026-1792325928, CLSA-2026-1792326048, CLSA-2026-1792345629, CLSA-2026-1792345631, CLSA-2026-1792345761, CLSA-2026-1792357306, CLSA-2026-1792357763, CLSA-2026-1792357765, CLSA-2026-1792366590, CLSA-2026-1792366876, CLSA-2026-1792366878, CLSA-2026-1792371581, CLSA-2026-1792372033, CLSA-2026-1792375681, CLSA-2026-1792376051, CLSA-2026-1792376081, CLSA-2026-1792380013, CLSA-2026-1792380381, CLSA-2026-1792380402, CLSA-2026-1792382626, CLSA-2026-1792382905, CLSA-2026-1792382906, CLSA-2026-1792386046, CLSA-2026-1792386111, CLSA-2026-1792386413, GHSA-c75v-2vq8-878f

## What is CVE-2021-4231?

CVE-2021-4231 is a low-severity cross-site scripting vulnerability in unspecified Angular, published on 26 May 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

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 11.0.5 and 11.1.0-next.3 is able to address this issue. The name of the patch is ba8da742e3b243e8f43d4c63aa842b44e14f2b09. It is recommended to upgrade the affected component.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2021-4231?

6 open source packages ship an affected version, including @angular/core. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@angular/core` | npm | All versions | 10.2.5 |
| `@angular/core` | npm | All versions | 10.2.5 |
| `@angular/core` | npm | From 11.0.0 | 11.0.5 |
| `@angular/core` | npm | From 11.0.0 | 11.0.5 |
| `@angular/core` | npm | From 11.1.0-next.0 | 11.1.0-next.3 |
| `@angular/core` | npm | From 11.1.0-next.0 | 11.1.0-next.3 |

Products: Angular Angular, Angularjs Angularjs.

## How do I fix CVE-2021-4231?

Upgrade @angular/core to a fixed version for your release line: 10.2.5, 11.0.5 or 11.1.0-next.3.

## Is CVE-2021-4231 being exploited?

There is no known exploitation of CVE-2021-4231 in the wild and no public exploit code.

## Other vulnerabilities in unspecified Angular

- [CVE-2026-68945](https://insights.sbomify.com/CVE-2026-68945/): Angular: Cache-Key Ambiguity in HttpTransferCache Leading to Cross-Request Response Reuse and State Poisoning (high 8.8)
- [CVE-2026-46417](https://insights.sbomify.com/CVE-2026-46417/): Angular: SSRF via Hostname Hijacking in @angular/platform-server (high 8.8)
- [CVE-2026-50168](https://insights.sbomify.com/CVE-2026-50168/): Angular: URL Parser Differential in @angular/platform-server leading to SSRF Allowlist Bypass (high 8.8)
- [CVE-2026-54266](https://insights.sbomify.com/CVE-2026-54266/): Angular: Weak 32-Bit Cache Key Hashing in `HttpTransferCache` Leading to Cross-Request Data Leakage and State Poisoning (high 8.8)
- [CVE-2026-41423](https://insights.sbomify.com/CVE-2026-41423/): Angular: SSRF via protocol-relative and backslash URLs in Angular Platform-Server (high 8.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-4231 and fix it if it is affected.

What it is: CVE-2021-4231 is a low-severity cross-site scripting vulnerability in unspecified Angular, published on 26 May 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-4231 in the wild and no public exploit code.

Affected packages and fixed versions:
- @angular/core (npm): affected all versions; fixed in 10.2.5
- @angular/core (npm): affected all versions; fixed in 10.2.5
- @angular/core (npm): affected from 11.0.0; fixed in 11.0.5
- @angular/core (npm): affected from 11.0.0; fixed in 11.0.5
- @angular/core (npm): affected from 11.1.0-next.0; fixed in 11.1.0-next.3
- @angular/core (npm): affected from 11.1.0-next.0; fixed in 11.1.0-next.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-4231/ (Markdown: https://insights.sbomify.com/CVE-2021-4231/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-4231
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-4231
- OSV: https://osv.dev/vulnerability/CVE-2021-4231

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-4231/
Summaries are generated and may contain mistakes; the official description above is the record.
