# CVE-2021-3782: Integer overflow in wayland

> Integer overflow in Wayland buffer pool reference counting allows use-after-free, potentially leading to code execution or memory leakage.

- **Severity:** Medium 6.6 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 23 Sep 2022
- **Updated:** 22 May 2025
- **Also known as:** ALSA-2023:2786, AZL-11019, DEBIAN-CVE-2021-3782, GHSA-pvw2-9h4r-c5cr, JLSEC-2026-97, MGASA-2022-0418, OESA-2022-1920, RHSA-2023:2786, RLSA-2023:2786, SUSE-SU-2023:1860-1, SUSE-SU-2023:1864-1, SUSE-SU-2023:1873-1, SUSE-SU-2023:1874-1, UBUNTU-CVE-2021-3782, USN-5614-1, USN-5614-2

## What is CVE-2021-3782?

CVE-2021-3782 is a medium-severity vulnerability in wayland, published on 23 Sep 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

An internal reference count is held on the buffer pool, incremented every time a new buffer is created from the pool. The reference count is maintained as an int; on LP64 systems this can cause the reference count to overflow if the client creates a large number of wl_shm buffer objects, or if it can coerce the server to create a large number of external references to the buffer storage. With the reference count overflowing, a use-after-free can be constructed on the wl_shm_pool tracking structure, where values may be incremented or decremented; it may also be possible to construct a limited oracle to leak 4 bytes of server-side memory to the attacking client at a time.

Weakness: CWE-190 (Integer Overflow or Wraparound)

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

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libwayland-client` | AlmaLinux:8 | All versions | 1.21.0-1.el8 |
| `libwayland-cursor` | AlmaLinux:8 | All versions | 1.21.0-1.el8 |
| `libwayland-egl` | AlmaLinux:8 | All versions | 1.21.0-1.el8 |
| `libwayland-server` | AlmaLinux:8 | All versions | 1.21.0-1.el8 |
| `wayland-devel` | AlmaLinux:8 | All versions | 1.21.0-1.el8 |
| `libwayland-client` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-client-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-cursor` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-cursor-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-egl` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-egl-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-server` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `libwayland-server-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland-devel-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:1.21.0-1.el8 |
| `wayland` | Rocky Linux:8 | All versions | 0:1.21.0-1.el8 |
| `wayland` | SUSE:Enterprise Storage 7 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Enterprise Storage 7.1 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 1.16.0-150100.7.3.1 |
| `wayland` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Micro 5.2 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Micro 5.3 | All versions | 1.19.0-150400.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Micro 5.4 | All versions | 1.19.0-150400.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Module for Basesystem 15 SP4 | All versions | 1.19.0-150400.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Real Time 15 SP3 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 1.13.0-3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server 15 SP1-LTSS | All versions | 1.16.0-150100.7.3.1 |
| `wayland` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server for SAP Applications 12 SP5 | All versions | 1.13.0-3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server for SAP Applications 15 SP1 | All versions | 1.16.0-150100.7.3.1 |
| `wayland` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 1.18.0-150200.3.3.1 |
| `wayland` | SUSE:Linux Enterprise Software Development Kit 12 SP5 | All versions | 1.13.0-3.3.1 |
| `wayland` | SUSE:Manager Proxy 4.2 | All versions | 1.18.0-150200.3.3.1 |

Products: Wayland Wayland.

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

Apply the vendor's patch.

## Is CVE-2021-3782 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2021-3782 is a medium-severity vulnerability in wayland, published on 23 Sep 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-3782 in the wild and no public exploit code.

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

## Sources

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

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