Microsoft Azure Sphere Kernel GPIO_SET_PIN_CONFIG_IOCTL information disclosure vulnerability
The GPIO_SET_PIN_CONFIG_IOCTL ioctl in Azure Sphere's kernel fails to validate the lineoffsets array indices, allowing an attacker to read kernel memory via an oracle based on the allowed_user check. This can leak the address of the gdev->descs array and the process's cred structure, potentially leading to further exploitation.
Originally disclosed on Cisco Talos
An information disclosure vulnerability exists in the GPIOSETPINCONFIGIOCTL functionality of Microsoft Azure Sphere 21.06. A specially crafted ioctl can lead to kernel memory leak.
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
Impact
An attacker could leak kernel memory addresses, including the location of the cred structure, which may aid in further exploitation such as privilege escalation.
What the attacker needed
Ability to execute code on Azure Sphere; access to /dev/gpiochip0
The fix
The vulnerability was fixed by the vendor on 2021-11-09.
How it was found
- Craft an ioctl call to GPIO_SET_PIN_CONFIG_IOCTL with a linecount between 1 and GPIOHANDLES_MAX and arbitrary lineoffsets values.
- The kernel dereferences gdev->descs[lineoffsets[i]] and checks if the allowed_user field matches the current UID.
- By observing whether the ioctl returns EACCES or a different error, determine if the memory at that address contains the UID.
- Iterate over lineoffsets values (using integer wraparound) to scan kernel memory for the UID pattern.
- Use the oracle to locate the gdev->descs array and the process's cred structure.
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.
A kernel driver for GPIO pins lets programs configure pins. It trusts a list of pin numbers without checking if they are valid, so a malicious program can make the kernel read memory at almost any address. By observing whether the kernel returns an error or not, the attacker can learn where important kernel data structures are located.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.