targeted ASM.JS JIT-Spray allows bypassing ASLR and DEP
The mitigations against a previous ASM.JS JIT-spray bug can be bypassed, allowing an attacker to fully bypass ASLR and DEP in 32-bit Firefox on Windows. An attacker can jump directly to controlled machine code without memory disclosures or code reuse when exploiting a memory corruption vulnerability.
- Fixed in 7 days
- Paid in 36 days
- Disclosed after 7 days
Created attachment 8831573
ASM.JS JIT-Spray (Nop-Sled) against 51.0.1 and Nightly
Dear Mozilla Team,
The mitigations made against bug 1325200 can be circumvented, and hence, ASM.JS
JIT-Spray in combination with heap spray still allows to fully bypass ASLR and
DEP in 32-bit Firefox on Windows. An attacker can directly jump to his controlled
machine code without resorting to memory-disclosures/info-leaks and code reuse,
when exploiting a memory corruption vulnerability.
As stated in comment #52 of bug 1325200, the attacker first occupies many memory
regions to decrease the entropy of possible 64KB aligned base addresses and then
forces the creation of max. allowed ASM.JS code regions. As shown in the PoC,
his controlled machine code lands at predictable addresses. (Can you reproduce?)
I think the best mitigations are 1) random nop insertion and 2) constant
blinding of four-byte constants:
1) Inserting different-sized nop-like instructions (such as "lea esp, [esp]" and
"nop dword [REG32 + OFFSET]") at random locations into the stream of machine code
instructions decreases the possiblilty to hit a sprayed nop sled. Therefore, each
JIT module should have different random nops. Even if the attacker hits a nop
sled, the instruction stream may "re-synchronize" and his payload becomes
unusable.
2) If four-byte constants are blinded only two(/one)-byte constants can be used to
hide attacker-controlled machine instructions. However, in combination with 1) I
doubt that an attacker can do anything meaningful with
that.
Of course both mitigations may have an unacceptable performance overhead :/.
Still, I hope this helps.
If you need more information, please let me know.
Best,
Rh0
P.S.:
If requested I can provide a PoC with more code execution (.e.g.:
WinExec("cmd")) soon.
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
Likely the JIT compiler generates predictable code layouts and does not randomise instruction sequences, allowing sprayed code to land at known addresses.
Impact
An attacker could bypass ASLR and DEP to execute arbitrary code when combined with a memory corruption vulnerability, without needing information leaks.
What the attacker needed
32-bit Firefox on Windows; memory corruption vulnerability; attacker can run JavaScript
The fix
The report suggests random nop insertion and constant blinding of four-byte constants as mitigations, but does not state they were implemented.
How it was found
- Occupy many memory regions to decrease entropy of possible 64KB aligned base addresses.
- Force the creation of maximum allowed ASM.JS code regions.
- The controlled machine code lands at predictable addresses.
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.
ASLR and DEP are security features that make it harder for attackers to run their own code after finding a memory bug. This report shows that a technique called JIT-spraying, which uses the browser's own code generator to place attacker-controlled instructions at predictable addresses, can still defeat these protections in 32-bit Firefox on Windows.
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.