psf-linux-kernel-kvm-escape-check(8)

Script: /opt/psf-security-patches/linux-kernel/linux-kernel-kvm-escape-check.sh. Tool page: Linux kernel. Source. With the package installed: man psf-linux-kernel-kvm-escape-check.

Linux kernel KVM guest-to-host escape on AMD (nested SVM): checker  (v1)
CVE-2026-99312

If this software is helpful, consider a donation to our 501c3 nonprofit:
https://privacysafe.foundation

Terra Security (Oren Yomtov) disclosed CVE-2026-99312 on 18 November 2026: a guest VM on an
AMD KVM host with nested virtualization on can read and write the host's physical memory,
which on a shared host means every other tenant's memory too. Terra demonstrated the read on
an ordinary DigitalOcean droplet (the host's kernel banner, then about 127 GB of host RAM) and
the write on their own server, so as not to disrupt other customers. Arbitrary write to host
memory is the step before code execution on the host.

The official record (the Linux kernel's own CNA entry, mirrored by NVD and Red Hat) describes
the underlying bug, an unconditional MMU-context reset missing when KVM emulates an INIT while
a nested guest's paging is off, and scores it as a local denial-of-service (CVSS vector ending
C:N/I:N/A:H: no confidentiality or integrity impact, only availability). Terra's own research,
corroborated independently, found the same bug chains with a use-after-free in KVM's nested SVM
handling (a stale nCR3 pointer left referencing a recycled page-table page) and an Accessed-bit
timing oracle, into a full guest-to-host memory read and write. Treat it accordingly: the
official score describes the kernel's own accounting of the bug class, not what was actually
demonstrated against it.

This is a fix landing on top of an older one. In 2022, a different, already-fixed KVM reset
flaw was fixed by switching a reset back to the control block of the VM that runs
the nested one before anything is freed. CVE-2026-99312 is a flaw that fix itself opened,
unrelated to three other 2026 KVM guest-to-host escapes found by a different researcher under
the names ITScape (arm64), Januscape and Zapscape (x86, both affecting Intel and AMD); do not
confuse this script's one CVE and one AMD-only mitigation with those.

Affected: nested virtualization on AMD (kvm_amd), on any kernel from 6.1 up to, but not
including, the fixed releases below. INIT is an unconditional intercept on Intel VMX, so Intel
nested virtualization (kvm_intel) cannot reach this specific bug. The precondition for this
flaw came from a November 2022 commit that was itself widely backported at the time, confirmed
at least as far back as the (now unsupported) stable branches 5.15.81 and 6.0.11. Nothing
confirms that other branches below 6.1 also receiving backports in November 2022 (5.10 and
5.4, for instance) escaped it, so `check` reports those as unknown rather than clear. First
fixed stable release of each currently maintained branch: 6.12.118, 6.18.64, 7.3.5; first
mainline release with the fix: 7.4-rc2 (9 November 2026).

check and hunt change nothing. check reports the kernel version against the fixed releases,
whether this is an AMD host, whether kvm_amd is loaded, and the current nested parameter.
mitigate sets kvm_amd's nested module parameter to 0, which closes this path entirely: it
writes a modprobe.d file so this applies the next time kvm_amd loads, and separately, only
with --unload, unloads and reloads kvm_amd now (every VM on the host must already be stopped,
since the module cannot unload while any are running, and the parameter is read only at load
time, so there is no way to apply it to an already-loaded module without a reload or reboot).

Usage:
  ./linux-kernel-kvm-escape-check.sh [command] [options]

  check (default)   kernel version against the fixed releases; whether this is an AMD host;
                    kvm_amd's load state and current nested parameter. Exit 0 = not exposed
                    (patched, not AMD, module absent, or nested already off), 1 = exposed,
                    2 = something couldn't be read.
  mitigate [--unload] [--force] [--dry-run]   (root for anything but --dry-run) Writes
                    /etc/modprobe.d/psf-kvm-amd-nested-off.conf ("options kvm_amd nested=0").
                    Refuses if kvm_amd is currently loaded, unless --unload (which refuses in
                    turn if any VM is running on it, since modprobe -r fails while anything
                    uses the module) or --force (writes the file regardless, with a reminder
                    that it only takes effect on kvm_amd's next load, which on most hosts
                    means after a reboot). --dry-run shows what would happen.
  rollback [--dry-run]   (root) removes the modprobe.d file. Does not reload kvm_amd with
                    nested back on; that needs the same drain this script will not do for you.
  rules             prints the file mitigate writes and the manual unload/reload commands.
  version           print the script version.

Env overrides:
  NESTED_FIXED_6_12=6.12.118   NESTED_FIXED_6_18=6.18.64   NESTED_FIXED_7=7.3.5
  NESTED_FIXED_MAINLINE=7.4-rc2
  KERNEL_RELEASE, KERNEL_VERSION_STRING   for testing: override `uname -r` and `uname -v`
  KERNEL_MODULES_FILE (default /proc/modules), KERNEL_BUILTIN_FILE, KERNEL_CHANGELOG
  CPU_VENDOR_FILE (default /proc/cpuinfo)   for testing: override where the CPU vendor is read
  NESTED_PARAM_FILE (default /sys/module/kvm_amd/parameters/nested)
  STATE_DIR (default /var/lib/psf-security-patches/linux-kernel-kvm-escape)
  PSF_LOCK_WAIT   seconds a run that changes the host waits for another one already changing
                  it (default 30), then stops with exit 2; the lock is STATE_DIR/.lock

The Security Patches software and this documentation are dedicated to the public domain under CC0 1.0 Universal. Other pages on privacysafe.app/docs are CC BY-SA 4.0 unless the page says otherwise.

The PrivacySafe Ecosystem

Shop at Ivy Cyber

Ivy Cyber offers PrivacySafe products and services in the USA and has partnerships with 3NSoft in Canada and Kuip Limited in the European Union. Enterprise services and consulting are available at ivycyber.com

PrivacySafe Foundation is a 501(c)(3) nonprofit public charity that supports the development of the PrivacySafe applications, along with the components they rely upon: 3NWeb protocols, filesystem, documentation, and reference implementations.

PrivacySafe Foundation

Donations to PrivacySafe Foundation support education, research, documentation, and public code. Purchases from Ivy Cyber support PrivacySafe products, services, hosting, and technical support. Together, we're building a better web.