# CVE-2021-32142: Memory corruption in n/a

> A buffer overflow in LibRaw allows attackers to escalate privileges or execute code via crafted image data.

- **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:** 17 Feb 2023
- **Updated:** 19 Mar 2025
- **Also known as:** ALSA-2023:6343, ALSA-2024:2994, AZL-43756, AZL-45267, CLSA-2025-1745427138, DEBIAN-CVE-2021-32142, GHSA-2vqp-59qv-pmrc, MGASA-2023-0082, OESA-2024-1339, OESA-2024-1446, OESA-2024-1447, OESA-2024-1448, OESA-2024-1449, OESA-2024-1450, RHSA-2023:6343, RHSA-2024:0343, RHSA-2024:2994, RLSA-2024:2994, SUSE-SU-2023:0510-1, SUSE-SU-2023:0511-1, SUSE-SU-2023:0512-1, UBUNTU-CVE-2021-32142

## What is CVE-2021-32142?

CVE-2021-32142 is a high-severity memory corruption vulnerability in Libraw Libraw, published on 17 Feb 2023. 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

Buffer Overflow vulnerability in LibRaw linux/unix v0.20.0 allows attacker to escalate privileges via the LibRaw_buffer_datastream::gets(char*, int) in /src/libraw/src/libraw_datastream.cpp.

Weakness: CWE-787 (Out-of-bounds Write)

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

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `LibRaw` | AlmaLinux:8 | All versions | 0.19.5-4.el8 |
| `LibRaw-devel` | AlmaLinux:8 | All versions | 0.19.5-4.el8 |
| `LibRaw` | AlmaLinux:9 | All versions | 0.20.2-6.el9 |
| `LibRaw-devel` | AlmaLinux:9 | All versions | 0.20.2-6.el9 |
| `LibRaw` | Red Hat:enterprise_linux:7::client | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-devel` | Red Hat:enterprise_linux:7::client | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-static` | Red Hat:enterprise_linux:7::client | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw` | Red Hat:enterprise_linux:7::server | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:7::server | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-devel` | Red Hat:enterprise_linux:7::server | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-static` | Red Hat:enterprise_linux:7::server | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-devel` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw-static` | Red Hat:enterprise_linux:7::workstation | All versions | 0:0.19.4-2.el7_9 |
| `LibRaw` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.19.5-4.el8 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.19.5-4.el8 |
| `LibRaw-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.19.5-4.el8 |
| `LibRaw-samples-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.19.5-4.el8 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:8::crb | All versions | 0:0.19.5-4.el8 |
| `LibRaw-debugsource` | Red Hat:enterprise_linux:8::crb | All versions | 0:0.19.5-4.el8 |
| `LibRaw-devel` | Red Hat:enterprise_linux:8::crb | All versions | 0:0.19.5-4.el8 |
| `LibRaw-samples-debuginfo` | Red Hat:enterprise_linux:8::crb | All versions | 0:0.19.5-4.el8 |
| `LibRaw` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.20.2-6.el9 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.20.2-6.el9 |
| `LibRaw-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.20.2-6.el9 |
| `LibRaw-samples-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.20.2-6.el9 |
| `LibRaw-debuginfo` | Red Hat:enterprise_linux:9::crb | All versions | 0:0.20.2-6.el9 |
| `LibRaw-debugsource` | Red Hat:enterprise_linux:9::crb | All versions | 0:0.20.2-6.el9 |
| `LibRaw-devel` | Red Hat:enterprise_linux:9::crb | All versions | 0:0.20.2-6.el9 |
| `LibRaw-samples-debuginfo` | Red Hat:enterprise_linux:9::crb | All versions | 0:0.20.2-6.el9 |
| `LibRaw` | Rocky Linux:8 | All versions | 0:0.19.5-4.el8 |
| `libraw` | SUSE:Linux Enterprise Module for Desktop Applications 15 SP4 | All versions | 0.20.2-150400.3.3.1 |
| `libraw` | SUSE:Linux Enterprise Software Development Kit 12 SP5 | All versions | 0.15.4-36.1 |
| `libraw` | SUSE:Linux Enterprise Workstation Extension 12 SP5 | All versions | 0.15.4-36.1 |
| `libraw` | SUSE:Linux Enterprise Workstation Extension 15 SP4 | All versions | 0.18.9-150000.3.17.1 |
| `libraw` | SUSE:Linux Enterprise Workstation Extension 15 SP4 | All versions | 0.20.2-150400.3.3.1 |
| `libraw` | openSUSE:Leap 15.4 | All versions | 0.18.9-150000.3.17.1 |
| `libraw` | openSUSE:Leap 15.4 | All versions | 0.20.2-150400.3.3.1 |

Products: Libraw Libraw.

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

Apply the vendor's patch.

## Is CVE-2021-32142 being exploited?

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

## Other vulnerabilities in Libraw Libraw

- [CVE-2026-20889](https://insights.sbomify.com/CVE-2026-20889/): Memory corruption in LibRaw (critical 9.8)
- [CVE-2026-20911](https://insights.sbomify.com/CVE-2026-20911/): Memory corruption in LibRaw (critical 9.8)
- [CVE-2026-21413](https://insights.sbomify.com/CVE-2026-21413/): Memory corruption in LibRaw (critical 9.8)
- [CVE-2015-8366](https://insights.sbomify.com/CVE-2015-8366/): Integer overflow in n/a (critical 9.8)
- [CVE-2015-8367](https://insights.sbomify.com/CVE-2015-8367/): Memory corruption in n/a (critical 9.8)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-32142 is a high-severity memory corruption vulnerability in Libraw Libraw, published on 17 Feb 2023. 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-32142 in the wild and no public exploit code.

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

## Sources

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

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