Vulnerabilities: Difference between revisions
CelesteBlue (talk | contribs) No edit summary |
CelesteBlue (talk | contribs) No edit summary |
||
Line 31: | Line 31: | ||
== WebKit/Userland Exploits == | == WebKit/Userland Exploits == | ||
=== FW ?.??-9.00 - WebCore::CSSFontFaceSet::removeFromFacesLookupTable() UaF === | |||
==== Credits ==== | |||
* Maddie Stone, Google Project Zero for sharing publicly a write-up describing this vulnerability (2021-10-13) | |||
* PS Test discord server community for testing PoCs of many WebKit vulnerabilities on their PS4s (2021-10-13) | |||
==== Analysis ==== | |||
* [https://github.com/WebKit/WebKit/commit/d5dbfd02054e9f904b27224a598ca1bb8ded5f87 WebKit bug-introducing commit - r256659 (2016-02-22)] | |||
* [https://github.com/WebKit/WebKit/commit/fbf37d27e313d8d0a150a74cc8fab956eb7f3c59 WebKit fix commit (2021-09-09)] | |||
* [https://github.com/WebKit/WebKit/blob/74bd0da94fa1d31a115bc4ee0e3927d8b2ea571e/Source/WebCore/css/CSSFontFaceSet.cpp#L223 Vulnerable code] | |||
* [https://googleprojectzero.github.io/0days-in-the-wild/0day-RCAs/2021/CVE-2021-30858.html Write-up and PoC by Maddie Stone, Google Project Zero (2021-10-13)] | |||
* [https://wololo.net/2021/10/14/use-after-free-webkit-vulnerability-impacts-ps4-possibly-up-to-firmware-9-00-included/ Vulnerability description by Wololo] | |||
* Warning: this vulnerability is not CVE-2021-30858 but was guessed to be by Maddie Stone, Google Project Zero. See [https://github.com/googleprojectzero/0days-in-the-wild/commit/65fcdf0473ada4e80dc967662ea8f3f3ce4ea81e#diff-1a428c43cedcf140e5bd6f92e4527f169c3c717780e1586f2fab589e4f467b52 write-up edit commit]. | |||
==== Bug description ==== | |||
Description in WebKit fix commit by Darin Adler/Russell Epstein: | |||
After r256659, asking for a failed CSSFontFace's families() returns nullopt. It's possible to add a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed and don't update our internal data structures, because there's no need to - we can't do anything useful with a failed font. If you _then_ try to remove the font from the CSSFontFace, we don't call families(), but instead just pull out the raw m_families member, and look in our internal data structures for it, but we don't find it, because it was never added. | |||
Description in Maddie Stone's write-up: | |||
The vulnerability is a use-after-free due to an unchecked end() iterator. There was an assert statement: ASSERT(iterator != m_facesLookupTable.end());, but ASSERTs don't do anything in release builds. Therefore, even if iterator == m_facesLookupTable.end() in the release build, nothing would happen and iterator would still be used. In FontFaceSet a FontFace is not added to the faces lookup table in addToFacesLookupTable if the font has already been deemed to be invalid. However, removeFromFacesLookupTable would still attempt to remove the font, leading to the use-after-free. The patch changes the ASSERT to an if clause. The function will return if iterator == m_facesLookupTable.end(), since the item it wishes to remove is not found in the table. | |||
==== Exploit Implementation ==== | |||
Not yet. | |||
==== Patched ==== | |||
'''Not yet'''. Tested working on FWs 8.00-9.00. | |||
=== FW ?.??-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW === | === FW ?.??-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW === |
Revision as of 22:38, 24 October 2021
Hardware Exploits
PCIe man-in-the-middle attack
- First done on 1.01 by failoverflow on PS4 launch !
- Detailed at 33c3: 33c3 slides by Marcan
- Permits kernel and userland dumping
Syscon glitching
It is possible to glitch the Syscon debug interface to allow access and dump keys. It was originally done by an anonymous member of fail0verflow.
Aeolia and Belize (Southbridge) SCA/DPA
Side Channel Analysis (SCA) with Differential Power Analysis (DPA) on Aeolia and Belize (PS4 Southbridge revisions) has been shown to be able to recover key material. Since Sony never used private/public key pairs, it is possible to exploit this and gain complete control over the Southbridge. You can attack the main FreeBSD kernel from here.
Nearly same methods are working on recent PS4 Pro motherboard NVB-003 that has Belize Southbridge (CXD90046GG).
Contrarly to Aeolia, Belize has ROM readout protection and clears stack which makes it more secure.
Old notes:
This is a hack to gain unsigned code execution on the Southbridge for all motherboard/console revisions. You might be able to glitch the EMC bootrom in order to bypass further signature checks and break the chain of trust. This hack might involve slowing down the Syscon clock. Timing the glitch based on SPI read accesses then either doing a power glitch or clock glitch to skip signature check. If the glitch fails, then we simply reset. This can be done with a very cheap CPLD/FPGA. Most Xbox 360 glitching modchips used a Xilinx Coolrunner because it is cheap and easy to use (board can cost as low as $5).
Related:
- fail0verflow's writeup
- [fail0verflow's tweet]
- Playstation 4 Rest Mode DEMO REcon Brussels 2018 by Volodymyr Pikhur
- Slides of REcon Brussels 2018 by Volodymyr Pikhur
- jogolden's writeup
WebKit/Userland Exploits
FW ?.??-9.00 - WebCore::CSSFontFaceSet::removeFromFacesLookupTable() UaF
Credits
- Maddie Stone, Google Project Zero for sharing publicly a write-up describing this vulnerability (2021-10-13)
- PS Test discord server community for testing PoCs of many WebKit vulnerabilities on their PS4s (2021-10-13)
Analysis
- WebKit bug-introducing commit - r256659 (2016-02-22)
- WebKit fix commit (2021-09-09)
- Vulnerable code
- Write-up and PoC by Maddie Stone, Google Project Zero (2021-10-13)
- Vulnerability description by Wololo
- Warning: this vulnerability is not CVE-2021-30858 but was guessed to be by Maddie Stone, Google Project Zero. See write-up edit commit.
Bug description
Description in WebKit fix commit by Darin Adler/Russell Epstein:
After r256659, asking for a failed CSSFontFace's families() returns nullopt. It's possible to add a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed and don't update our internal data structures, because there's no need to - we can't do anything useful with a failed font. If you _then_ try to remove the font from the CSSFontFace, we don't call families(), but instead just pull out the raw m_families member, and look in our internal data structures for it, but we don't find it, because it was never added.
Description in Maddie Stone's write-up:
The vulnerability is a use-after-free due to an unchecked end() iterator. There was an assert statement: ASSERT(iterator != m_facesLookupTable.end());, but ASSERTs don't do anything in release builds. Therefore, even if iterator == m_facesLookupTable.end() in the release build, nothing would happen and iterator would still be used. In FontFaceSet a FontFace is not added to the faces lookup table in addToFacesLookupTable if the font has already been deemed to be invalid. However, removeFromFacesLookupTable would still attempt to remove the font, leading to the use-after-free. The patch changes the ASSERT to an if clause. The function will return if iterator == m_facesLookupTable.end(), since the item it wishes to remove is not found in the table.
Exploit Implementation
Not yet.
Patched
Not yet. Tested working on FWs 8.00-9.00.
FW ?.??-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW
Credits
- Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) who are Security Researcher at Synacktiv for fuzzing WebKit, finding a way to exploit the vulnerability on PS4, presenting it on Black Hat Europe 2020 ([1]) and sharing the code (2020-12-10)
- sleirsgoevy for porting (although with low success rate) to 7.00-7.02
Analysis
- WebKit bad fix commit (2019-05-28)
- WebKit good fix commit (2020-09-11)
- Write-up by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)
- Presentation slides by by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)
Bug description
- The method buildBubbleTree makes a call to update the layout during which all user registered JS handlers are executed. If the ValidationMessage is destroyed in a JS callback, this could lead to a Use-After-Free situation when we get back to buildBubbleTree code.
- ValidationMessage::buildBubbleTree is doing layout which can run a script detaching the owner form element, and this ValidationMessage object can be destroyed.
After private disclose by Synacktiv ethical hackers, the vulnerability was fixed in Webkit on September 11st 2020. SIE updated to the patched WebKit with firmware 8.00 released on October 14st 2020.
Exploit Implementation
- Initial 6.xx implementation by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-11-12
- 7.02 implementation with code execution by sleirsgoevy (2020-12-15)
- 6.72-7.02 Kernel exploit using this webkit exploit by sleirsgoevy (2020-12-16)
- 7.00-7.02 Kernel exploit using this webkit exploit by ChendoChap (2020-12-16)
Patched
Yes in 8.00 FW. Tested working on FWs 6.72-7.55.
FW 6.00-6.72 - bad_hoist exploit (CVE-2018-4386) leading to arbirary RW
Credits
- Lokihardt (from Google Project Zer0) for the exploit PoC (Sep 13, 2018)
- Fire30 for turning the vulnerability into exploit for PS4 (Dec 30, 2019)
- sleirsgoevy for attempting to stabilize the PS4 exploit with a new implementation (Feb 23, 2020)
Analysis
- https://bugs.chromium.org/p/project-zero/issues/detail?id=1665
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-4386
- https://packetstormsecurity.com/files/155871/Sony-Playstation-4-Webkit-Code-Execution.html
- https://twitter.com/Fire30_/status/1211775229116211200
Bug Description
WebKit: JSC: BytecodeGenerator::hoistSloppyModeFunctionIfNecessary doesn't invalidate the ForInContext object.
It is possible to craft Javascript in such a way that allows for an object to be passed as the property variable directly as a string to the op_get_direct_pname handler without being properly validated.
This is a Type Confusion exploit.
Exploit Implementation
Patched
Yes in 7.00 FW
FW 6.00-6.20 - JSArray::shiftCountWithArrayStorage() OOB RW (CVE-2018-4441) leading to arbitrary RW
Credits
- Lokihardt (from Google Project Zer0) for the exploit PoC (Oct 3, 2018)
- Specter for the rewriting for PS4 (Mar 8, 2019)
- St4rk for helping Specter
Analysis
- Bug report by Lokihardt (Oct 3, 2018)
- WebKit fix commit (Oct 15, 2018)
- Announce of incoming write-up by rkmylo and buherator/stratan/@5tratan, Meligra Team (Feb 25, 2019)
- Write-up by Nytro, Meligra Team (Feb 27, 2019)
Bug Description
We would take the fast path for JSArray::shiftCountWithArrayStorage when the array hasHoles(). However, the code for this was wrong. It would incorrectly update ArrayStorage::m_numValuesInVector.
Exploit Implementation
Patched
Yes in 6.50 FW
FW 6.00-?6.20? - JSC::arrayProtoPrivateFuncConcatMemcpy() Information Leak (CVE-2018-4358) ?leading to ASLR defeat?
Credits
- bkth, niklasb and saelo (from phoenhex Team) for the exploit PoC in Safari (Sep 26, 2018)
- Vultra for discovering that the exploit worked since FW 6.00 (Dec 10, 2018)
Analysis
- https://github.com/WebKit/webkit/commit/b68b373dcbfbc68682ceeca8292c5c0051472071
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-4358
- https://phoenhex.re/2018-09-26/safari-array-concat
Bug Description
Exploit Implementation
Patched
Yes in 6.50/1 FW
Tested
Works on 6.00-6.20. Not working on PS4 FWs <= 5.56 because JSC (JavaScriptCore) was too old.
FW 4.50-5.56 - JSGlobalObject::haveABadTime() Type Confusion (CVE-2017-7005) leading to arbitrary RW
Credits
- Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 20, 2017)
- ALEXZZZ9 for the first PS4 implementation (on 5.01), and at same time for burning the exploit (Feb 20, 2018)
- qwertyoruiop for rewriting and porting to 5.05 and 5.50
Analysis
Bug Description
When JSGlobalObject::haveABadTime() is called with arrays of a different JSGlobalObject type, type confusion can occur, leading to memory corruption.
Exploit Implementation
Patched
Yes in 6.00 FW
FW 5.05 - Document::adoptNode() UaF leading to crash
Credits
- Lokihardt (from Google Project Zer0) for the exploit PoC (Jan 23, 2017)
- CelesteBlue for testing on PS4 and PSVita
Analysis
- exploit report by Lokihardt (Jan 23, 2017)
- mitre report
- exploitDB report
- related bug (Oct 8, 2015)
- Test on PSVita FW 3.60 by CelesteBlue (May 9, 2020)
- Test on PS4 FW 5.05 by CelesteBlue (Aug 20, 2020)
Bug Description
Exploit Implementation
Patched
Maybe in ?6.00? FW.
FW ?-5.05-? - WebCore::HTMLFrameElementBase::marginHeight() Heap UaF (CVE-2016-1859) leading to crash
PoC crashes the webbrowser.
FW 4.50-5.01 - Element::setAttributeNodeNS() UaF leading to arbitrary RW
Credits
- Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 15, 2017)
- qwertyoruiop for the PS4 exploit (October 2017)
- Specter for the writeup (May 27, 2018)
Analysis
- exploit report by Lokihardt (Mar 15, 2017)
- First test on PS4 by WildCard (Oct 16, 2017)
- Specter's setAttributeNodeNS Exploit Writeup
Bug Description
By forcing setAttributeInternal() to call setAttributeNodeNS() twice, an attribute node reference will be added twice to the list. When one is free()'d, the second attribute still contains a duplicate stale reference, leading to a use-after-free (UAF) scenario.
Exploit Implementation
PS4 5.05 WebKit + Kernel Exploit
Patched
Yes in 5.03 FW.
FW 3.15-4.07 - Stack Uninitialized Read UaF leading to arbitrary RW
Credits
- qwertyoruiop for the exploit
- Specter for the writeup
Analysis
Bug Description
Via a specially crafted valueOf() function of an arguments.length() function, non-zero indexes of the stack-allocated array are not initialized, leading to a stack uninitialized read. This can be abused to store a reference that can later be re-obtained post-GC (garbage collection) yielding a use-after-free() (UAF) situation.
Exploit Implementation
Patched
Yes in 4.50 FW
Tested
Works on 3.15-4.07. Not working on <=3.11.
FW 3.15-3.70 - JSArray::sortCompactedVector() Heap UaF leading to arbitrary RW
Credits
- xyz for the original exploit on PSVita (HENkaku)
- Fire30 for porting to PS4
- Specter for improved PS4 playground
Analysis
Bug Description
When attempting to update a vector via sortCompactedVector() - data is written based on a pointer, though the pointer isn't re-updated nor nulled. When this memory in free()'d, the reference is maintained and thus memory corruption can occur.
Exploit Implementation
- PSVita 3.60 webkit exploit by xyz
- PS4 playground 3.15-3.70 by Fire30
- Improved PS4 playground 3.15-3.70 by Specter
Patched
Yes in 4.0?0? FW
Tested
Works on 3.15-3.70. Not working on <= 3.11. Maybe working on 4.00.
FW <= 3.50 - WebCore::TimerBase::heapPopMin() Heap UaF leading to crash
Analysis
- WebKit fix commit
- Summary of Critical and Exploitable iOS Vulnerabilities in 2016 by Min (Spark) Zheng, Cererdlong, Eakerqiu @ Team OverSky
Bug Description
"As of firmware version 3.55 a patch has been included to prevent a use-after-free segmentation fault from being exploited. This could have led to a ROP chain and code execution. It would have been cool if someone would have done some real research on it..." qwertyoruiop
Exploit Implementation
- Article about qwertyoruiop's tests (20-05-2016)
- Article about initial PoC for PS4 (21-05-2016)
- Initial PoC for PS4 (21-05-2016)
- iOS 9.3.2 WebKit RCE via heapPopMin (07-2016)
- qwertyoruiop's tweet (22-07-2016)
- mirror of iOS 9.3.2 WebKit RCE via heapPopMin
Patched
Yes in 3.55 FW
Tested
Works on 3.15, 3.50 FW. Maybe working on 3.51 FW.
FW <= 2.03 - WebCore::CSSSelector Heap Overflow (CVE-2014-1303) leading to arbitrary RW
Credits
- KeenTeam for finding and documenting the bug
- Liang Chen from KeenTeam for the writeups
- xyz for porting to PSVita FWs 3.30-3.36
- Fire30 for porting to PS4
- dreadlyei (unknown person, credited by Fire30)
Analysis
- BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' slides
- BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' PDF
- Attacking WebKit Applications by exploiting memory corruption bugs by Liang Chen
Bug Description
By forcing addRule() to be called on a CSS Selector via window.getMatchedCSSRules(), a 1-bit OOB write can be achieved and leveraged to corrupt heap memory.
Exploit Implementation
- ROP PoC for PS4 FW 2.03 by Fire30
- wololo article
- WebKit exploit for 3.30-3.36 FW PSVita by xyz: used in vitasploit
- PoC for Linux by RKX1209
Patched
Yes in 2.50 FW
Tested
- Working on 2.00-2.03 FW. Might work on 2.04 (99% sure as 2.04 PUP is about same size as 2.03 PUP).
- Working on AppleWebKit/537.73
- Maybe not working on FW < 2.00.
FW <= 2.03-? - WebCore::ImageInputType::attach Heap UaF (CVE-2013-2857) leading to ROP execution
Credits
- Chromium bugs reporters
- JumpCallPop, jam1garner, hedgeberg for inital exploit on Wii U
- yellows8 for ROP on Wii U
- orboditilt for increasing stability on Wii U
- zoogie for porting Wii U exploit to New3DS
- CelesteBlue for testing on PS4 FW 2.03
Analysis
Bug Description
Use-after-free with input type image. Error event was fired synchronously blowing away the input element from underneath.
Exploiting this vulnerability on PS4 is not good because:
- This vulnerability does not provide arbitrary RW without code execution, hence ROP chain (at least to stack pivot to JiT code) must be made with a memory dump or decrypted modules for this FW gotten using another vulnerability.
- There is userland ASLR since about FW 1.70 so ROP chain gadgets must be relocated at runtime. This means another vulnerability allowing userland arbitrary read is needed.
- As usually an arbitrary read vulnerability also gives arbitrary write, and as arbitrary RW leads to userland code execution (by hijacking JS pointers in virtual table), this UaF is not needed at all.
- Even if we get ROP chain to work on PS4 with this UaF vulnerability, there is no evidence that a return to JavaScript from ROP chain is doable, making this exploit less convenient than arbitrary RW exploits method of getting code execution then returning to userland by restoring vtable.
Exploit Implementation
- Initial Wii U implementation
- Wii U stabler implementation (last update May 22, 2018)
- Wii U tabler implementation (last update Jan 13, 2019)
- Wii U stabler implementation by Hiperhazz (last update May 26, 2020)
- New3DS implementation by zoogie (last update Aug 9, 2020)
Patched
Yes in ? FW
Tested
- Working on 2.03 FW. Might work on 2.04 (99% sure as 2.04 PUP is about same size as 2.03 PUP).
FW <= 1.76 - JSArray::sort() Heap Overflow (CVE-2012-3748, PSA 2013-0903-1) leading to arbitrary RW
Credits
- Vitaliy Toropov for the exploit on Mac OS X Safari (September 4, 2013)
- nas and Proxima for the first PS4 POC on 1.76 PS4 (Oct. 23, 2014)
- sony for patching the exploit in FW 2.00 (Oct 27, 2014)
- CTurt for the rewriting (PS4 1.76 PlayGround) and implementation with his 1.76 kexploit (December 6, 2015) [4]
Analysis
Bug Description
By forcing the compare function to reduce the size of the array, trailing items will be written out of bounds (OOB write), leading to heap memory corruption.
Exploit Implementation
- first POC for 1.76 PS4 by nas and Proxima
- mirror
- live test
- livetest2
- ROP2
- PS4 playground 1.76 by CTurt
- PSVita 2.00-3.20 webkit exploit
Patched
Yes in 2.00 FW
Tested
- Working on 1.00-1.76 FW, AppleWebKit/531.3-536.26
- Might work on FW 0.930.020.
Userland securities
Userland ASLR
- Very old firmwares (<= 1.05) don't have ASLR enabled, but it was introduced sometime before firmware 1.70. "Address Space Layout Randomization" (ASLR) is a security technique which causes the base addresses of modules to be different every time you start the PS4.
- To defeat userland ASLR on FWs >=1.70, we can use the module imports table to find other modules address once we know SceWebkit2 address.
Module imports table cleaned before execution
- Between 1.76 and 4.05, Sony did that to prevent webkit exploiters from defeating userland ASLR easily.
- Now we have to dump entire userland sandboxed memory, and by studying it we can defeat ASLR:
1. Chose a function (ex: __stack_chk_fail) imported from LibKernel by SceWebkit2 2. Read pointer contained at the address where the call is done 3. Substract to this pointer the offset of the function (ex: __stack_chk_fail) in LibKernel module 4. This result is LibKernel base address. This method works for any imported module.
DEP / NX
- "Data Execution Prevention" / "No eXecute" is enabled on all firmwares. It prevents allocating memory as both RW and RX at same time (RWX) so preventing us from writing shellcode to userland memory then executing it.
- 2 ways to bypass this security: JiT vulnerability (FW <= 1.76) or ROP (all FWs).
JiT removed from webbrowser
- On FW <= 1.76, you could map RWX memory from ROP by abusing the JiT functionality and the sys_jitshm_create and sys_jitshm_alias system calls. This however was fixed after 1.76, as WebKit has been split into two processes. One handles javascript compilation and the other handles other web page elements like image rendering and DOM. The second process will request JiT memory upon hitting JavaScript via IPC (Inter-Process Communication). Since we no longer have access to the process responsible for JiT, we can no longer (at least currently), map RWX memory for proper code execution unless the kernel is patched.
- Workaround is to use ROP.
Syscalls removed
Syscall 0 disabled i.e Error Kernel: The application directly issues a syscall instruction (24)
- Between 2.00 and 2.57, SCE has removed system call 0, so we can no longer call any syscall we want by specifying the call number in the rax register.
- Doing so now crashes the app and gives error CE-34878-0, SCE_KERNEL_ABORT_REASON_SYSTEM_ILLEGAL_FUNCTION_CALL, with the message "Kernel: The application directly issues a syscall instruction (24)".
- We now have to use wrappers provided to us from the libkernel / libkernel_web / libkernel_sys modules to access system calls.
bpf_write function stripped out of the kernel
- On 4.70, bpfwrite() was stripped out of the kernel entirely to patch kernel vulnerability exploited in 4.55 kexploit.
bpf_open function blocked for unprivileged processes
- On 5.50, opening BPF has been blocked for unprivileged processes such as WebKit and other apps/games. It's still present in the sandbox, however attempting to open it will fail and yield EPERM. This aims blocking BPF kernel exploits especially qwertyoruiop's BPF double free UAF.
bpf_ioctl function blocked or removed
- Moreover, on FW 5.50+, opening BPF is still possible in less sandboxed apps like test/devkits fselfs. But this is useless because ioctl doesn't work.
Device access blocked/removed from webbrowser
- Around 6.50-6.70, device access got blocked or removed. Now you can no longer access devices from webbrowser
Kernel Exploits
FW <= 7.55 - IP6_EXTHDR_CHECK Double Free (CVE-2020-9892)
Credits
- 2019-09-15 tuexen for finding the FreeBSD vulnerability [5]
- 2020-07-24 TheFloW for finding CVE-2020-9892 in XNU
- 2020-07-26 TheFloW for porting CVE-2020-9892 to PS4
- 2020-07-27 TheFloW for publishing publicly a PoC leading to code execution on XNU. [6]
- 2021-01-12 TheFloW for disclosing publicly the PS4 vulnerability. [7]
- 2021-01-20 sleirsgoevy for making a first working exploit for FreeBSD 9 [8]
- 2021-03-03 sleirsgoevy for making a second working exploit for FreeBSD 9 [9]
- 2021-03-12 sleirsgoevy for making the first public usable exploit for PS4 7.50-7.55 (https://twitter.com/sleirsgoevy/status/1370481212813348865)
Analysis
- Fix handling of Hop-by-Hop options over the loopback interface commits review (2019-09-15 to 2020-05-07)
- Apple iOS 13.6 and iPadOS 13.6 Security Update (2020-07-24)
- Apple macOS Catalina 10.15.6 Security Update (2020-07-24)
- TheFloW's report of the exploit with undisclosed PS4 and FreeBSD 9 PoCs
- TheFloW's writeup and PoC for XNU (2020-07-26)
- Vulnerability adviced by TheFloW for exploitation (2018-02-05)
Bug Description
Memory corruption can be achieved by sending fragmented IPv6 packets to loopback interface due to poor and inconsistent use of IP6_EXTHDR_CHECK.
The macro IP6_EXTHDR_CHECK can free the mbuf if the packet is sent to loopback interface. This fact is not considered in dest6_input(), frag6_input() and more. For example in dest6_input(), the double pointer is not updated.
Hence, when parsing next headers, the mbuf can be free'd once again, leading to a double free which behaves like a use-after-free when we allocate mbuf's again.
Normally, this path would not be triggerable, because sending to loopback interface requires SOCK_RAW root privileges. However, for some reason on the PS4 SOCK_RAW sockets can be opened in Webkit process! Moreover, CelesteBlue confirmed that SOCK_RAW sockets can also be opened in PS4 Kit fSELF.
According to TheFloW, the reliability of the FreeBSD 9 PoC is very high, around 80%, whereas the PS4 PoC's is not very high, he guesses around 20%.
Exploit Implementation
- TheFloW's writeup and PoC for XNU (2020-07-27)
- sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)
- Demonstration video of sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)
- Specter's kernel panic PoC for PS4 Web browser (2021-01-15)
- CelesteBlue's kernel panic PoC for PS4 Kit fSELF (2021-01-15)
- WiP exploit code by Specter and tihmstar (2021-02-24)
- sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)
- Demonstration video of sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)
- sleirsgoevy's implementation for PS4 7.5x (2021-03-12)
Patched
Yes in 8.00 FW
FW <= 7.02 - IPV6_2292PKTOPTIONS UaF (yielding arbitrary kernel R/W)
Credits
- 2018-08-18 up to 2020-07-06 Fire30 for finding and keeping the vulnerability as a private 0day for it not to be patched by SIE. [10]
- 2020-07-06 TheFloW for publishing publicly a PoC leading to code execution on FreeBSD. [11]
- sleirsgoevy and ChendoChap for porting the PoC to PS4 and chaining it with the 6.72 and 7.02 webkit exploits.
Analysis
Bug Description
Due to missing locks in option IPV6_2292PKTOPTIONS of setsockopt, it is possible to race and free the struct ip6_pktopts buffer, while it is being handled by ip6_setpktopt. This structure contains pointers (ip6po_pktinfo) that can be hijacked to obtain arbitrary kernel R/W primitives. As a consequence, it is easy to have kernel code execution. This vulnerability is reachable from WebKit sandbox and is available in the latest FW, that is 7.02.
Exploit Implementation
- TheFloW's PoC for FreeBSD 9 and 12
- PS4 6.72-7.02 WebKit + Kernel Exploit implementation by sleirsgoevy
- PS4 5.05-7.02 WebKit + Kernel Exploit implementation by ChendoChap
Patched
Yes in 7.50 FW
FW <= 5.07 - BPF Race Condition (Yielding Double Free())
Analysis
Specter's Writeup of the 5.05 BPF Race Condition
Bug Description
Due to improper locking, two threads can enter the BPF SETWF ioctl command handler. While the bug is similar to that of 4.55, the method of attack is slightly different. Since write() was removed for BPF in 4.70, instead of triggering a use-after-free with write() - SETWF is ran in parallel via threading. Eventually, both calls will copy the same pointer to the stack, leading to both threads free()'ing the same pointer, poisoning the freelist. This can later be leveraged via heap spraying to corrupt heap memory to obtain arbitrary code execution in supervisor mode (ring0).
Exploit Implementation
Patched
Yes in 5.50 FW
FW <= 4.55 - BPF Race Condition (Yielding UaF)
Analysis
Specter's Writeup of the 4.55 BPF Race Condition
Bug Description
Due to improper locking, two threads can enter the BPF ioctl command handlers for setting a new write filter (SETWF) and setting a filter (SETIF). Both threads will reference the same pointer. In specially crafted situations, one thread could free() this pointer while the other thread executes it as a filter post-validation. This allows an unprivileged user to obtain an out-of-bounds (OOB) write on the stack, leading to arbitrary code execution in supervisor mode (ring0).
Exploit Implementation
PS4 4.55 WebKit + Kernel Exploit
PS4 4.55 WebKit + Kernel Exploit Source
Patched
Yes in 4.70 FW
FW <= 6.00 ?6.02? - sys_getcontext Information Leak (kASLR defeat) (CVE-2018-17155)
Analysis
- https://www.cvedetails.com/cve/CVE-2018-17155/
- coming soon by CelesteBlue
Bug Description
System call 421 or sys_getcontext() initializes the structure pointed at by ucp to the currently active context. The vulnerability is, some areas of memory copied out are not initialized, and thus the function leaks memory at certain spots. This vector was patched in 6.20, as now before the buffer is used it is initialized to 0 via bzero().
Exploit Implementation
- QuickHEN by CelesteBlue (v2 not released yet)
- KitHEN by CelesteBlue (not released yet)
Patched
Yes somewhere between 6.00 and 6.20 FW
FW <= 4.07 - sys_thr_get_ucontext Information Leak (kASLR defeat)
Analysis
Bug Description
System call 634 or sys_thr_get_ucontext() allows to obtain information on a given thread. The vulnerability is, some areas of memory copied out are not initialized, and thus the function leaks memory at certain spots. This vector was patched in 4.50, as now before the buffer is used it is initialized to 0 via bzero().
Exploit Implementation
PS4 4.05 WebKit + Kernel Exploit
Patched
Yes in 4.50 FW
FW <= 4.05 - NamedObj Type Confusion (Yielding UaF)
Credits
- Chaitlin Tech for having been the first to show they had pwned PS4 FW 4.01 at Geekpwn convention. (2016-10-24)
official video, tweet 1, tweet 2, tweet 3 (2016-10-25)
- fail0verflow for the first writeup (2017-10-19)
- Specter for rewriting the exploit using a different object, and releasing it publicly (2017-12-27)
Analysis
- fail0verflow's writeup on the 1.01-4.05 namedobj kernel exploit (2017-10-19)
- Specter's first writeup (2017-10-20)
- Specter's writeup on his 4.05 implementation (2017-12-28)
Bug Description
Type confusion in the namedobj system once exploited can lead to an arbitrary free() allowing an attacker to craft a use-after-free() (UAF) situation to corrupt kernel memory. This can be leveraged to eventually obtain an arbitrary code execution primitive in supervisor mode (ring0).
Exploit Implementation
PS4 4.05 WebKit + Kernel Exploit
Patched
Yes in 4.06 FW
Tested
Works on FWs 4.00-4.05. On <=3.70 FW we haven't found a way to leak the target object, but it might be doable as F0F did it on 1.01.
FW <= 1.76 - dlclose Kernel Heap Overflow
Credits
- Discovered by CTurt.
- Privately implemented thanks to qwertyoruiop.
- CTurt published a writeup.
- The exploit was publicly implemented by kR105 and on another side by Zer0xFF and Bigboss (psxdev).
Analysis
Bug Description
Integer overflow in the sys_dynlib_prepare_dlclose() system call can lead to a heap overflow causing memory corruption, allowing an attacker to obtain code execution in supervisor mode (ring0).
Exploit Implementation
Patched
Yes in 2.00 FW
FW <= 1.76 - BadIRET (CVE-2014-9322, CVE-2015-5675)
Credits
- Andy Lutomirski for CVE-2014-9322 (2014-11-22)
- Konstantin Belousov, Andrew Lutomirski for CVE-2015-5675 (2015-07-08)
- Adam Zabrocki (pi3) for asking CTurt to test CVE-2015-5675 on PS4 (2015-08-21) [12], [13]
- Volodymyr Pikhur for exploiting FreeBSD and PS4 in private (2015-09-24) [14]
- CTurt for porting the exploit from FreeBSD 9 to PS4 (2015-12-06) [15]
Analysis
- Fix commit for Linux CVE-2014-9322 by Andy Lutomirski
- NVD Bug Description for CVE-2014-9322
- 2014-9322 analysis by Rafal Wojtczuk
- CVE-2014-9322 analysis by Adam Zabrocki (pi3)
- CVE-2015-5675 PoC for FreeBSD by Konstantin Belousov, Andrew Lutomirski (2015-07-08)
- FreeBSD security advisory by Konstantin Belousov, Andrew Lutomirski (2015-08-25)
Bug Description
Faults associated with the stack segment (SS) register are not handled properly, allowing unprivileged users to trigger an IRET instruction that accesses a GS Base from userland memory, providing an attacker with a method of privilege escalation.
Exploit Implementation
- CVE-2014-9322 kernel panic PoC for Linux by Emeric Nasi (2015-03-04)
- CVE-2014-9322 exploit code for Linux by Ren Kimura (@RKX1209) (2017-07-19)
- CVE-2014-9322 exploit code for Linux by Ren Kimura (@RKX1209) (2017-07-24)
- CVE-2015-5675 PoC for FreeBSD by Konstantin Belousov, Andrew Lutomirski (2015-07-08)
Patched
Yes in 2.00 FW
FW ??? - setlogin Information Leak (CVE-2014-8476)
Warning: this has not been tested on PS4.
Credits
- Mateusz Guzik for finding the vulnerability
- Volodymyr Pikhur for advising to use this vulnerability at his Playstation 4 Rest Mode DEMO in REcon Brussels 2018
- Francisco Falcon for making a PoC on FreeBSD 8.4
Analysis
Bug Description
The setlogin function in FreeBSD 8.4 through 10.1-RC4 does not initialize the buffer used to store the login name, which allows local users to obtain sensitive information from kernel memory via a call to getlogin, which returns the entire buffer.
When setlogin(2) is called while setting up a new login session, the login name is copied into an uninitialized stack buffer, which is then copied into a buffer of the same size in the session structure. The getlogin(2) system call returns the entire buffer rather than just the portion occupied by the login name associated with the session.
An unprivileged user can access this memory by calling getlogin(2) and reading beyond the terminating NUL character of the resulting string. Up to 16 (FreeBSD 8) or 32 (FreeBSD 9 and 10) bytes of kernel memory may be leaked in this manner for each invocation of setlogin(2).
This memory may contain sensitive information, such as portions of the file cache or terminal buffers, which an attacker might leverage to obtain elevated privileges.
Exploit Implementation
Patched
?
Kernel securities
Kernel ASLR
Since 3.50 FW, ASLR (Address Space Layout Randomization) has been enabled in PS4 kernel. This means that to properly exploit the kernel to escalate privileges, an information disclosure vulnerability will most likely be needed to defeat ASLR and locate the kernel in memory.
Kernel SMAP
In 5.0x FW and above, "Supervisor Mode Access Prevention" (SMAP), a new custom mitigation was added to the PS4 kernel to prevent exploiters from pivoting the kernel stack pointer into userland memory (attempting to do so would crash the system). A new exploitation strategy is needed to run kernel ROP chains because we need to get our ROP chain into kernel memory.
To do this, qwertyoruiop decided in his 5.05 PS4 kernel exploit to go with the method he used on the Apple iPhone 7 - essentially using JOP to push a bunch of stack frames onto the kernel stack, and memcpy()'ing the chain into RSP.
Another way to bypass this mitigation has been showed by sleirsgoevy in his 6.72 PS4 kernel exploit implementation. It is to wrap the main kernel ROP with cli/sti pair, which would prevent it from being preempted. This way the thread's CPU core will not run other kernel code during kROP execution, and other cores have no way of detecting the stack pivot, so the mitigation is defeated.
Another SMAP bypass has been found by m00nbsd while working on FreeBSD 12. It is named CVE-2021-29628 and used to work on PS5 before it was disclosed and patched.
CR0.WP protection
At least since firmware 6.51 Sony instrumented all instructions that write to the CR0 register with checks for attempts to clear CR0.WP (Write Protect), which is necessary for patching the kernel. This is what it looks like in 6.51 kernel:
a1b79: 0f 22 c0 mov cr0,rax a1b7c: 48 a9 00 00 01 00 test rax,0x10000 a1b82: 75 02 jne a1b86 <-- skip the next instruction if CR0.WP is not cleared a1b84: 0f 0b ud2 <-- #UD exception, causes a kernel panic a1b86: c3 ret
Note that the check is after the write, to prevent a ROP gadget from pointing straight at the mov and skipping the verification.
Bypasses (in chronological order):
- Use an "unintended" mov to cr0 in the middle of another instruction (e.g. instruction "call $+0x220f1c" (e8 17 0f 22 00) contains an unintended "mov cr0, rax" (0f 22 00))
- Use kernel write to give your process JIT permissions, allocate JIT memory, and put entirely custom code there (avoids the problem altogether, as it is specific to ROP)
- Since the IDT is writable on FreeBSD and PS4, it is possible to overwrite an exception handler without clearing CR0.WP first. One can overwrite the handler of #UD with a gadget of their choice (a stack pivot, or a "add rsp, ... ; ret", or whatever else), and the UD2 instruction in the mitigation code will happily jump to it instead of the real handler, with CR0.WP cleared.
|