Skip to content
Memory corruption Advisory Advanced CVE-2021-28460

Microsoft Azure Sphere Kernel pwm_ioctl_apply_state kfree() code execution vulnerability

A kernel driver in Azure Sphere mishandles a failed copy_from_user, leaving an attacker-controlled pointer in a structure that is later freed with kfree. An attacker with local access can trigger an arbitrary kfree, potentially leading to code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

High 8.1 View original

A code execution vulnerability exists in the kernel pwmioctlapplystate functionality of Microsoft Azure Sphere 21.01. A specially crafted ioctl can lead to arbitrary kfree.

Lilith >_>, on Cisco Talos

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the driver fails to initialise the extended_state pointer when copy_from_user fails, so kfree is called on an attacker-controlled value.

Impact

An attacker with local access could achieve arbitrary code execution in the kernel, though an information leak is needed to make exploitation reliable.

What the attacker needed

Local access to the device; userland code execution; access to /dev/pwm*

How it was found

  1. Obtain userland code execution on the device with access to /dev/pwm*.
  2. Craft an ioctl call to PWM_APPLY_STATE with a pwm_chardev_params buffer that is not 32-bit aligned and whose last three bytes are unreadable.
  3. The copy_from_user fails, leaving the extended_state pointer controlled by the attacker.
  4. The driver calls kfree on that pointer, causing an arbitrary free.

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 report has not been written yet. The Original tab links to the source.

This is a bug in a device driver that runs with high privileges. When the driver tries to copy data from a user program and that copy fails partway, it does not clear all the data it received. Later it frees a pointer that the attacker can control, which can crash the system or let the attacker run their own code.

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.

More by Lilith >_>

View all

148 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

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.