Susctl CVE-2024-54507: A particularly 'sus' sysctl in the XNU kernel
A sysctl handler in the XNU kernel read a 16-bit variable as a 32-bit integer, causing a 2-byte out-of-bounds read. An attacker could leak two bytes of kernel memory adjacent to the variable.
jprx.io
Published on jprx.io
Every time Apple releases a new version of XNU, I run a custom suite of tests under an address sanitizer to see if I can spot any regressions, or even possibly new bugs. When I was messing around with macOS 15.0, I was shocked to see a very simple command was causing the sanitizer to report an invalid load.
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 handler cast a pointer to a 16-bit integer to a 32-bit integer pointer, causing an out-of-bounds read.
Impact
An attacker could leak two bytes of kernel memory, but the exact data depends on the linker and may be padding or another variable.
What the attacker needed
Local access to the system; ability to read the sysctl (no root needed)
The fix
The fix was to cast the pointer to uint16_t instead of int when loading the value.
How it was found
- Run sysctl -a on a kernel with KASAN to trigger the invalid load.
- Read the sysctl net.inet.udp.log.remote_port_excluded to leak two bytes.
- Observe the leaked bytes correspond to memory after the variable.
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.
A sysctl is a kernel setting you can read or change from user space. The handler for one such setting mistakenly read 4 bytes from a 2-byte variable, so it grabbed 2 extra bytes of kernel memory and returned them to the user. This lets an attacker see a tiny piece of kernel memory they should not access.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.