Dissecting the CVE-2024-38106 Fix
A race condition in the Windows kernel's worker factory handling allowed a use-after-free when setting the idle timeout while the factory was being shut down. An attacker could trigger a system crash (blue screen) by racing these operations.
pixiepointsecurity.com
Published on pixiepointsecurity.com
In the security patches for August, Microsoft fixed several ntoskrnl.exe bugs, and one of them (CVE-2024-38106) being exploited in the wild. As anything ITW always require closer attention, we attempt to create a POC for it by.
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
Likely a missing lock or check allowed the worker factory object to be freed while a timer was being set on it, leading to a use-after-free.
Impact
An attacker could cause a system crash (blue screen) by triggering the race condition, leading to denial of service.
What the attacker needed
Local access to the system; ability to create worker factory objects
The fix
The fix adds a flag check to prevent setting the idle timeout after the worker factory has been shut down, and also implements proper locking for the secure context operation.
How it was found
- Create a worker factory object and obtain a handle to it.
- Repeatedly call NtSetInformationWorkerFactory with WorkerFactoryIdleTimeout to set a timer on the worker factory.
- In parallel, repeatedly call NtClose on the worker factory handle to trigger shutdown and free the object.
- The race between setting the timer and freeing the object causes a use-after-free, resulting in a system crash.
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 race condition happens when two actions occur at the same time and interfere with each other. Here, one part of the system was setting a timer on a worker factory object while another part was shutting it down and freeing it, leading to the timer being set on freed memory. This caused the system to crash.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.