Microsoft Azure Sphere mqueue inode initialization kernel code execution vulnerability
The mqueue inode allocation in Azure Sphere's kernel uses kmalloc without initializing the inode's list head, leaving it uninitialized. An attacker can poison the heap to control the uninitialized list pointer, leading to kernel code execution when the IPC namespace is destroyed.
Originally disclosed on Cisco Talos
A code execution vulnerability exists in the mqueue inode initialization functionality of Microsoft Azure Sphere 21.01. A specially crafted set of syscalls can lead to uninitialized kernel read, which in turn leads to code execution in kernel.
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 mqueue inode allocation uses kmalloc without calling inode_init_once, leaving the i_lru list head uninitialized.
Impact
An attacker could achieve kernel code execution, potentially compromising the entire device.
What the attacker needed
Ability to create user and IPC namespaces; ability to perform kernel heap spray
The fix
The fix is to call inode_init_once after kmalloc in mqueue_alloc_inode.
How it was found
- Create a new user namespace and a new IPC namespace using unshare.
- Exit the namespace, causing the IPC namespace to be destroyed.
- During destruction, the mqueue filesystem is unmounted and the inode is freed.
- The uninitialized i_lru list is accessed, leading to a crash or code execution.
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.
In this system, when a message queue is created, a small data structure (an inode) is allocated but not fully set up. One of its fields, a list pointer, is left with whatever garbage was in memory. An attacker can arrange for that garbage to be a value they control, and when the system later tries to use that list, it can crash or run the attacker's code with high privileges.
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.