Skip to content
Access control Write-up Advanced

Exploiting a Flaw in Bitmap Handling in Windows User-Mode Printer Drivers

A use-after-free in win32kfull allows a malicious user-mode printer driver to bypass bitmap validation and pass a crafted bitmap to a kernel-mode display driver, potentially leading to privilege escalation. The bug was patched by Microsoft.

thezdi.com

Published on thezdi.com

In the Windows kernel, there are three APIs intended for general use by device drivers for the purpose of creating bitmaps: EngCreateBitmap, EngCreateDeviceBitmap and EngCreateDeviceSurface. Each of these APIs return a bitmap handle.

The author, on thezdi.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

The user-mode EngLockSurface validation could be bypassed because the kernel trusted the UMSO.hsurf handle without re-validating the bitmap type, allowing a screen-related bitmap to reach a kernel-mode display driver.

Impact

A malicious user-mode printer driver could potentially escalate privileges to kernel mode, though the text does not demonstrate a full exploit.

What the attacker needed

Ability to run user-mode printer driver code; a printer installed (virtual printer present by default)

The fix

The patch re-validates the bitmap handle in GetLockableSURFOBJ by calling IsSurfaceLockable, rejecting screen-related bitmaps.

How it was found

  1. Hook or patch gdi32.dll!GdiPrinterThunk to run code during a printer callback.
  2. Initiate a printing operation to trigger the callback.
  3. Create a destination bitmap with a screen-related hdev and HOOK_XXX flags.
  4. Create a source bitmap with dhsurf pointing to controlled memory.
  5. Prepare UMSO records for both bitmaps.
  6. Call an EngXXX API that accepts two bitmaps to reach the kernel display driver.

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.

Windows printer drivers run in user mode, but they can call kernel functions that handle bitmaps. A validation step was supposed to stop them from using certain bitmaps that could reach kernel display drivers, but it could be bypassed. This could let an attacker with low privileges take control of the kernel.

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.