# CVE-2021-42574: Code injection in n/a

> Attackers can hide malicious logic in source code using Unicode control characters, bypassing human review and causing compilers to execute unintended code.

- **Severity:** High 8.3 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 1 Nov 2021
- **Updated:** 4 Aug 2024
- **Also known as:** ALPINE-CVE-2021-42574, ALSA-2021:4585, ALSA-2021:4586, ALSA-2021:4587, ALSA-2021:4590, ALSA-2021:4591, ALSA-2021:4592, ALSA-2021:4593, ALSA-2021:4594, ALSA-2021:4595, ALSA-2021:4649, ALSA-2021:4743, CLEANSTART-2026-XV51845, CLSA-2026-1777310036, CLSA-2026-1777456424, DEBIAN-CVE-2021-42574, MGASA-2021-0517, OESA-2022-1501, RHSA-2021:4033, RHSA-2021:4034, RHSA-2021:4035, RHSA-2021:4036, RHSA-2021:4037, RHSA-2021:4038, RHSA-2021:4039, RHSA-2021:4585, RHSA-2021:4586, RHSA-2021:4587, RHSA-2021:4588, RHSA-2021:4589, RHSA-2021:4590, RHSA-2021:4591, RHSA-2021:4592, RHSA-2021:4593, RHSA-2021:4594, RHSA-2021:4595, RHSA-2021:4596, RHSA-2021:4598, RHSA-2021:4599, RHSA-2021:4600, RHSA-2021:4601, RHSA-2021:4602, RHSA-2021:4649, RHSA-2021:4669, RHSA-2021:4694, RHSA-2021:4723, RHSA-2021:4724, RHSA-2021:4729, RHSA-2021:4730, RHSA-2021:4743, RLSA-2021:4585, RLSA-2021:4586, RLSA-2021:4587, RLSA-2021:4590, RLSA-2021:4591, RLSA-2021:4592, RLSA-2021:4593, RLSA-2021:4594, RLSA-2021:4595, RLSA-2021:4649, RLSA-2021:4743, UBUNTU-CVE-2021-42574, openSUSE-SU-2024:11650-1

## What is CVE-2021-42574?

CVE-2021-42574 is a high-severity code injection vulnerability in Fedoraproject Fedora, published on 1 Nov 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

An issue was discovered in the Bidirectional Algorithm in the Unicode Specification through 14.0. It permits the visual reordering of characters via control sequences, which can be used to craft source code that renders different logic than the logical ordering of tokens ingested by compilers and interpreters. Adversaries can leverage this to encode source code for compilers accepting Unicode such that targeted vulnerabilities are introduced invisibly to human reviewers. NOTE: the Unicode Consortium offers the following alternative approach to presenting this concern. An issue is noted in the nature of international text that can affect applications that implement support for The Unicode Standard and the Unicode Bidirectional Algorithm (all versions). Due to text display behavior when text includes left-to-right and right-to-left characters, the visual order of tokens may be different from their logical order. Additionally, control characters needed to fully support the requirements of bidirectional text can further obfuscate the logical order of tokens. Unless mitigated, an adversary could craft source code such that the ordering of tokens perceived by human reviewers does not match what will be processed by a compiler/interpreter/etc. The Unicode Consortium has documented this class of vulnerability in its document, Unicode Technical Report #36, Unicode Security Considerations. The Unicode Consortium also provides guidance on mitigations for this class of issues in Unicode Technical Standard #39, Unicode Security Mechanisms, and in Unicode Standard Annex #31, Unicode Identifier and Pattern Syntax. Also, the BIDI specification allows applications to tailor the implementation in ways that can mitigate misleading visual reordering in program text; see HL4 in Unicode Standard Annex #9, Unicode Bidirectional Algorithm.

Weakness: CWE-94 (Improper Control of Generation of Code)

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

It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `annobin` | AlmaLinux:8 | All versions | 9.72-1.el8_5.2 |
| `annobin-annocheck` | AlmaLinux:8 | All versions | 9.72-1.el8_5.2 |
| `binutils-devel` | AlmaLinux:8 | All versions | 2.30-108.el8_5.1 |
| `cargo` | AlmaLinux:8 | All versions | 1.54.0-3.module_el8.5.0+2599+d655d86c |
| `cargo-doc` | AlmaLinux:8 | All versions | 1.54.0-3.module_el8.5.0+2599+d655d86c |
| `clang` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clang-analyzer` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clang-devel` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clang-libs` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clang-resource-filesystem` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clang-tools-extra` | AlmaLinux:8 | All versions | 12.0.1-4.module_el8.4.0+2600+cefb5d4c |
| `clippy` | AlmaLinux:8 | All versions | 1.54.0-3.module_el8.5.0+2599+d655d86c |
| `compiler-rt` | AlmaLinux:8 | All versions | 12.0.1-1.module_el8.4.0+2600+cefb5d4c |
| `cpp` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-c++` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-gdb-plugin` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-gfortran` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-offload-nvptx` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-plugin-devel` | AlmaLinux:8 | All versions | 8.5.0-4.el8_5.alma |
| `gcc-toolset-10-annobin` | AlmaLinux:8 | All versions | 9.29-1.el8_5.2 |
| `gcc-toolset-10-binutils` | AlmaLinux:8 | All versions | 2.35-8.el8_5.6 |
| `gcc-toolset-10-binutils-devel` | AlmaLinux:8 | All versions | 2.35-8.el8_5.6 |
| `gcc-toolset-10-gcc` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-gcc-c++` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-gcc-gdb-plugin` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-gcc-gfortran` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-gcc-plugin-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libasan-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libatomic-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libitm-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-liblsan-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libquadmath-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libstdc++-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libstdc++-docs` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libtsan-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-10-libubsan-devel` | AlmaLinux:8 | All versions | 10.3.1-1.2.el8_5 |
| `gcc-toolset-11-annobin-annocheck` | AlmaLinux:8 | All versions | 9.85-1.el8_5.1 |
| `gcc-toolset-11-annobin-docs` | AlmaLinux:8 | All versions | 9.85-1.el8_5.1 |
| `gcc-toolset-11-annobin-plugin-gcc` | AlmaLinux:8 | All versions | 9.85-1.el8_5.1 |

Products: Fedoraproject Fedora, Starwindsoftware Starwind Virtual San, Unicode Unicode.

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

Apply the vendor's patch.

## Is CVE-2021-42574 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-42574 exists.

Public exploit code:

- Generate malicious files using recently published bidi-attack (CVE-2021-42574) (github_poc): https://github.com/simplylu/CVE-2021-42574
- Checks your files for existence of Unicode BIDI characters which can be misused for supply chain attacks. See CVE-2021-42574  (github_poc): https://github.com/maweil/bidi_char_detector
- Scan code for invisible bidirectional Unicode characters (Trojan Source attack prevention, CVE-2021-42574) (github_poc): https://github.com/Moshe-ship/bidi-guard
- Research-only AI watermark & provenance robustness toolkit: local reverse proxy (OpenAI/Anthropic/Gemini) + CLI stripping C2PA/EXIF/XMP, zero-width & homoglyph Unicode, KGW text watermarks, DWT/Tree-Ring image stego, AudioSeal, PDF/DOCX/PPTX/XLSX metadata, and Trojan Source (CVE-2021-42574) code scanning. (github_poc): https://github.com/rakib-nyc/nullorigin
- POC of CVE-2021-42574 for solidity and solc compiler (github_poc): https://github.com/tin-z/solidity_CVE-2021-42574-POC
- https://github.com/sotiak/CVE-2021-42574 (github_poc): https://github.com/sotiak/CVE-2021-42574

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2024-4577](https://insights.sbomify.com/CVE-2024-4577/): PHP-CGI OS Command Injection (critical 9.8, exploited in the wild)
- [CVE-2021-39226](https://insights.sbomify.com/CVE-2021-39226/): Grafana Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2019-5544](https://insights.sbomify.com/CVE-2019-5544/): VMware ESXi and Horizon DaaS OpenSLP Heap-Based Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2024-4947](https://insights.sbomify.com/CVE-2024-4947/): Google Chromium V8 Type Confusion (critical 9.6, exploited in the wild)
- [CVE-2024-4671](https://insights.sbomify.com/CVE-2024-4671/): Google Chromium Visuals Use-After-Free (critical 9.6, exploited in the wild)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-42574 is a high-severity code injection vulnerability in Fedoraproject Fedora, published on 1 Nov 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-42574 exists.

Affected product: Fedoraproject Fedora. No package-level version data is available, so check the vendor advisory linked from the reference page.

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-42574/ (Markdown: https://insights.sbomify.com/CVE-2021-42574/index.md)
```

## Sources

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

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