Skip to content
Memory corruption Write-up Advanced

Xen exploitation part 2: XSA-148, from guest to host

A flaw in Xen's handling of level 2 page table entries allowed a paravirtualised guest to create writable super page mappings, bypassing Xen's read-only invariants. An attacker with control of a guest could therefore read and write arbitrary machine memory, leading to code execution in the dom0 context.

blog.quarkslab.com

Published on blog.quarkslab.com

Posted Wed 27 July 2016 Author Jérémie Boutoille Category Exploitation Tags Xen, exploitation, PoC, guest-to-host, vm escape, 2016

Jérémie Boutoille, on blog.quarkslab.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

Root cause

Likely the fast path in mod_l2_entry() did not check the PSE and RW bits when deciding whether to skip validation, and L2_DISALLOW_MASK unconditionally allowed the PSE bit, so a guest could set the super page flag without the allowsuperpage option.

Impact

A guest can read and write any machine page, allowing code execution in dom0's context; the text does not mention any defence that limited the exploit.

What the attacker needed

Control of a paravirtualised x86 guest; ability to make hypercalls

The fix

The fix was to make L2_DISALLOW_MASK conditional on opt_allow_superpage and to include the PSE and RW bits in the fast-path check.

How it was found

  1. Take a virtual address and set the PSE flag on its corresponding L2 entry.
  2. Access the whole L1 page table with write rights and craft entries that bypass Xen invariants.
  3. Unset the PSE flag.
  4. Access any physical page.

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.

Xen is software that lets one physical computer run several virtual computers (guests). Normally a guest is kept separate and cannot touch the memory of the host or other guests. This bug let a guest trick Xen into giving it write access to memory it should only be able to read, so the guest could take over the host.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.