Skip to main content

CVE-2021-4093: Linux Kernel Privilege Escalation Flaw

CVE-2021-4093 is a privilege escalation vulnerability in Linux Kernel's KVM AMD SEV-ES code that allows guest VMs to trigger out-of-bounds memory access. This article covers technical details, affected versions, and mitigation.

Updated:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2021-4093 Overview

CVE-2021-4093 is an out-of-bounds read and write vulnerability [CWE-125] in the Linux kernel's Kernel-based Virtual Machine (KVM) implementation of AMD Secure Encrypted Virtualization-Encrypted State (SEV-ES). A malicious SEV-ES guest can craft a VMGEXIT for a string I/O instruction such as outs or ins using the SVM_EXIT_IOIO exit reason. The crafted exit triggers out-of-bounds memory access in the host kernel. Successful exploitation crashes the host or enables a guest-to-host escape. The flaw affects multiple Linux distributions including Red Hat Enterprise Linux, Fedora, and Ubuntu.

Critical Impact

A SEV-ES guest with local access can crash the host kernel or potentially escape virtualization boundaries to execute code in the host context.

Affected Products

  • Linux Kernel (KVM AMD subsystem with SEV-ES support)
  • Red Hat Enterprise Linux 8
  • Fedora 35
  • Ubuntu 20.04 LTS and 21.10

Discovery Timeline

  • 2022-02-18 - CVE-2021-4093 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-4093

Vulnerability Analysis

The vulnerability resides in the KVM AMD code path that emulates string I/O instructions for SEV-ES guests. SEV-ES encrypts guest CPU register state, so the hypervisor cannot inspect guest registers directly. To communicate with the host for instructions requiring emulation, SEV-ES guests use the Guest-Hypervisor Communication Block (GHCB) and issue a VMGEXIT. When the exit reason is SVM_EXIT_IOIO for a string I/O operation, the host kernel reads guest-controlled parameters from the GHCB to perform the data transfer. Insufficient validation of these parameters allows the guest to direct reads and writes outside intended buffers in the host kernel.

Root Cause

The root cause is missing bounds checking on guest-supplied I/O parameters during SVM_EXIT_IOIO handling. The KVM AMD code trusts values that the guest places into the GHCB without validating that the resulting host-side buffer access stays within allocated memory. Because SEV-ES shifts I/O emulation responsibility to the GHCB-mediated path, fields that were previously implicit in trapped instructions become explicit guest inputs that require validation.

Attack Vector

An attacker requires the ability to run code inside a SEV-ES guest on a vulnerable host. The attacker prepares a malicious GHCB describing a string ins or outs operation with crafted size or address fields, then executes VMGEXIT to transfer control to the hypervisor. The host kernel processes the exit and performs an out-of-bounds read or write while servicing the request. The flaw is local in attack vector but spans the trust boundary between guest and host, which is reflected in the scope change shown by the CVSS vector. Refer to the Red Hat Bug Report #2028584 and Chromium Project Zero Issue #2222 for technical details.

Detection Methods for CVE-2021-4093

Indicators of Compromise

  • Unexpected host kernel oops or panic messages referencing svm, sev, vmgexit, or ioio handlers in dmesg or /var/log/kern.log.
  • Abrupt termination of hypervisor processes (qemu-kvm) on hosts running SEV-ES guests, particularly with KASAN or page-fault traces.
  • SEV-ES guests issuing high volumes of VMGEXIT events with SVM_EXIT_IOIO for string I/O instructions.

Detection Strategies

  • Monitor kernel ring buffer for crash signatures originating in arch/x86/kvm/svm/ code paths handling GHCB string I/O.
  • Audit installed kernel versions across hypervisor hosts and flag any AMD EPYC system running an unpatched kernel with SEV-ES enabled.
  • Correlate guest lifecycle events with host kernel stability metrics to identify guests that consistently precede host instability.

Monitoring Recommendations

  • Enable kernel crash dump collection (kdump) on all KVM hosts to preserve forensic evidence of exploitation attempts.
  • Track package versions of kernel, linux-image, and equivalent across the fleet and alert on hosts running versions predating distribution fixes.
  • Log and review SEV-ES guest provisioning to ensure only trusted workloads run with SEV-ES enabled until patches are deployed.

How to Mitigate CVE-2021-4093

Immediate Actions Required

  • Apply the kernel updates published by Red Hat, Fedora, Canonical, and upstream Linux maintainers to all AMD KVM hosts running SEV-ES.
  • Restrict the ability to launch SEV-ES guests to trusted operators until patched kernels are in place.
  • Reboot hypervisor hosts after kernel updates to ensure the patched KVM modules are active.

Patch Information

Fixes were merged into the upstream Linux kernel and backported by major distributions. Consult the Red Hat Bug Report #2028584 for Red Hat Enterprise Linux 8 errata mappings and the Chromium Project Zero Issue #2222 for the original report and patch references. Fedora 35 and Ubuntu 20.04 LTS and 21.10 received corresponding kernel updates through their standard security channels.

Workarounds

  • Disable SEV-ES on affected hosts by booting the kernel without the kvm_amd.sev_es=1 parameter until patches are applied.
  • Avoid running untrusted workloads inside SEV-ES guests on unpatched hosts, since the threat model assumes guests can be malicious.
  • Migrate sensitive SEV-ES workloads to fully patched hosts before re-enabling encrypted virtualization features.
bash
# Verify kernel version and SEV-ES status, then apply distribution updates
uname -r
cat /sys/module/kvm_amd/parameters/sev_es

# Red Hat / Fedora
sudo dnf update kernel && sudo reboot

# Ubuntu
sudo apt update && sudo apt install --only-upgrade linux-image-generic && sudo reboot

# Temporary mitigation: disable SEV-ES until patched
echo 'options kvm_amd sev_es=0' | sudo tee /etc/modprobe.d/kvm-amd.conf

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.