# CVE-2021-38185: Integer overflow in n/a

> Attackers can execute arbitrary code via a crafted pattern file due to an integer overflow in GNU cpio, affecting Linux distributions.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 7 Aug 2021
- **Updated:** 9 Jun 2025
- **Also known as:** ALSA-2022:1991, AZL-6357, CLEANSTART-2024-HF57565, DEBIAN-CVE-2021-38185, GHSA-pp74-ghrg-jwfh, MGASA-2021-0423, OESA-2021-1325, RHSA-2022:1991, RLSA-2022:1991, SUSE-RU-2021:2779-1, SUSE-RU-2021:2780-1, SUSE-SU-2021:14777-1, SUSE-SU-2021:14788-1, SUSE-SU-2021:2686-1, SUSE-SU-2021:2689-1, SUSE-SU-2021:2808-1, UBUNTU-CVE-2021-38185, USN-5064-1, USN-5064-2, USN-5064-3

## What is CVE-2021-38185?

CVE-2021-38185 is a high-severity vulnerability in n/a, published on 7 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

GNU cpio through 2.13 allows attackers to execute arbitrary code via a crafted pattern file, because of a dstring.c ds_fgetstr integer overflow that triggers an out-of-bounds heap write. NOTE: it is unclear whether there are common cases where the pattern file, associated with the -E option, is untrusted data.

Weakness: CWE-190 (Integer Overflow or Wraparound)

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

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cpio` | AlmaLinux:8 | All versions | 2.12-11.el8 |
| `cpio` | Red Hat:enterprise_linux:8::baseos | All versions | 0:2.12-11.el8 |
| `cpio-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:2.12-11.el8 |
| `cpio-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:2.12-11.el8 |
| `cpio` | Rocky Linux:8 | All versions | 0:2.12-11.el8 |
| `cpio` | SUSE:Enterprise Storage 6 | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:HPE Helion OpenStack 8 | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:HPE Helion OpenStack 8 | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:HPE Helion OpenStack 8 | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise High Performance Computing 15 SP1-ESPOS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise High Performance Computing 15-ESPOS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise High Performance Computing 15-LTSS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Micro 5.0 | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Module for Basesystem 15 SP2 | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Module for Basesystem 15 SP3 | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Point of Sale 11 SP3 | All versions | 2.9-75.81.14.1 |
| `cpio` | SUSE:Linux Enterprise Point of Sale 11 SP3 | All versions | 2.9-75.81.8.1 |
| `cpio` | SUSE:Linux Enterprise Server 11 SP4-LTSS | All versions | 2.9-75.81.14.1 |
| `cpio` | SUSE:Linux Enterprise Server 11 SP4-LTSS | All versions | 2.9-75.81.8.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP2-BCL | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP2-BCL | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP2-BCL | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-BCL | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-BCL | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-BCL | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-LTSS | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-LTSS | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP3-LTSS | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP4-LTSS | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP4-LTSS | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP4-LTSS | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 2.11-36.15.1 |
| `cpio` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 2.11-36.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 15 SP1-BCL | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 15 SP1-LTSS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Server 15-LTSS | All versions | 2.12-3.9.1 |
| `cpio` | SUSE:Linux Enterprise Server for SAP Applications 12 SP3 | All versions | 2.11-36.12.1 |
| `cpio` | SUSE:Linux Enterprise Server for SAP Applications 12 SP3 | All versions | 2.11-36.15.1 |

Products: Gnu Cpio.

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

Apply the vendor's patch.

## Is CVE-2021-38185 being exploited?

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

Public exploit code:

- ACE poc exploit for glibc cpio 2.13 through mmap chunk metadata curruption (CVE-2021-38185) (github_poc): https://github.com/fangqyi/cpiopwn

## Other vulnerabilities in n/a

- [CVE-2010-4226](https://insights.sbomify.com/CVE-2010-4226/): Path traversal in n/a (high 7.2)
- [CVE-2010-0624](https://insights.sbomify.com/CVE-2010-0624/): Memory corruption in n/a (medium 6.8)
- [CVE-2019-14866](https://insights.sbomify.com/CVE-2019-14866/): Path traversal in cpio (medium 6.7)
- [CVE-2023-7216](https://insights.sbomify.com/CVE-2023-7216/): Cpio: extraction allows symlinks which enables remote command execution (medium 5.3)
- [CVE-2023-7207](https://insights.sbomify.com/CVE-2023-7207/): Path traversal in Debian cpio (medium 4.9)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-38185 is a high-severity vulnerability in n/a, published on 7 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-38185 in the wild and no public exploit code.

Affected product: n/a. 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-38185/ (Markdown: https://insights.sbomify.com/CVE-2021-38185/index.md)
```

## Sources

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

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