Hacking the PS4, part 3: Kernel exploitation
The PS4 kernel was vulnerable to the BadIRET flaw, where an iret fault causes an extra swapgs and lets userland control the GS base. An attacker with userland code execution could corrupt the page fault handler in the IDT and run arbitrary code in kernel mode to escalate privileges.
cturt.github.io
Published on cturt.github.io
Contact About Articles Home
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 an extra swapgs performed when iret raises a #SS exception, leaving the kernel using a userland-controlled GS base.
Impact
An attacker with userland code execution could gain kernel code execution and escalate to root, escaping the jail and sandbox, though the bug was already patched in later firmware.
What the attacker needed
Userland code execution on the console; firmware 1.76 or similar vulnerable build
How it was found
- Set the userland GS base with sysarch.
- Trigger the vulnerable iret path so the extra swapgs occurs.
- Use the critical_enter write to zero the upper bytes of the page fault handler pointer in the IDT.
- Map and write the payload at the resulting userland address.
- Trigger a page fault so the hijacked handler runs the payload in kernel mode.
- Restore the IDT entry and return to userland.
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.
The kernel is the core of the operating system that controls everything. A small mistake in how it returns from handling an interrupt let a user program trick the kernel into using memory the user controls, so the attacker could run their own code with full system rights.
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.