Microsoft Azure Sphere mtd character device driver privilege escalation vulnerability
The mtd character device driver in Azure Sphere allows a MEMWRITE ioctl to be issued on a read-only file descriptor, bypassing file permission checks. An attacker with read access to /dev/mtd1 could write a new revision of the uid_map file, potentially assigning a higher UID to a controlled application.
Originally disclosed on Cisco Talos
An arbitrary flash write vulnerability exists in the mtd character device driver of Microsoft Azure Sphere 20.06. A specially crafted ioctl can bypass file permissions and allow writes to flash by unauthorized users.
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
The MEMWRITE ioctl handler does not check whether the file was opened for writing (FMODE_WRITE), unlike other ioctls such as MEMERASE.
Impact
An attacker with read access to the mtd1 device could modify the uid_map to assign a higher UID to a controlled application, though UID 0 is prevented by a check in application-manager.
What the attacker needed
Read access to /dev/mtd1; ability to issue ioctl calls; reboot or service crash to apply changes
How it was found
- Obtain read access to the mtd1 character device (e.g., via a previous vulnerability).
- Issue a MEMWRITE ioctl on the read-only file descriptor to write a new revision of the uid_map file in an erased block.
- Reboot or cause a service crash to make the system read the modified uid_map.
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 device file in Linux can be opened for reading or writing. Normally, writing requires the file to be opened for writing, but here a special command (ioctl) called MEMWRITE skips that check. So someone who can only read the device can still write to the flash memory, which could let them change important system files.
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.