Skip to content
Access control Write-up Advanced

Pandavirtualization: Exploiting the Xen hypervisor

Xen's access_ok() check for the memory_exchange hypercall only validated the start of the guest array, not the full range, allowing a guest kernel to write 8-byte values to arbitrary hypervisor memory. An attacker with root in a paravirtualised guest could exploit this to gain control of page tables and execute commands in other guests, including dom0.

googleprojectzero.blogspot.com

Published on googleprojectzero.blogspot.com

On 2017-03-14, I reported a bug to Xen's security team that permits an attacker with control over the kernel of a paravirtualized x86-64 Xen guest to break out of the hypervisor and gain full control over the machine's physical memory. The Xen Project publicly released an advisory and a patch for this issue 2017-04-04.

The author, on googleprojectzero.blogspot.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker with root in a paravirtualised guest could break out of the hypervisor and gain full control over the machine's physical memory, including the ability to execute commands in other guests such as dom0.

What the attacker needed

Root privileges in a 64-bit PV Xen guest

How it was found

  1. Set extent_order fields to 0 to exchange page-sized blocks.
  2. Choose out.extent_start and nr_exchanged so that out.extent_start points to userspace and out.extent_start+8*nr_exchanged points to the target hypervisor address.
  3. Set in.nr_extents and out.nr_extents to nr_exchanged+1.
  4. Set in.extent_start to a legitimate guest kernel pointer minus 8*nr_exchanged.
  5. Invoke the memory_exchange hypercall to write a physical page number to the target address.
  6. Repeat to write controlled bytes and modify a live page table, then map arbitrary physical memory.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

In a virtualised system, a hypervisor runs multiple virtual machines (guests) and must protect itself from them. Xen provides hypercalls, which are like system calls from a guest to the hypervisor. A bug in one hypercall allowed a guest to trick the hypervisor into writing to its own memory, letting the guest take over the whole physical machine.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.