# CVE-2021-3748: Use after free in QEMU (virtio-net)

> A malicious guest can trigger a use-after-free in QEMU's virtio-net device to crash the host or execute arbitrary code with QEMU privileges.

- **Severity:** High 7.5 (`CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 23 Mar 2022
- **Updated:** 3 Aug 2024
- **Also known as:** AZL-9121, DEBIAN-CVE-2021-3748, GHSA-4f87-mww8-gm8x, OESA-2021-1371, RHSA-2021:4112, RHSA-2021:5036, UBUNTU-CVE-2021-3748

## What is CVE-2021-3748?

CVE-2021-3748 is a high-severity use after free vulnerability in Canonical Ubuntu Linux, published on 23 Mar 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A use-after-free vulnerability was found in the virtio-net device of QEMU. It could occur when the descriptor's address belongs to the non direct access region, due to num_buffers being set after the virtqueue elem has been unmapped. A malicious guest could use this flaw to crash QEMU, resulting in a denial of service condition, or potentially execute code on the host with the privileges of the QEMU process.

Weakness: CWE-416 (Use After Free)

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

It affects 6 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `SLOF` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:20191022-3.git899d9883.module+el8.2.0+5449+efc036dd |
| `hivex` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.3.18-20.module+el8.2.0+5588+63a201c3 |
| `hivex-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.3.18-20.module+el8.2.0+5588+63a201c3 |
| `hivex-debugsource` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.3.18-20.module+el8.2.0+5588+63a201c3 |
| `hivex-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.3.18-20.module+el8.2.0+5588+63a201c3 |
| `libguestfs` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-bash-completion` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-benchmarking` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-benchmarking-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-debugsource` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-gfs2` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-gobject` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-gobject-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-gobject-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-inspect-icons` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-java` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-java-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-java-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-javadoc` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-man-pages-ja` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-man-pages-uk` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-rescue` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-rsync` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-tools` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-tools-c` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-tools-c-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libguestfs-winsupport` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:8.2-2.module+el8.2.1+12663+d52ebc0d |
| `libguestfs-xfs` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 1:1.40.2-24.module+el8.2.1+7154+47ffd890 |
| `libiscsi` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libiscsi-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libiscsi-debugsource` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libiscsi-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libiscsi-utils` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libiscsi-utils-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.18.0-8.module+el8.2.0+4793+b09dd2fb |
| `libnbd` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.2.2-1.module+el8.2.0+5644+32ac38d4 |
| `libnbd-debuginfo` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.2.2-1.module+el8.2.0+5644+32ac38d4 |
| `libnbd-debugsource` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.2.2-1.module+el8.2.0+5644+32ac38d4 |
| `libnbd-devel` | Red Hat:advanced_virtualization:8.2::el8 | All versions | 0:1.2.2-1.module+el8.2.0+5644+32ac38d4 |

Products: Canonical Ubuntu Linux, Debian Debian Linux, Fedoraproject Fedora, Qemu Qemu, Redhat Enterprise Linux, Redhat Enterprise Linux Advanced Virtualization Eus.

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

Apply the vendor's patch.

## Is CVE-2021-3748 being exploited?

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

## Other vulnerabilities in Canonical Ubuntu Linux

- [CVE-2020-11651](https://insights.sbomify.com/CVE-2020-11651/): SaltStack Salt Authentication Bypass (critical 9.8, exploited in the wild)
- [CVE-2020-7247](https://insights.sbomify.com/CVE-2020-7247/): OpenSMTPD Remote Code Execution (critical 9.8, exploited in the wild)
- [CVE-2019-16928](https://insights.sbomify.com/CVE-2019-16928/): Exim Out-of-bounds Write (critical 9.8, exploited in the wild)
- [CVE-2018-6789](https://insights.sbomify.com/CVE-2018-6789/): Exim Buffer Overflow (critical 9.8, exploited in the wild)
- [CVE-2015-2590](https://insights.sbomify.com/CVE-2015-2590/): Oracle Java SE and Java SE Embedded Remote Code Execution (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

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

What it is: CVE-2021-3748 is a high-severity use after free vulnerability in Canonical Ubuntu Linux, published on 23 Mar 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-3748 in the wild and no public exploit code.

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

## Sources

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

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