Vulnerabilities: Difference between revisions

From PS4 Developer wiki
Jump to navigation Jump to search
No edit summary
 
(27 intermediate revisions by 4 users not shown)
Line 3: Line 3:
=== PS1 games savedata exploits ===
=== PS1 games savedata exploits ===


See [https://www.psdevwiki.com/ps1/Vulnerabilities PS1 savedata exploits on PS1 Dev Wiki].
See [[PS1 Emulation]] for a list of candidate games.


Official PS Classic games (warning: some may be remastered, to check) on PS4/PS5 available on PS Store:
See [https://www.psdevwiki.com/ps1/Vulnerabilities PS1 Dev Wiki] for a list of PS1 savedata exploits.
* Ape Escape - First-time NA re-release on PS4/PS5
* Cool Boarders (2000)
* Hot Shots Golf - First-time NA re-release on PS4/PS5
* I.Q. Intelligence Qube - First-time NA re-release on PS4/PS5
* Jumping Flash! - Free PS4/PS5 version for PS3 PSone Classics owners
* MediEvil (1998)
* Mr. Driller - PlayStation Plus Premium subscription only (?)
* Oddworld: Abe’s Oddysee - Free PS4/PS5 version for PS3 PSone Classics owners
* G-Police (1997)
* R4: Ridge Racer Type 4 (1998)
* Resident Evil: Director’s Cut - PlayStation Plus Premium subscription only
* Syphon Filter - Free PS4/PS5 version for PS3 PSone Classics owners
* Tekken 2 - PlayStation Plus Premium subscription only
* The Legend of Dragoon (1999)
* Toy Story 2: Buzz Lightyear To The Rescue! - Free PS4/PS5 version for PS3 PSone Classics owners
* Twisted Metal (1995) UP9000-CUSA43359_00-SCUS943040000000 or JP9000-CUSA43360_00-SIPS600070000000
* Twisted Metal 2 / Twisted Metal EX UP9000-CUSA43361_00-SCUS943060000000 or JP9000-CUSA43362_00-SIPS600210000000
* Wild Arms - Free PS4/PS5 version for PS3 PSone Classics owners
* Worms World Party - First-time NA re-release on PS4/PS5
* Worms Armageddon - First-time NA re-release on PS4/PS5
 
* https://www.playstation.com/en-us/editorial/iconic-must-play-titles-on-playstation-plus-classics-catalog/
* https://www.reddit.com/r/PS3/comments/1cscsb2/all_ps1pspps3_games_that_have_crossbuy_or_free/
* https://www.reddit.com/r/PlayStationPlus/comments/vfg39t/is_there_a_clear_list_of_which_ps1_classic_ps4ps5/
 
"I have bought some of them on the PS3/Vita and the ones I could claim on the PS4/PS5 were Tekken 2 (which previously was not redeemable), all Syphon Filter games, all Wild Arms games, Legend of Dragoon, Ridge Racer Type 4 and Jumping Flash. Resident Evil Director's Cut is NOT redeemable. The rule of thumb is: if you can buy it on PS4/PS5 - and not only claim it through plus premium/deluxe sub, like Resident Evil 1 - they are redeemable from a previous purchase on PS3/PSP/Vita."
 
Official PS Classic games (warning: some may be remastered, to check) on PS4/PS5 sold on Bluray Discs:
* Tomba! by LRG (for PS5: UP6893-PPSA21381_00-0240103642659799-U001)
* TBA 2025 by LRG: Tomba 2 The Evil Swine Return
* TBA 2025 by LRG: Gex Trilogy: Gex, Gex Enter the Gecko, Gex 3 Deep Cover Gecko
* TBA 2025 by LRG: Clock Tower: Rewind https://store.playstation.com/en-us/concept/10010305 Notice: PS1 Clock Tower is not the original game. The first game in the series was Clock Tower (1995) - first released on the SNES, later ported to PS1, PC and WonderSwan, but only ever released in Japan. The PS1 game is the second game, and was called Clock Tower 2 in Japan but just Clock Tower everywhere else, even though it is a sequel and not a port of the original. So Clock Tower 2 on the PS1 is the third game, and Clock Tower 3 on the PS2 is the fourth game.
* TBA 2025 by LRG: Fear Effect
* TBA 2025 by LRG: Fighting Force and Fighting Force 2
 
"Five PS1 games were recently announced for PS5 and PS4 with trophy support: Gex, Gex Enter the Gecko, Gex 3 Deep Cover Gecko, Clock Tower, and Tomba. All five games were announced to be using Limited Run Games' Carbon Engine, which so far has been primarily used to support older console emulation like the SNES and Sega Genesis, but has now officially revealed support for Sony's original PlayStation as well. These PS1 ports for PS5 and PS4 will use Limited Run Games' "Carbon Engine," which allows these classic titles to implement modern features like trophy support."


=== PS2 games savedata exploits ===
=== PS2 games savedata exploits ===


See [https://www.psdevwiki.com/ps2/Vulnerabilities#PS2_Savedata_exploits PS2 savedata exploits on PS2 Dev Wiki].
See [[PS2 Emulation]] for a list of candidate games.
 
Official PS2onPS4 games sold on the PS Store (as of September, 2024):
* ADK DAMASHII™ UP0576-CUSA03783_00-SLPS259060000001 https://image.api.playstation.com/cdn/UP0576/CUSA03783_00/BpMMUC8q1MRAsL9iWDh6vbW844hq3JXK.png
* Arc the Lad: Twilight of the Spirits
* Art of Fighting Anthology
* Ape Escape 2
* Bully (Canis Canem Edit)
* Dark Chronicle (Dark Cloud 2) UP9000-CUSA02037_00-SCUS972130000001 https://image.api.playstation.com/cdn/UP9000/CUSA02037_00/hIKSKqBMerypNW49TCECATZSBBUcSBph.png
* Dark Cloud
* Destroy All Humans!
* Destroy All Humans! 2
* Eternal Ring UP1022-CUSA04654_00-SLUS200150000001 https://image.api.playstation.com/cdn/UP1022/CUSA04654_00/DRIS0z7mtNMYZPchoqLnKlhJqyNvM8mZ.png
* FantaVision
* Fatal Fury Battle Archives Vol. 2
* Forbidden Siren EP9000-CUSA02274_00-SCES519200000001 patch 1.01 requires PS4 3.10
* Fu'un Super Combo UP0576-CUSA03784_00-SLPS257810000001 https://image.api.playstation.com/cdn/UP0576/CUSA03784_00/QWsetumZLYupFHsOIkoGbKYpySGBdtlp.png
* Ghosthunter (English, Japanese) UP9000-CUSA47996_00-SLUS209930000000
* GTA III
* GTA Vice City
* GTA San Andreas
* Harvest Moon: Save the Homeland
* Harvest Moon: A Wonderful Life Special Edition
* Hot Shots® Tennis (Everybody's Tennis) UP9000-CUSA02193_00-SCUS976100000001 https://image.api.playstation.com/cdn/UP9000/CUSA02193_00/FrJXexHruy7pjB6bCgDidXRbakNfNJJc.png
* Indigo Prophecy
* Jak and Daxter™ HP9000-CUSA08427_00-SCPS560030000001 patch 1.01 requires PS4 4.73
* Jak and Daxter: The Precursor Legacy™ UP9000-CUSA02522_00-SCUS971240000001 patch 1.01 requires PS4 4.73
* Jak and Daxter™: The Precursor Legacy EP9000-CUSA07934_00-SCES503610000001 patch 1.03 requires PS4 4.73
* Jak II™ UP9000-CUSA07840_00-SCUS972650000001 patch 1.01 requires PS4 5.01
* Jak II™ EP9000-CUSA07990_00-SCES516080000001 patch 1.02 requires PS4 5.01
* Jak II™ HP9000-CUSA08422_00-SCKA200100000001 patch 1.01 requires PS4 5.01
* Jak 3™ UP9000-CUSA07841_00-SCUS973300000001 patch 1.01 requires PS4 5.01
* Jak 3™ EP9000-CUSA07991_00-SCES524600000001 patch 1.01 requires PS4 5.01
* Jak 3™ HP9000-CUSA08423_00-SCKA200400000001 patch 1.01 requires PS4 5.01
* Jak X: Combat Racing UP9000-CUSA07842_00-SCUS974290000001 patch 1.02 requires PS4 5.01
* Jak™ X EP9000-CUSA07992_00-SCUS974290000001 patch 1.02 requires PS4 5.01
* Kinetica UP9000-CUSA01725_00-SCUS971320000001 https://image.api.playstation.com/cdn/UP9000/CUSA01725_00/EKH34FKOEt3dTXLCiccuawdS8iGIqGLF.png
* Manhunt
* Max Payne
* Metal Slug Anthology
* Mister Mosquito UP9000-CUSA48755_00-SLUS203750000000 (for PS5: UP9000-PPSA22948_00-SLUS203750000000) patch 1.02 requires PS4 11.52 or PS5 9.60
* Okage: Shadow King UP9000-CUSA02199_00-SCUS971290000001, requires PS4 FW version 3.15, although it was compiled with PS4 SDK version 3.008.000, latest patch requires PS4 FW 4.05
* PaRappa the Rapper 2
* Primal
* Psychonauts
* Puzzle Quest: Challenge of the Warlords
* Red Dead Revolver
* Red Faction
* Red Faction II
* Resident Evil Code: Veronica X
* Rise of the Kasai
* Rogue Galaxy
* Samurai Shodown VI
* Siren UP9000-CUSA02198_00-SCUS973550000001 (for PS5: UP9000-PPSA22947_00-SCUS973550000000) PS4 patch 1.02 requires PS4 3.00 and PS5 patch 1.00 requires PS5 9.40
* SkyGunner UP9000-CUSA49210_00-SLUS203840000000 (for PS5: UP9000-PPSA23535_00-SLUS203840000000) patch 1.03 requires PS4 11.52 or PS5 9.60
* Sly Raccoon (2002), Sly Cooper and the Thievius Racoonus UP9000-CUSA47431_00-SCUS971980000000 requires PS4 FW ?11.00? (update requires PS4 11.508.000)
* Star Ocean Till The End Of Time
* Star Wars Bounty Hunter
* Star Wars Racer Revenge
* STAR WARS: Jedi Starfighter UP1082-CUSA03473_00-SLUS202930000001 https://image.api.playstation.com/cdn/UP1082/CUSA03473_00/PGRyqtcRKUoAsP4bJAhcoziTwL8940k1.png
EP1006-CUSA03494_00-SLES503710000001
https://image.api.playstation.com/cdn/EP1006/CUSA03494_00/9MsXVY5UULzSHB5BTreuKhwep3KZwvQP.png
* STAR WARS The Clone Wars UP1082-CUSA48010_00-SLUS205100000000
* Summoner UP4389-CUSA48889_00-SLUS200740000000 (for PS5: UP4389-PPSA23124_00-SLUS200740000000) PS4 patch 1.01 requires PS4 11.50, PS5 patch 1.02 requires PS5 9.40
* The King of Fighters Collection: The Orochi Saga
* The King of Fighters '98 Ultimate Match
* The King of Fighters 2000
* The Mark of Kri
* The Warriors
* Timesplitters EP4062-CUSA49387_00-SLUS200900000000 (for PS5: EP4062-PPSA23799_00-SLUS200900000000) PS4 patch 1.01 requires PS4 11.52, PS5 patch 1.00 requires PS5 9.40
* TimeSplitters 2 EP4062-CUSA49392_00-SLUS203140000000 (for PS5: EP4062-PPSA23801_00-SLUS203140000000) PS4 patch 1.01 requires PS4 11.52, PS5 patch 1.00 requires PS5 9.40
* TimeSplitters: Future Perfect EP4062-CUSA49435_00-SLUS211480000000 (for PS5: EP4062-PPSA23847_00-SLUS211480000000) PS4 patch 1.01 requires PS4 11.52, PS5 patch 1.00 requires PS5 9.40
* Tomb Raider: Legend UP8489-CUSA48389_00-SLUS212030000000 https://store.playstation.com/store/api/chihiro/00_09_000/titlecontainer/SE/en/999/CUSA48389_00/image
* Twisted Metal: Black
* War of the Monsters
* Wild Arms 3
 
* See [https://www.playstation.com/en-us/editorial/iconic-must-play-titles-on-playstation-plus-classics-catalog/].
 
Official PS2onPS4 games sold on Bluray Discs:
* ADK DAMASHII™ UP0576-CUSA03783_00-SLPS259060000001 https://image.api.playstation.com/cdn/UP0576/CUSA03783_00/BpMMUC8q1MRAsL9iWDh6vbW844hq3JXK.png
* Art of Fighting Anthology (by Limited Run #375) UP0576-CUSA03754_00-SLUS214870000001 https://image.api.playstation.com/cdn/UP0576/CUSA03754_00/Hf5lUn48Ds3UDNp8NNjdzv7f1BZWGaai.png
* Destroy All Humans! (2005) (PS2 Classic by Limited Run #370, not to be confused with the remake EP4389-CUSA14910_00-DAH1REMAKEEU0000) UP4389-CUSA05232_00-SLUS209450000001 https://image.api.playstation.com/cdn/UP4389/CUSA05232_00/XrgVkqoR5rvZk4tAGi2j7OFfHpAZWKUu.png
* Fatal Fury Battle Archives Vol. 2 (by Limited Run #371) UP0576-CUSA03750_00-SLUS217230000001 https://image.api.playstation.com/cdn/UP0576/CUSA03750_00/gFCLAhlGZwvFkra1p2sozwIZ5SH1OyZO.png
* Fu'un Super Combo UP0576-CUSA03784_00-SLPS257810000001 https://image.api.playstation.com/cdn/UP0576/CUSA03784_00/QWsetumZLYupFHsOIkoGbKYpySGBdtlp.png
* Indigo Prophecy™ (aka Fahrenheit 2005, by Limited Run #331) UP1642-CUSA04798_00-SLUS211960000001 https://image.api.playstation.com/cdn/UP1642/CUSA04798_00/WJFDq83f1tcZ0E2PkEa1rXOba8laaZUV.png
* Jak and Daxter: The Precursor Legacy™ UP9000-CUSA02522_00-SCUS971240000001 https://image.api.playstation.com/cdn/UP9000/CUSA02522_00/o9zJoXqpd4lzarjIbvvZLFjYGLsLvqCp.png
* Jak X Combat Racing™® UP9000-CUSA07842
* Jak II UP9000-CUSA07840
* Jak 3 UP9000-CUSA07841
* METAL SLUG ANTHOLOGY™ (US version by Limited Run #364) UP0576-CUSA03749_00-SLUS215500000001 https://image.api.playstation.com/cdn/UP0576/CUSA03749_00/ImHDRENlttkdiXlm3K8ejNVgLURd3uTw.png
* METAL SLUG ANTHOLOGY™ (EU version by SNK) EP0576-CUSA04156_00-SLES546770000001 https://image.api.playstation.com/cdn/EP0576/CUSA04156_00/NN7npbsEvxIRGI8lBVhm9I5BwFzdGlOK.png
* Psychonauts UP2154-CUSA03881
* Red Faction (by Limited Run #281) UP4389-CUSA06402_00-SLUS200730000001 https://image.api.playstation.com/cdn/UP4389/CUSA06402_00/T07Bf136claKzP3SHF30QLa2xMAFjSpP.png
* Samurai Shodown VI (by Limited Run #329) UP0576-CUSA03787_00-SLUS216290000001 or EP0576-CUSA04158_00-SLES552920000001 https://image.api.playstation.com/cdn/UP0576/CUSA03787_00/CuLRRdOYvdge0IW9LL9Vewj44RCc6OAU.png https://image.api.playstation.com/cdn/EP0576/CUSA04158_00/7SrtqugKMJixAcbprEE0ExGUOHlhL0F7.png
* STAR WARS™ BOUNTY HUNTER™ (US version) UP1082-CUSA03472_00-SLUS204200000001
* STAR WARS™ BOUNTY HUNTER™ (EU version) EP1006-CUSA03493_00-SLES508310000001
* Star Wars Racer Revenge UP1082-CUSA03474, requires PS4 FW version ?3.15, although it was compiled with SDK version 3.008.000?
* The King of Fighters '98 Ultimate Match (by Limited Run #344) UP0576-CUSA03751_00-SLUS218160000001 https://image.api.playstation.com/cdn/UP0576/CUSA03751_00/bp4LfKIjcVTMfKP3O4LrDJHWzY6vZDar.png
* The King of Fighters 2000 (by Limited Run #386) UP0576-CUSA03748_00-SLUS208340000001 https://image.api.playstation.com/cdn/UP0576/CUSA03748_00/tvXJmFqa9zkXAAKCij20B3spadkqGuka.png
* The King of Fighters™ Collection: the Orochi Saga (by Limited Run #393) UP0576-CUSA03753_00-SLUS215540000001 https://image.api.playstation.com/cdn/UP0576/CUSA03753_00/E3gFtUUjCu2WDBSIGeXMV40sfF4uHzZi.png


These PS2onPS4 games can be bought online directly via Limited Run Games for brand new or for example on Ebay for second hand or like new.
See [https://www.psdevwiki.com/ps2/Vulnerabilities#PS2_Savedata_exploits PS2 Dev Wiki] for a list of PS2 savedata exploits.


=== PSP games savedata exploits ===
=== PSP games savedata exploits ===


See [https://www.psdevwiki.com/psp/Vulnerabilities PSP savedata exploits on PSP Dev Wiki].
See [[PSP Emulation]] for a list of candidate games.
 
* https://wololo.net/2012/09/01/when-the-psp-and-the-vita-show-their-battle-scars/
* https://wololo.net/talk/viewtopic.php?f=52&t=11183&start=10#p143779
* https://www.playstation.com/en-us/editorial/iconic-must-play-titles-on-playstation-plus-classics-catalog/


Official PS2onPS4 games sold on the PS Store (as of September, 2024):
See [https://www.psdevwiki.com/psp/Vulnerabilities PSP Dev Wiki] for a list of PSP savedata exploits.
* Tekken 6 UP0700-CUSA33754_00-TEKKEN6000000000
* Killzone: Liberation (2006) EP9000-CUSA37875_00-UCES002790000000
* Ratchet & Clank: Size Matters (2007) UP9000-CUSA41395_00-UCUS986330000000
* Syphon Filter: Logan's Shadow (2007) EP9000-CUSA32631_00-UCES007100000000
* Pursuit Force (2005) UP9000-CUSA37191_00-UCUS986400000000 or EP9000-CUSA37192_00-UCES000190000000 or HP9000-CUSA37193_00-UCKS450160000000
* Pursuit Force: Extreme Justice UP9000-CUSA34853_00-UCUS987030000000
* Super Stardust Portable (2007) EP9000-CUSA33036_00-NPEG000080000000
* Resistance: Retribution (2009) UP9000-CUSA32636_00-UCUS986680000000 or EP9000-CUSA32637_00-UCES011840000000
* Jeanne d’Arc (2006) UP9000-CUSA41018_00-UCUS987000000000
* Jak and Daxter: The Lost Frontier UP9000-CUSA41282_00-NPUG803300000000 (for PS5: UP9000-PPSA14325_00-NPUG803300000000-U001) patch 1.02 requires PS4 11.50 or PS5 9.00
* LEGO Star Wars II: The Original Trilogy UP1082-CUSA41250_00-ULUS101550000000 (for PS5: UP1082-PPSA14300_00-ULUS101550000000, UP1082-PPSA14300_00-0804842924824650-U002) or EP1006-CUSA41251_00-ULES004790000000, patch 1.01 requires PS4 11.50 or PS5 9.20
* Daxter UP9000-CUSA36097_00-NPUG803290000000 (for PS5: UP9000-PPSA09695_00-NPUG803290000000-U001) patch 1.01 requires PS4 11.50 or PS5 9.20


=== PS4/PS5 PS2emu sandbox escape (mast1c0re) ===
=== PS4/PS5 PS2emu sandbox escape (mast1c0re) ===
Line 198: Line 46:
'''No''' as of PS4 FW 11.50 and PS5 FW 8.00. Using the PS2onPS4 game Okage Shadow King, the exploit should work starting from PS4 FW 3.15 and PS5 FW 1.00.
'''No''' as of PS4 FW 11.50 and PS5 FW 8.00. Using the PS2onPS4 game Okage Shadow King, the exploit should work starting from PS4 FW 3.15 and PS5 FW 1.00.


=== PS4/PS5 game savedata LUA exploit ===
=== PS4/PS5 game savedata Lua exploit ===


==== Credits ====
==== Credits ====
* Used by Flatz on 2023-07-27 in [https://wololo.net/2023/07/28/ps5-flat_z-dumps-ps5-secure-processor-confirms-he-has-a-ps5-hypervisor-exploit-via-a-ps4-game-save-exploit/ his Hypervisor exploit].
* Used by Flatz on 2023-07-27 in [https://wololo.net/2023/07/28/ps5-flat_z-dumps-ps5-secure-processor-confirms-he-has-a-ps5-hypervisor-exploit-via-a-ps4-game-save-exploit/ his Hypervisor exploit].
* Used by Flatz on 2024-09-14 in [https://gist.github.com/flatz/5e12f75cdb210516d31df03069f7ed0a his implementation of the umtx UaF kernel exploit].
* Used by Flatz on 2024-09-14 in [https://gist.github.com/flatz/5e12f75cdb210516d31df03069f7ed0a his implementation of the umtx UaF kernel exploit].
* Lua sandbox escape makers (to document): Peter Cawley (corsix), erezto, Morgan Jones (numinit), Maxim Ivanov (ulidtko)


==== Bug description ====
==== Bug description ====
Some PS4 (or maybe PS5) games, in disc version (probably also available in PS Store version but potentially patched), can be exploited as they use some LUA interpreter, by crafting an evil save data.
Some PS4 (and maybe PS5) games, in disc version (usually also available in PS Store version, some even in free demo version, but potentially patched), can be exploited as they allow the user to execute Lua code by crafting an evil save data. By running malicious Lua code, the attacker can escape the Lua sandbox and obtain usermode arbitrary read-write then ROP chain execution in usermode.
 
On PS Vita, you can simply install the DRM demos, the same way as you would for Bitter Smile Demo (see h-encore by TheFloW).
 
If you have access to the PS4/PS5 PS Store, you can simply buy the trial version to test it.
 
Artemis and MUGEN engines are known to use Lua and so are vulnerable to various sandbox escape exploits.
 
Most of Artemis games automatically load save9999.dat file from save data folder when the game boots. By editing this file, one can load custom LUA scripts.
 
Game boots -> "save9999.dat" is loaded -> "inject.iet" is loaded -> "inject.lua" is loaded.
 
You might have to create a different save9999.dat file for each game as the Lua interpreter version might differ.
 
On Windows, you have access to luasocket and os.execute. However, on PS Vita/PS4/PS5, you have limited access.
 
You have to copy PS Vita/PS4/PS5 savedata files to the console.


==== Vulnerable games ====
==== Vulnerable games ====
See [[Artemis Engine]] for a list of candidate games.


Not confirmed:
Confirmed exploitable games:
Pay Day 2, Mafia III, God of War (which one?).
* Raspberry Cube (CUSA16074)
* Aibeya (CUSA17068)
* Hamidashi Creative (CUSA27389)
* Hamidashi Creative Demo (CUSA27390)


Confirmed:
Other games that may use Lua scripts:
TODO
* Pay Day 2, Mafia III, God of War (which one?).
* Games using the MUGEN engine are vulnerable to many exploits, but it is unknown if some PS4 games use this engine. https://mugen-cheap.fandom.com/wiki/SuperNull


==== Analysis ====
==== Analysis ====


==== Patched
==== Exploit Implementation ====
* [https://github.com/shahrilnet/remote_lua_loader/blob/b5f2420495e66308de06934530b3c449ab4bcf9b/savedata/inject.lua#L793 Lua ?5.1? sandbox escape in PS4 games running Artemis engine by shahrilnet (2024-11-25)]
* [https://gist.github.com/flatz/cbb84539aeee1ade1983ee2eea499dbc ROP chain manager in Lua by flatz (2024-11-02)]
* [https://github.com/Gezine/ArtemisLuaLoader Lua script execution PoC for Raspberry Cube (PS4 CUSA16074 and Windows) by Gezine (2024-10-06)]
* [https://github.com/erezto/lua-patcher LUA 5.1-5.3 bytecode patching tool by erezto (2015-10-19)]
* [https://github.com/erezto/lua-sandbox-escape/blob/master/x86_64/exploit.lua Lua 5.2 sandbox escape for x86 and x86-64 by erezto (2016-04-27)]
* [https://github.com/adamivora/lua-hardening-suite/tree/main/exploits Various Lua exploits by Adam Ivora (adamivora) (2023-12-14)]
* [https://web.archive.org/web/20201029040829/https://apocrypha.numin.it/talks/lua_bytecode_exploitation.pdf Escaping the Lua 5.2 sandbox with untrusted bytecode by Morgan Jones (numinit) (2016-09-12)]
* [https://www.corsix.org/content/malicious-luajit-bytecode Malicious LuaJIT bytecode by Peter Cawley (corsix) (2015-11-11)]
* [https://gist.github.com/corsix/49d770c7085e4b75f32939c6c076aad6 Exploiting Lua 5.2 on x64 by Peter Cawley (corsix) (2016-08-21)]
* [https://gist.github.com/ulidtko/51b8671260db79da64d193e41d7e7d16 Exploiting Lua 5.1 with bytecode type confusion on 32-bit Windows by Maxim Ivanov (ulidtko) (2018-03-21)]
* [https://gist.github.com/corsix/6575486 Exploiting Lua 5.1 on 32-bit Windows by Peter Cawley (corsix) (2013-09-16)]
* [https://gist.github.com/corsix/1fc9b13a2dd5f3659417b62dd54d4500 LuaJIT 2.1.0beta1 string hash table collision by Peter Cawley (corsix) (2019-04-27)]
* [https://github.com/gonzalezjo/ljhashdos LuaJIT 2.1.0beta1 string hash table collision by gonzalezjo (2018-07-09)]
* [https://benmmurphy.github.io/blog/2015/06/04/redis-eval-lua-sandbox-escape/ Redis EVAL Lua Sandbox Escape by Ben Murphy (2015-06-04)]
* [https://www.youtube.com/watch?v=8Q0KLTma_FA LuaJIT, something interesting inside at Lua Workshop 2016 by Peter Cawley (corsix) (2016-12-04)]
* [https://www.youtube.com/watch?v=OSMOTDLrBCQ Lua: Mitigating the Danger of Malicious Bytecode at Lua Workshop 2011 by Peter Cawley (corsix) (2011-09-08)]
* [https://github.com/ZiddiaMUGEN/LuaSupernull Lua exploits for the MUGEN 1.1 engine]
* [https://www.lua.org/bugs.html Lua bugs for any version disclosed by lua.org]
 
==== Patched ====
'''No''' as of PS4 FW ?12.00? and PS5 FW 7.61.
'''No''' as of PS4 FW ?12.00? and PS5 FW 7.61.


Line 235: Line 125:


==== Analysis ====
==== Analysis ====
* [https://github.com/TheOfficialFloW/Presentations/blob/master/2022-hardwear-io-bd-jb.pdf Pages 27 and 28 of slides presented at hardwear.io by TheFloW (2022-06-10)]
* [https://twitter.com/theflow0/status/1701154155744645349 Removed tweet of BD-JB2 logs on a 7.61 PS5 by TheFloW (2023-09-11)]
* [https://twitter.com/theflow0/status/1701154155744645349 Removed tweet of BD-JB2 logs on a 7.61 PS5 by TheFloW (2023-09-11)]
* [https://github.com/TheOfficialFloW/bd-jb/commit/44713ef59f897ff2125efccbdcb5d07dbe1ffdb5 Diff between UserPreferenceManagerImpl hijack and Path traversal sandbox escape implementations by TheFloW (2024-11-28)]


==== Bug Description ====
==== Bug Description ====
Basing on BD-JB1 exploit files, in /bdmv/bdjo.xml changing bdjo/applicationManagementTable/baseDirectory to a path of the form `file:///app0/cdc/lib/../../../disc/BDMV/JAR/00000.jar` allows loading a JAR Java executable file.
Basing on the BD-JB1 exploit files, in /bdmv/bdjo.xml changing bdjo/applicationManagementTable/baseDirectory to a path of the form `file:///app0/cdc/lib/../../../disc/BDMV/JAR/00000.jar` allows loading a JAR Java executable file. This vulnerability can efficiently replace the UserPreferenceManagerImpl to extend the supported System Software versions range compared to BD-JB1.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://twitter.com/theflow0/status/1717088032031982066 PoC by TheFloW (2023-10-25)]
* [https://twitter.com/theflow0/status/1717088032031982066 Removed PoC by TheFloW (2023-10-25)]
* [https://github.com/TheOfficialFloW/bd-jb/blob/d21fd76c0768d05ad01c4722eb21480fa8a8b619/src/com/bdjb/Loader.java#L62 Implementation by TheFloW (2024-11-28)]


==== Patched ====
==== Patched ====
'''No''' as of PS4 FW 10.71 (maybe patched on PS4 FW 11.00). '''Yes''' on PS5 FW 8.00.
'''No''' as of PS4 FW 10.71 (maybe patched on PS4 FW 11.00). '''Yes''' on PS5 FW 8.00. Probably not patched on PS3.


=== FW <= 9.00 - BD-JB - Five vulnerabilities chained by TheFloW ===
=== FW <= 9.00 - BD-JB - Five vulnerabilities chained by TheFloW ===
Line 260: Line 153:


==== Bug Description ====
==== Bug Description ====
TO ADD DESCRIPTION OF EACH ONE OF THE 5 BUGS:
This exploit chain alone does not allow one to run pirated games on PS4 or PS5 as there is not enough RAM allowed in the BD-J process and there are other constraints.


* #1 com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl userprefs hijack leading to classes instantiation under privileged context (affecting ?PS3?, PS4, PS5)
TODO!: ADD DESCRIPTION OF EACH ONE OF THE 5 BUGS:
* #2 com.oracle.security.Service leading to privileged constructor call (affecting ?PS3?, PS4, not PS5)
* #3 com.sony.gemstack.org.dvb.io.ixc.IxcProxy leading to privileged method call (affecting ?PS3?, PS4, PS5)
* #4 JIT compiler hack leading to usermode arbitrary RW and arbitrary usermode code execution (affecting ?PS3?, PS4, not PS5)
* #5 UDF buffer overflow kernel exploit (affecting ?PS3?, PS4, PS5)


This exploit chain alone does not allow one to run pirated games on PS4 or PS5 as there is not enough RAM allowed in the BD-J process and there are other constraints.
===== #1 - userprefs hijack (?PS3?, PS4, PS5) =====
 
com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl userprefs hijack leads to classes instantiation under privileged context.
 
===== #2 - com.oracle.security.Service (?PS3?, PS4, not PS5) =====
 
com.oracle.security.Service leads to privileged constructor call.


==== Exploit Implementation ====
===== #3 - com.sony.gemstack.org.dvb.io.ixc.IxcProxy leading to privileged method call (?PS3?, PS4, PS5) =====
* [https://github.com/TheOfficialFloW/bd-jb Implementation of BD-J usermode code execution on PS4 using bugs #1, #2, #3 and #4 by TheFloW (2021-10-24)]
 
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/exploit/sandbox/ExploitUserPrefsImpl.java Vuln #1 com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl implementation by TheFloW]
com.sony.gemstack.org.dvb.io.ixc.IxcProxy leads to privileged method call.
 
===== #4 - JIT compiler hack (?PS3?, PS4, not PS5) =====
 
JIT compiler hack leads to usermode arbitrary RW and usermode arbitrary code execution.
 
===== #5 - UDF buffer overflow (?PS3?, PS4, PS5) =====
 
The UDF driver in kernel contains a buffer overflow. Note that no implementation of the UDF kernel exploit has ever been done even by TheFloW, only a kernel panic PoC.
 
==== Exploit Implementation ====
* [https://github.com/TheOfficialFloW/bd-jb Implementation of BD-J usermode code execution on PS4 using bugs #1, #2, #3 and #4 by TheFloW (2021-10-24)]
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/exploit/sandbox/ExploitUserPrefsImpl.java Vuln #1 com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl implementation by TheFloW]
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/exploit/sandbox/ExploitServiceProxyImpl.java Vuln #2 com.oracle.security.Service and #3 com.sony.gemstack.org.dvb.io.ixc.IxcProxy chained together by TheFloW]
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/exploit/sandbox/ExploitServiceProxyImpl.java Vuln #2 com.oracle.security.Service and #3 com.sony.gemstack.org.dvb.io.ixc.IxcProxy chained together by TheFloW]
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/jit/JitCompilerReceiverImpl.java Vuln #4 JIT compiler hack implementation by TheFloW]
* [https://github.com/TheOfficialFloW/bd-jb/blob/master/src/com/bdjb/jit/JitCompilerReceiverImpl.java Vuln #4 JIT compiler hack implementation by TheFloW]
Line 290: Line 197:


[https://web.archive.org/web/20241007081407/https://doc.dl.playstation.net/doc/ps4-oss/webkit.html WebKit sources] archived currently up to version 11.00. Useful for people that cannot access PlayStation URLs and also for when Sony will inevitably stop hosting the sources.
[https://web.archive.org/web/20241007081407/https://doc.dl.playstation.net/doc/ps4-oss/webkit.html WebKit sources] archived currently up to version 11.00. Useful for people that cannot access PlayStation URLs and also for when Sony will inevitably stop hosting the sources.
=== Untested - mmap issue involving pointer address misalignment leading to nothing for now ===
==== Credits ====
* Jasmine, working for Sony, for information through a WebKit commit (2022-10-19)
==== Analysis ====
* https://bugs.webkit.org/show_bug.cgi?id=246763
==== Bug Description ====
There is a mmap issue involving pointer address misalignmen because of a failing assert [https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/heap/StructureAlignedMemoryAllocator.cpp#L94 here]. A workaround is to set HAVE_MAP_ALIGNED flag as OFF in OptionsPlayStation.cmake: [https://github.com/WebKit/WebKit/commit/626585db9857b7630cf34d82f9a0555720f15bca]. This workaround can be reverted after the mmap issue is resolved. Currently, the workaround is still enabled: [https://github.com/WebKit/WebKit/blob/ab2fff92b37e52d6c65e215b155e6b92f1646954/Source/cmake/OptionsPlayStation.cmake#L251]
==== Exploit Implementation ====
==== Patched ====
'''Maybe'''
==== Tested ====
Not tested yet on PS4 or PS5.
----


=== FW ?6.00-11.52? - get_by_id_with_this associated with ProxyObject can leak JSScope objects ===
=== FW ?6.00-11.52? - get_by_id_with_this associated with ProxyObject can leak JSScope objects ===
Line 349: Line 236:
----
----


=== FW ?10.00-11.52? - Integer underflow in WebKit renderer (CVE-2024-27833) leading to arbitrary code execution ===
=== FW ?6.00-11.52? - Integer underflow in JSC genericTypedArrayViewProtoFuncCopyWithin (CVE-2023-38600) ===


==== Credits ====
==== Credits ====
* Manfred Paul (@_manfp), working with Trend Micro Zero Day Initiative, for discovering the vulnerability on Apple Safari at pwn2own 2024 (2024-03-21) [https://twitter.com/thezdi/status/1770611705510293546 Zero Day Initiative's tweet]
* anonymous researcher for discovering the vulnerability and reporting it to Zero Day Initiative (2023-05)
* Apple Safari update integrates a fix (2024-06-10)
* Yusuke Suzuki and Mark Lam for fixing the bug in WebKit (2023-07-31)
* Hossein Lotfi for publishing a writeup (2023-10-18)


==== Analysis ====
==== Analysis ====
* [https://www.zerodayinitiative.com/blog/2023/10/17/cve-2023-38600-story-of-an-innocent-apple-safari-copywithin-gone-way-outside Writeup by Hossein Lotfi (2023-10-18)]
* [https://github.com/WebKit/WebKit/commit/6e7e654417b61630d67f02b65798439cf3d6b0b5 WebKit fix commit by Yusuke Suzuki (2023-07-31)]


==== Bug Description ====
==== Bug Description ====
There is an integer underflow in WebKit renderer. It was addressed with improved input validation.
It is required to recompute length properly when resize happens during TypedArray copyWithin.
 
copyWithin's side effectful operation can resize resizable ArrayBuffer. WebKit has a code catching this and recompute the appropriate copy count again, but it can overflow if `to` or `from` are larger than the newly updated `length`. The patch handles this case correctly: returning since there is no copying content in this case.
 
The issue was patched by aborting the copy if either of the two variables to or from is larger than the updated length.


It is associated with WebKit Bugzilla #271491.
The values used during the exploit were sane as they went through a sanitizer function. However, in the final stage, the values were updated without checking if there are inside the buffer length bounds.
 
According to PS4 WebKit source code for System Software version 11.00, not only it is not patched but it uses code from 2021! Looking at [https://github.com/WebKit/WebKit/blob/cccb58deac3c56a831678458ce95ea5b7c837614/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h#L177 a version close to one in the PS4 source code for System Software version 11.00], it should be exploitable.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://gist.github.com/zdi-team/ad320bdc6ad095cc210c7031e0f0ecda/raw/746ce622fe73344ccb9cd51bc03ad97950f4ea3b/CVE-2023-38600-0.js Minimal PoC by Hossein Lotfi (2023-10-18)]
* [https://github.com/WebKit/WebKit/blob/main/JSTests/stress/resizable-array-buffer-copy-within-length-update.js Vulnerability test code by Yusuke Suzuki (2023-07-31)]


==== Patched ====
==== Patched ====
'''Maybe''' on PS4 FW 12.00 and PS5 FW ?10.00?.
'''Maybe''' in FW 11.50.


==== Tested ====
==== Tested ====
Not tested as there is no PoC available.
Not tested yet on PS4 nor PS5. To test on PS4 11.00.
----
----


=== FW ?10.00-11.52? - Immediate overflow in JSC SBFX leading to crash ===
=== FW ?6.00-11.00? - CloneDeserializer::deserialize() UaF (CVE-2023-28205) leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Justin Michaud for fix commit, Yusuke Suzuki for fix commit review (2024-05-15)
* Clément Lecigne of Google's Threat Analysis Group and Donncha Ó Cearbhaill of Amnesty International’s Security Lab for discovering the vulnerability and reporting it to Apple (2023-04-10)
* xvonfers for discovering it affects PS4 and PS5 (2024-06-11) [https://twitter.com/xvonfers/status/1800426437486485635 xvonfer's tweet]
* Justin Michaud, Mark Lam and JonWBedard for fixing the bug in WebKit (2023-04-17)
* abc (anonymous) for making an OOM PoC for PS4 and PS5 (2024-12-01)


==== Analysis ====
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/1ea4ef8127276fd00ca43ffcb22bed162072abde WebKit fix commit by Justin Michaud (2024-05-15)]
* [https://github.com/WebKit/WebKit/commit/c9880de4a28b9a64a5e1d0513dc245d61a2e6ddb WebKit fix commit (2023-04-17)]


==== Bug Description ====
==== Bug Description ====
The JavaScriptCore Isel SBFX patterns in JavaScriptCore/b3/B3LowerToAir.cpp allowed immediate overflow as 'lsb' and 'width' are not properly checked.
Previously, CloneDeserializer::deserialize() was storing pointers to newly created objects in a few Vectors, in a MarkedArgumentBufferBase. This is problematic because the GC is not aware of Vectors, and cannot scan them. Instead, CloneDeserializer::deserialize() should store cell pointers in a MarkedVector.


SBFX stands for Signed Bitfield Extract. See [https://www.scs.stanford.edu/~zyedidia/arm64/sbfx_sbfm.html] and [https://developer.arm.com/documentation/101273/0001/The-Cortex-M55-Instruction-Set--Reference-Material/Bit-field-instructions/SBFX-and-UBFX]. SBFX is an alias for SBFM (Signed Bitfield Move). See [https://www.scs.stanford.edu/~zyedidia/arm64/sbfm.html]. SBFM is a bitfield extraction opcode.
The PoC code triggers a use-after-free (UaF) vulnerability by delaying the addition of Map and Date objects, which allows the garbage collector (GC) to free them. This can potentially lead to accessing freed objects to corrupt memory. Then it cannot avoid executing a release assert that causes an Out-Of-Memory crash.


Isel is a short name for Instruction SELect. This pass transforms generic machine instructions into equivalent target-specific instructions. It traverses the MachineFunction bottom-up, selecting uses before definitions, enabling trivial dead code elimination.
The WebKit patch refactors the MarkedArgumentBuffer class into a MarkedVector template class.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/WebKit/WebKit/blob/main/JSTests/stress/sbfx-offset-overflow.js Vulnerability test by Justin Michaud]
* [https://github.com/ntfargo/uaf-2023-28205/blob/main/poc.js PoC by abc (2024-12-01)]


==== Patched ====
==== Patched ====
'''Yes''' on PS4 FW 12.00 and PS5 FW ?10.00?.
'''Yes''' on PS4 FW ?11.00? and PS5 FW ?8.00?.


==== Tested ====
==== Tested ====
Tested working on PS4 FWs 11.50 and PS5 FWs ?6.00-9.60?. Not working on PS4 <= 9.00 and PS5 >= 10.01.
Tested working on PS4 FWs ? and PS5 FWs 6.00-7.61.
----
----


=== FW ?10.00?-11.52 - Unknown heap and string overflow (no CVE) leading to crash ===
=== FW 6.00-9.60 - FrameLoader::loadInSameDocument() UaF (CVE-2022-22620) leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Debty for PoC public disclose (2024-08-29)
* Sergei Glazunov, Google Project Zero, for reporting the bug in 2013-01 and answering Maddie Stone's questions in 2022 (2013)
* Maddie Stone, Google Project Zero, for sharing a write-up describing this vulnerability (2022-06-14)
* abc (anonymous) for making an OOM PoC for webkit-gtk, PS4 and PS5 (2023-10-03) then making an arbitrary RW PoC (PSFree) for webkit-gtk, PS4 6.00-9.60 and PS5 1.00-5.50 (2023-10-24)
* CelesteBlue for testing and porting abc' PSFree to PS4 6.00-9.60 and PS5 1.00-5.50 (2023-11-04)


==== Analysis ====
==== Analysis ====
* [https://github.com/Debvt/Wm/tree/Root0 PoC and analysis by Debty (2024-08-29)]
* [https://github.com/WebKit/WebKit/commit/aa31b6b4d09b09acdf1cec11f2f7f35bd362dd0e WebKit bug-reintroducing commit by Darin Adler reviewed by Alex Christensen (2016-12-31)]
* [https://bugs.webkit.org/show_bug.cgi?id=235551 WebKit fix talk by Yusuke Suzuki reviewed by Mark Lam (2022-01-24)]
* [https://github.com/WebKit/WebKit/commit/486816dc355c19f1de1b8056f85d0bbf7084dd6e WebKit fix commit by Yusuke Suzuki reviewed by Mark Lam (2022-01-25)]
* [https://googleprojectzero.github.io/0days-in-the-wild/0day-RCAs/2022/CVE-2022-22620.html Short writeup by Maddie Stone (2022-06-14)]
* [https://googleprojectzero.blogspot.com/2022/06/an-autopsy-on-zombie-in-wild-0-day.html Detailed writeup by Maddie Stone (2022-06-14)]


==== Bug Description ====
==== Bug Description ====
* TODO
The History API allows access to (and modification of) a stack of the pages visited in the current frame, and these page states are stored as a <code>SerializedScriptValue</code>. The History API exposes a getter for state, and a method <code>replaceState()</code> which allows overwriting the "most recent" history entry.


Implementation description by Debty:<br />
The bug is that <code>FrameLoader::loadInSameDocument()</code> takes the state as an argument (<code>stateObject</code>), but does not increase its reference count. Only a <code>HistoryItem</code> object holds a reference to the <code>stateObject</code>. <code>loadInSameDocument()</code> can trigger a callback into user JavaScript through the <code>onblur</code> event. The user's callback can call <code>replaceState()</code> to replace the <code>HistoryItem</code>'s state with a new object, therefore dropping the only reference to the <code>stateObject</code>. When the callback returns, <code>loadInSameDocument()</code> will still use this free'd object in its call to <code>statePopped()</code>, leading to the use-after-free.
String exploit is not actually an exploit but just a memory exhauster. It is not actually viable so instead there is a feature called "latest iteration".


==== Exploit Implementation ====
When <code>loadInSameDocument()</code> is called it changes the focus to the element its scrolling to. If we set the focus on a different element prior to <code>loadInSameDocument()</code>'s execution, the blur event will be fired on that element. Then we can free the <code>stateObject</code> by calling <code>replaceState()</code> in the <code>onblur</code> event handler.
* [https://github.com/Debvt/Wm/tree/Root0 PoC by Debty (2024-08-29)]


==== Patched ====
The bug is triggered by <code>history.back()</code> with the target state whose URL contains a hash. Here's a Proof-of-Concept that will crash:
'''Yes''' on PS4 FW 12.00 and PS5 FW 10.00.
<source lang="js">
input = document.body.appendChild(document.createElement('input'));


==== Tested ====
foo = document.body.appendChild(document.createElement('a'));
Tested working on PS4 FWs 10.00-11.52 and PS5 FWs 6.00-9.60.
foo.id = 'foo';
----


=== FW ?6.00-11.52? - integer underflow vulnerability (CVE-2023-38600) ===
function pop(event) {
    alert('you get a crash after you close this alert');
    event.state; // use the freed SerializedScriptValue
    alert('WebKit version not vulnerable');
}


==== Credits ====
addEventListener('popstate', pop);
* anonymous researcher for discovering the vulnerability and reporting it to Zero Day Initiative (2023-05)
* Hossein Lotfi for publishing a writeup (2023-10-18)


==== Analysis ====
history.pushState('state1', '', location + '#foo'); // URL with a hash
* [https://www.zerodayinitiative.com/blog/2023/10/17/cve-2023-38600-story-of-an-innocent-apple-safari-copywithin-gone-way-outside Writeup by Hossein Lotfi (2023-10-18)]
history.pushState('state2', '');


==== Bug Description ====
setTimeout(() => {
    input.focus();
    input.onblur = () => {
        history.replaceState('state3', '')
    };
    setTimeout(() => {
        history.back(); // trigger loadInSameDocument()
    }, 1000);
}, 1000);


==== Exploit Implementation ====
</source>
The user may then trigger a double free and escalate it into an arbitrary read primitive via spraying <code>WTF::StringImpl</code>s like in the <code>buildBubbleTree()</code> UaF exploit. The read primitive is used to create the <code>addrof()</code> primitive and is used to save addresses of buffers that will be used to modify a <code>SerializedScriptValue</code>. After freeing the StringImpl (triple free), <code>SerializedScriptValue</code>s are sprayed via the <code>postMessage()</code> JavaScript function until one is allocated using the previously freed memory.


==== Patched ====
The method used to modify the fields of the <code>StringImpl</code> for arbitrary reads can be used can also be used to modify the <code>SerializedScriptValue</code>. Appropriate fields can modified to have deserialization create a <code>JSC::JSArrayBufferView</code> whose <code>m_vector</code> field will point to another <code>JSArrayBufferView</code>, which  will be called the worker. The user can modify the worker's fields for arbitrary read/write. Deserialization is done via <code>msg.data</code> where <code>msg</code> is the <code>MessageEvent</code> from <code>postMessage()</code>.
'''Maybe'''


==== Tested ====
A way to know if the system is vulnerable is the appearance of the input HTML element in the PoC page. If the HTML input field stays focused (blue outline) after the second timeout, then the vulnerability is not present. Note that Maddie Stone's PoC will never trigger any sort of crash on release builds as it was meant for builds with memory sanitation that can detect UaFs.
Not tested yet on PS4 nor PS5.
----
 
=== FW ?10.00-11.02? - JSC::DFG::clobberize() needs to be more precise with the *ByOffset nodes (CVE-2023-41993) leading to arbitrary RW ===
 
==== Credits ====
* Bill Marczak of The Citizen Lab at The University of Toronto's Munk School and Maddie Stone of Google's Threat Analysis Group for discoverting the vulnerability and reporting it (2023-09-21)
* Keith Miller for the WebKit fix commit (2023-10-09)
* po6ix for his writeup (2023-10-15)
 
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/08d5d17c766ffc7ca6a7c833c5720eb71b427784 WebKit fix commit by Keith Miller (2023-10-09)]
* [https://github.com/po6ix/POC-for-CVE-2023-41993 Writeup by po6ix (2023-10-15)]
 
==== Bug Description ====
clobberize needs to be more precise with the *ByOffset nodes. CSE phase uses clobberize to figure out if it's safe to merge two operations that def the same HeapLocation. Since HeapLocation does not currently have a way to track the offset used by the various *ByOffset nodes it can get confused and think that two ByOffset instructions produce the same value even if they do not use the same offset. This patch solves this by adding a new field to HeapLocation, which takes the metadata associated with the corresponding *ByOffset node. If two *ByOffset operations don't share the same metadata then they cannot be CSEed.
 
This vulnerability is ranked 7.5 (HIGH) on CVSS:3.1.
 
This vulnerability should provide r/w primitive to the webcontent process, but currently the PoC is written only up to addrof/fakeobj.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/po6ix/POC-for-CVE-2023-41993 PoC written only up to addrof/fakeobj by po6ix (2023-10-15)]
* Simple PoC for ASAN webkit-gtk by Maddie Stone in Maddie Stone's writeups
* [https://github.com/springsec/CVE-2022-22620/blob/main/CVE-2022-22620_infoleak_exploit.html Information leak PoC for webkit-gtk by springsec]
* [https://discord.com OOM PoC for PS4 and PS5 by abc on ps4-dev discord (to mirror)]
* [https://discord.com Arbitrary RW PoC (PSFree) for PS4 6.00-9.60 and PS5 1.00-5.50 by abc on ps4-dev discord (to mirror)]


==== Patched ====
==== Patched ====
'''Maybe''' on PS4 FW 12.00 and PS5 ?10.00?
'''Yes''' on PS4 FW 10.00 and PS5 FW 6.00.
 
The patch changes the stateObject argument to loadInSameDocument from a raw pointer, SerializedScriptValue*, to a reference-counted pointer, RefPtr<SerializedScriptValue>, so that loadInSameDocument now increments the reference count on the object.


==== Tested ====
==== Tested ====
Not tested yet. According to open source code, PS4 FW 11.00 should be vulnerable.
Tested working on PS4 FWs 6.00-9.60 and PS5 FWs 1.00-5.50. PS4 FWs <= 5.56 are invulnerable as the HTML input field stays focused (blue outline) after second timeout whilst it should not if the console were exploitable.
----
----


=== FW 10.00-11.02 - JSC DFG Abstract Intepreter clobberWorld Type Confusion (no CVE) leading to crash ===
=== FW 9.00-9.04 - WebCore::CSSFontFaceSet vulnerabilities leading to arbitrary RW ===
 
There are many FontFaceSet vulnerabilities. Explore [https://trac.webkit.org/search?q=mmaxfield%40apple.com+FontFaceSet&noquickjump=1&changeset=on].


==== Credits ====
==== Credits ====
* ENKI for public disclose and analysis (2024-06-03)
* Myles C. Maxfield (litherum), Apple, for adding the vulnerability in WebKit (2016-02-22) then fixing and so disclosing the vulnerability (2021-08-26)
* abc (anonymous) for tests and analysis (2024-10-01)
* Maddie Stone, Google Project Zero, for sharing 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 ====
* sleirsgoevy for making the first exploit PoC for Safari (2021-10-24) and the first exploit PoC for PS4 FW 9.00-9.04 and PS5 FW 3.00-4.50 (2021-10-27)
* [https://medium.com/@enki-techblog/ios-16-5-1-safari-rce-analysis-cve-2023-37450-89bb8583bebc Analysis by ENKI (2024-06-03)]
 
* [https://github.com/WebKit/WebKit/commit/1b0741f400ee2d31931ae30f2ddebe66e8fb0945 Patch commit #1 (2023-07-31)]
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/39476b8c83f0ac6c9a06582e4d8e5aef0bb0a88f Patch commit #2 (2023-05-01)]
* [https://github.com/WebKit/WebKit/commit/d5dbfd02054e9f904b27224a598ca1bb8ded5f87 WebKit bug-introducing commit by Myles C. Maxfield - r256659 (2016-02-22)]
* [https://www.zerodayinitiative.com/blog/2018/4/12/inverting-your-assumptions-a-guide-to-jit-comparisons Inverting Your Assumptions: A Guide to JIT Comparisons by Jasiel Spelman (2018-04-12)]
* [https://trac.webkit.org/changeset/281648/webkit WebKit fix commit by Myles C. Maxfield - r281648 (2021-08-26)]
* [https://github.com/WebKit/WebKit/commit/b22be72a013442ca9d1ff4bf3aa8aa436f78f142 WebKit commit adding FontFace tests (2021-09-01)]
* [https://bugs.webkit.org/show_bug.cgi?id=229848 WebKit Bugzilla - Bug 229848 - FontFaceSet.has() needs to react to style changes by Myles C. Maxfield (2021-09-02)]
* [https://github.com/web-platform-tests/wpt/pull/30322#issue-726455679 web-platform-tests - Add a test for FontFaceSet.has() #30322 (2021-09-03)]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1729089#c4 Mozilla Bugzilla - New wpt failures in /css/css-font-loading/fontfaceset-has.html (with TypeError `fonts.keys() is not iterable`, due to FontFaceSetIterator not behaving like an Iterable) (2021-09-03)]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1729997 Mozilla Bugzilla - FontFaceSet's iterators skip items when previous items are removed by Myles C. Maxfield (2021-09-09)]
* [https://bugs.webkit.org/show_bug.cgi?id=230119 WebKit Bugzilla - Bug 230119 - FontFaceSet's iterators skip items when previous items are removed by Myles C. Maxfield (2021-09-09)]
* [https://github.com/WebKit/WebKit/commit/fbf37d27e313d8d0a150a74cc8fab956eb7f3c59 WebKit fix commit by Myles C. Maxfield merged by Russell Epstein (2021-09-09)]
* [https://github.com/WebKit/WebKit/blob/74bd0da94fa1d31a115bc4ee0e3927d8b2ea571e/Source/WebCore/css/CSSFontFaceSet.cpp#L223 Part of vulnerable code]
* [https://web.archive.org/web/20211020134808/https://googleprojectzero.github.io/0days-in-the-wild//0day-RCAs/2021/CVE-2021-30858.html (archive) Write-up and PoC by Maddie Stone (2021-10-13)]. Maddie Stone's vulnerability is not CVE-2021-30858 but instead might be CVE-2021-30889. See [https://github.com/googleprojectzero/0days-in-the-wild/commit/65fcdf0473ada4e80dc967662ea8f3f3ce4ea81e#diff-1a428c43cedcf140e5bd6f92e4527f169c3c717780e1586f2fab589e4f467b52 write-up edit commit]. Warning: Maddie Stone's vulnerability was wrongly classified as a use-after-free by Maddie Stone according to sleirsgoevy.
* [https://wololo.net/2021/10/14/use-after-free-webkit-vulnerability-impacts-ps4-possibly-up-to-firmware-9-00-included/ Vulnerability description by Wololo (2021-10-14)]


==== Bug Description ====
==== Bug Description ====
Note that the PS4 web browser JIT support has been removed since around PS4 System Software version 5.00 or lower so using the article directly is not applicable.
Description in WebKit fix commit by Myles C. Maxfield:


The clobber bug PoC turns out not to be a memory corruption. Just like the article said, you can access a `GetterSetter` directly. The crash came from triggering `GetterSetter`'s methods that will call `RELEASE_ASSERT()`.
After r256659, asking for a failed CSSFontFace's families() returns nullopt. It is possible to add a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed and do not update our internal data structures, because there's no need to - we cannot do anything useful with a failed font. If you _then_ try to remove the font from the CSSFontFace, we do not call families(), but instead just pull out the raw m_families member, and look in our internal data structures for it, but we do not find it, because it was never added.


We actually came across a bug that can leak `GetterSetter`s at WebKit's git main branch: `ceb7e89febcd [JSC] get_by_id_with_this + ProxyObject can leak JSScope objects https://bugs.webkit.org/show_bug.cgi?id=267425 <rdar://120777816>`
Description in Maddie Stone's write-up:


In summary with tinkering with this bug, abc (anonymous) do not think that an attacker can do anything useful with accessing a `GetterSetter`. The clobberWorld bug however does allow setting properties in places where you usually cannot like `Function's prototype` as shown in the article. But without JIT, one probably cannot cause any memory corruption. The impact for both bugs (clobberWorld and ProxyObject) is probably just JavaScript execution, which we already have, which is a no go in some context (JS injection) but it does not help in gaining usermode ROP execution on PS4 or PS5.
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 do not 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 ====
Description by sleirsgoevy:
* [https://medium.com/@enki-techblog/ios-16-5-1-safari-rce-analysis-cve-2023-37450-89bb8583bebc PoC by ENKI (2024-06-03)]


==== Patched ====
On PS4 FWs 9.00-9.04 the constructor returns with an exception, but to C++ code that ignores it. That is how an invalid font is created in the first place. On earlier PS4 FWs the exception is propagated to JavaScript.
'''Yes''' on PS4 FW 11.50 and PS5 FW 9.00.


==== Tested ====
==== Exploit Implementation ====
Tested working on PS4 FWs 10.00-11.02 and PS5 FWs 6.00-8.60. PS4 FWs <= ?9.60? and PS5 FWs <= ?5.50? are invulnerable.
* [https://web.archive.org/web/20211024215236/http://vdsina.sleirsgoevy.dynv6.net:8081/ (archive) First exploit PoC for Safari by sleirsgoevy (2021-10-24)]
* [https://gist.github.com/sleirsgoevy/6beca32893909095f4bba1ce29167992 First exploit PoC for PS4 FW 9.00-9.04 and PS5 FW 3.00-4.51 by sleirsgoevy (2021-10-27)]
* [https://github.com/ChendoChap/pOOBs4/blob/main/webkit.js Implementation for PS4 FW 9.00 with exFAT kernel exploit in pOOBs4 by ChendoChap (2022-01-17)]
 
==== Patched ====
'''Yes''' on PS4 FW 9.50 and '''No''' as of PS5 FW 4.51 (need to test on PS5 FWs >=5.00). Not working on PS4 FWs <9.00 and PS5 FWs <2.10.
 
Might have been introduced in PS4 FW 3.50 and before PS5 FW 1.00 according to dates (need to check). However the vulnerability cannot be exploited in some conditions depending on how WebKit was compiled. For example, on PS4 FWs 7.55-8.52 and PS5 FWs <= 2.00, the FontFaceSet constructor returns with an exception that is propagated to JavaScript, preventing exploitation this way.
 
==== Tested ====
Tested working on PS4 FWs 9.00-9.04 and PS5 FWs 3.00-4.51. Untested: PS5 FWs 2.10-2.70 and >=5.00.
----
----


=== FW 6.00-9.60 - FrameLoader::loadInSameDocument() UaF (CVE-2022-22620) leading to arbitrary RW ===
=== FW 6.00-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Sergei Glazunov, Google Project Zero, for reporting the bug in 2013-01 and answering Maddie Stone's questions in 2022 (2013)
* 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 ([https://www.blackhat.com/eu-20/briefings/schedule/index.html#this-is-for-the-pwners--exploiting-a-webkit--day-in-playstation--21212]) and sharing the code (2020-12-10)
* Maddie Stone, Google Project Zero, for sharing a write-up describing this vulnerability (2022-06-14)
* sleirsgoevy for porting (although with low success rate) to PS4 FWs 7.00-7.02
* abc (anonymous) for making an OOM PoC for webkit-gtk, PS4 and PS5 (2023-10-03) then making an arbitrary RW PoC (PSFree) for webkit-gtk, PS4 6.00-9.60 and PS5 1.00-5.50 (2023-10-24)
* CelesteBlue for testing and porting abc' PSFree to PS4 6.00-9.60 and PS5 1.00-5.50 (2023-11-04)


==== Analysis ====
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/aa31b6b4d09b09acdf1cec11f2f7f35bd362dd0e WebKit bug-reintroducing commit by Darin Adler reviewed by Alex Christensen (2016-12-31)]
* [https://github.com/WebKit/WebKit/commit/b99f0737d0bbcbc52c4b6e6edadcf4990173191f WebKit bad fix commit (2019-05-28)]
* [https://bugs.webkit.org/show_bug.cgi?id=235551 WebKit fix talk by Yusuke Suzuki reviewed by Mark Lam (2022-01-24)]
* [https://github.com/WebKit/WebKit/commit/b5d5412d9f517e25304aadb1b20dd5118a2c387d WebKit good fix commit (2020-09-11)]
* [https://github.com/WebKit/WebKit/commit/486816dc355c19f1de1b8056f85d0bbf7084dd6e WebKit fix commit by Yusuke Suzuki reviewed by Mark Lam (2022-01-25)]
* [https://www.synacktiv.com/publications/this-is-for-the-pwners-exploiting-a-webkit-0-day-in-playstation-4.html Write-up by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)]
* [https://googleprojectzero.github.io/0days-in-the-wild/0day-RCAs/2022/CVE-2022-22620.html Short writeup by Maddie Stone (2022-06-14)]
* [http://i.blackhat.com/eu-20/Thursday/eu-20-Meffre-This-Is-For-The-Pwners-Exploiting-A-Webkit-0day-In-Playstation4.pdf Presentation slides by by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)]
* [https://googleprojectzero.blogspot.com/2022/06/an-autopsy-on-zombie-in-wild-0-day.html Detailed writeup by Maddie Stone (2022-06-14)]


==== Bug Description ====
==== Bug Description ====
The History API allows access to (and modification of) a stack of the pages visited in the current frame, and these page states are stored as a <code>SerializedScriptValue</code>. The History API exposes a getter for state, and a method <code>replaceState()</code> which allows overwriting the "most recent" history entry.
* 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.


The bug is that <code>FrameLoader::loadInSameDocument()</code> takes the state as an argument (<code>stateObject</code>), but does not increase its reference count. Only a <code>HistoryItem</code> object holds a reference to the <code>stateObject</code>. <code>loadInSameDocument()</code> can trigger a callback into user JavaScript through the <code>onblur</code> event. The user's callback can call <code>replaceState()</code> to replace the <code>HistoryItem</code>'s state with a new object, therefore dropping the only reference to the <code>stateObject</code>. When the callback returns, <code>loadInSameDocument()</code> will still use this free'd object in its call to <code>statePopped()</code>, leading to the use-after-free.
* ValidationMessage::buildBubbleTree is doing layout which can run a script detaching the owner form element, and this ValidationMessage object can be destroyed.


When <code>loadInSameDocument()</code> is called it changes the focus to the element its scrolling to. If we set the focus on a different element prior to <code>loadInSameDocument()</code>'s execution, the blur event will be fired on that element. Then we can free the <code>stateObject</code> by calling <code>replaceState()</code> in the <code>onblur</code> event handler.
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.


The bug is triggered by <code>history.back()</code> with the target state whose URL contains a hash. Here's a Proof-of-Concept that will crash:
==== Exploit Implementation ====
<source lang="js">
* [https://github.com/synacktiv/PS4-webkit-exploit-6.XX Initial 6.xx implementation by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-11-12]
input = document.body.appendChild(document.createElement('input'));
* [https://github.com/sleirsgoevy/PS4-webkit-exploit-7.02 7.02 implementation with code execution by sleirsgoevy (2020-12-15)]
* [https://github.com/sleirsgoevy/ps4jb 6.72-7.02 Kernel exploit using this WebKit exploit by sleirsgoevy (2020-12-16)]
* [https://github.com/ChendoChap/ps4-ipv6-uaf/tree/7.00-7.02 7.00-7.02 Kernel exploit using this WebKit exploit by ChendoChap (2020-12-16)]


foo = document.body.appendChild(document.createElement('a'));
==== Patched ====
foo.id = 'foo';
'''Yes''' in 8.00 FW.


function pop(event) {
==== Tested ====
    alert('you get a crash after you close this alert');
Tested working on FWs 6.00-7.55, not working on FWs <= 5.56. HTML textarea guessed addresses for FWs 6.70-7.55 are known but not for FWs 6.00-6.51 so an attacker needs to make tests to determine these addresses on FWs 6.00-6.51.
    event.state; // use the freed SerializedScriptValue
----
    alert('WebKit version not vulnerable');
}


addEventListener('popstate', pop);
=== FW 6.00-6.72 - bad_hoist Type Confusion exploit (CVE-2018-4386) leading to arbirary RW ===


history.pushState('state1', '', location + '#foo'); // URL with a hash
==== Credits ====
history.pushState('state2', '');
* 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)


setTimeout(() => {
==== Analysis ====
    input.focus();
* https://bugs.chromium.org/p/project-zero/issues/detail?id=1665
    input.onblur = () => {
* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-4386
        history.replaceState('state3', '')
* https://packetstormsecurity.com/files/155871/Sony-Playstation-4-Webkit-Code-Execution.html
    };
* https://twitter.com/Fire30_/status/1211775229116211200
    setTimeout(() => {
        history.back(); // trigger loadInSameDocument()
    }, 1000);
}, 1000);


</source>
==== Bug Description ====
The user may then trigger a double free and escalate it into an arbitrary read primitive via spraying <code>WTF::StringImpl</code>s like in the <code>buildBubbleTree()</code> UaF exploit. The read primitive is used to create the <code>addrof()</code> primitive and is used to save addresses of buffers that will be used to modify a <code>SerializedScriptValue</code>. After freeing the StringImpl (triple free), <code>SerializedScriptValue</code>s are sprayed via the <code>postMessage()</code> JavaScript function until one is allocated using the previously freed memory.
WebKit: JSC: BytecodeGenerator::hoistSloppyModeFunctionIfNecessary does not invalidate the ForInContext object.


The method used to modify the fields of the <code>StringImpl</code> for arbitrary reads can be used can also be used to modify the <code>SerializedScriptValue</code>. Appropriate fields can modified to have deserialization create a <code>JSC::JSArrayBufferView</code> whose <code>m_vector</code> field will point to another <code>JSArrayBufferView</code>, which  will be called the worker. The user can modify the worker's fields for arbitrary read/write. Deserialization is done via <code>msg.data</code> where <code>msg</code> is the <code>MessageEvent</code> from <code>postMessage()</code>.
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.


A way to know if the system is vulnerable is the appearance of the input HTML element in the PoC page. If the HTML input field stays focused (blue outline) after the second timeout, then the vulnerability is not present. Note that Maddie Stone's PoC will never trigger any sort of crash on release builds as it was meant for builds with memory sanitation that can detect UaFs.
This is a Type Confusion exploit.


==== Exploit Implementation ====
==== Exploit Implementation ====
* Simple PoC for ASAN webkit-gtk by Maddie Stone in Maddie Stone's writeups
* [https://github.com/Fire30/bad_hoist Initial implementation by Fire30]
* [https://github.com/springsec/CVE-2022-22620/blob/main/CVE-2022-22620_infoleak_exploit.html Information leak PoC for webkit-gtk by springsec]
* [https://github.com/sleirsgoevy/bad_hoist Implementation with code execution by sleirsgoevy]
* [https://discord.com OOM PoC for PS4 and PS5 by abc on ps4-dev discord (to mirror)]
* [https://discord.com Arbitrary RW PoC (PSFree) for PS4 6.00-9.60 and PS5 1.00-5.50 by abc on ps4-dev discord (to mirror)]


==== Patched ====
==== Patched ====
'''Yes''' on PS4 FW 10.00 and PS5 FW 6.00.
'''Yes''' in 7.00 FW
 
The patch changes the stateObject argument to loadInSameDocument from a raw pointer, SerializedScriptValue*, to a reference-counted pointer, RefPtr<SerializedScriptValue>, so that loadInSameDocument now increments the reference count on the object.
 
==== Tested ====
Tested working on PS4 FWs 6.00-9.60 and PS5 FWs 1.00-5.50. PS4 FWs <= 5.56 are invulnerable as the HTML input field stays focused (blue outline) after second timeout whilst it should not if the console were exploitable.
----
----


=== FW 9.00-9.04 - WebCore::CSSFontFaceSet vulnerabilities leading to arbitrary RW ===
=== FW 4.50-6.72 - DOMWindow::open heap UaF (CVE-2021-30849) leading to crash ===
 
There are many FontFaceSet vulnerabilities. Explore [https://trac.webkit.org/search?q=mmaxfield%40apple.com+FontFaceSet&noquickjump=1&changeset=on].


==== Credits ====
==== Credits ====
* Myles C. Maxfield (litherum), Apple, for adding the vulnerability in WebKit (2016-02-22) then fixing and so disclosing the vulnerability (2021-08-26)
* Sergei Glazunov (from Google Project Zer0) for the exploit PoC (Jul 1, 2021)
* Maddie Stone, Google Project Zero, for sharing 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)
* sleirsgoevy for making the first exploit PoC for Safari (2021-10-24) and the first exploit PoC for PS4 FW 9.00-9.04 and PS5 FW 3.00-4.50 (2021-10-27)


==== Analysis ====
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/d5dbfd02054e9f904b27224a598ca1bb8ded5f87 WebKit bug-introducing commit by Myles C. Maxfield - r256659 (2016-02-22)]
* https://bugs.chromium.org/p/project-zero/issues/detail?id=2204
* [https://trac.webkit.org/changeset/281648/webkit WebKit fix commit by Myles C. Maxfield - r281648 (2021-08-26)]
 
* [https://github.com/WebKit/WebKit/commit/b22be72a013442ca9d1ff4bf3aa8aa436f78f142 WebKit commit adding FontFace tests (2021-09-01)]
* [https://bugs.webkit.org/show_bug.cgi?id=229848 WebKit Bugzilla - Bug 229848 - FontFaceSet.has() needs to react to style changes by Myles C. Maxfield (2021-09-02)]
* [https://github.com/web-platform-tests/wpt/pull/30322#issue-726455679 web-platform-tests - Add a test for FontFaceSet.has() #30322 (2021-09-03)]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1729089#c4 Mozilla Bugzilla - New wpt failures in /css/css-font-loading/fontfaceset-has.html (with TypeError `fonts.keys() is not iterable`, due to FontFaceSetIterator not behaving like an Iterable) (2021-09-03)]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1729997 Mozilla Bugzilla - FontFaceSet's iterators skip items when previous items are removed by Myles C. Maxfield (2021-09-09)]
* [https://bugs.webkit.org/show_bug.cgi?id=230119 WebKit Bugzilla - Bug 230119 - FontFaceSet's iterators skip items when previous items are removed by Myles C. Maxfield (2021-09-09)]
* [https://github.com/WebKit/WebKit/commit/fbf37d27e313d8d0a150a74cc8fab956eb7f3c59 WebKit fix commit by Myles C. Maxfield merged by Russell Epstein (2021-09-09)]
* [https://github.com/WebKit/WebKit/blob/74bd0da94fa1d31a115bc4ee0e3927d8b2ea571e/Source/WebCore/css/CSSFontFaceSet.cpp#L223 Part of vulnerable code]
* [https://web.archive.org/web/20211020134808/https://googleprojectzero.github.io/0days-in-the-wild//0day-RCAs/2021/CVE-2021-30858.html (archive) Write-up and PoC by Maddie Stone (2021-10-13)]. Maddie Stone's vulnerability is not CVE-2021-30858 but instead might be CVE-2021-30889. See [https://github.com/googleprojectzero/0days-in-the-wild/commit/65fcdf0473ada4e80dc967662ea8f3f3ce4ea81e#diff-1a428c43cedcf140e5bd6f92e4527f169c3c717780e1586f2fab589e4f467b52 write-up edit commit]. Warning: Maddie Stone's vulnerability was wrongly classified as a use-after-free by Maddie Stone according to sleirsgoevy.
* [https://wololo.net/2021/10/14/use-after-free-webkit-vulnerability-impacts-ps4-possibly-up-to-firmware-9-00-included/ Vulnerability description by Wololo (2021-10-14)]
 
==== Bug Description ====
==== Bug Description ====
Description in WebKit fix commit by Myles C. Maxfield:


After r256659, asking for a failed CSSFontFace's families() returns nullopt. It is possible to add a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed and do not update our internal data structures, because there's no need to - we cannot do anything useful with a failed font. If you _then_ try to remove the font from the CSSFontFace, we do not call families(), but instead just pull out the raw m_families member, and look in our internal data structures for it, but we do not find it, because it was never added.
==== Exploit Implementation ====


Description in Maddie Stone's write-up:
==== Patched ====
'''Yes''' in 7.00 FW.


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 do not 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.
==== Tested ====
Vulnerable on PS4 FWs 4.50-6.72. Not vulnerable on FWs <= 4.07. Not vulnerable on FWs >=7.00 according to manual tests but need to check WebKit sources.
----


Description by sleirsgoevy:
=== FW 4.50-6.20 - JSArray::shiftCountWithArrayStorage() OOB RW (CVE-2018-4441) leading to arbitrary RW ===


On PS4 FWs 9.00-9.04 the constructor returns with an exception, but to C++ code that ignores it. That is how an invalid font is created in the first place. On earlier PS4 FWs the exception is propagated to JavaScript.
==== 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 ====
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1685 Bug report by Lokihardt (Oct 3, 2018)]
* [https://github.com/WebKit/webkit/commit/51a62eb53815863a1bd2dd946d12f383e8695db0 WebKit fix commit (Oct 15, 2018)]
* [https://mastodon.social/@buherator/101654714198519755 Announce of incoming write-up by rkmylo and buherator/stratan/@5tratan, Meligra Team (Feb 25, 2019)]
* [https://rstforums.com/forum/topic/110439-cve-2018-4441-oob-rw-via-jsarrayunshiftcountwitharraystorage-webkit/ Write-up mirrored by Nytro (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 ====
==== Exploit Implementation ====
* [https://web.archive.org/web/20211024215236/http://vdsina.sleirsgoevy.dynv6.net:8081/ (archive) First exploit PoC for Safari by sleirsgoevy (2021-10-24)]
* [https://github.com/Cryptogenic/PS4-6.20-WebKit-Code-Execution-Exploit PS4 6.20 WebKit exploit by Specter]
* [https://gist.github.com/sleirsgoevy/6beca32893909095f4bba1ce29167992 First exploit PoC for PS4 FW 9.00-9.04 and PS5 FW 3.00-4.51 by sleirsgoevy (2021-10-27)]
* [https://github.com/ChendoChap/pOOBs4/blob/main/webkit.js Implementation for PS4 FW 9.00 with exFAT kernel exploit in pOOBs4 by ChendoChap (2022-01-17)]


==== Patched ====
==== Patched ====
'''Yes''' on PS4 FW 9.50 and '''No''' as of PS5 FW 4.51 (need to test on PS5 FWs >=5.00). Not working on PS4 FWs <9.00 and PS5 FWs <2.10.
'''Yes''' in 6.50 FW.
 
Might have been introduced in PS4 FW 3.50 and before PS5 FW 1.00 according to dates (need to check). However the vulnerability cannot be exploited in some conditions depending on how WebKit was compiled. For example, on PS4 FWs 7.55-8.52 and PS5 FWs <= 2.00, the FontFaceSet constructor returns with an exception that is propagated to JavaScript, preventing exploitation this way.


==== Tested ====
==== Tested ====
Tested working on PS4 FWs 9.00-9.04 and PS5 FWs 3.00-4.51. Untested: PS5 FWs 2.10-2.50 and >=5.00.
It does not work on <= 4.07 FW PS4 according to tests as the exploit fails at step "Triggering memory corruption".
----
----


=== FW 6.00-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW ===
=== FW 6.00-6.20 - JSC::arrayProtoPrivateFuncConcatMemcpy() Information Leak (CVE-2018-4358) ?leading to ASLR defeat? ===


==== Credits ====
==== 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 ([https://www.blackhat.com/eu-20/briefings/schedule/index.html#this-is-for-the-pwners--exploiting-a-webkit--day-in-playstation--21212]) and sharing the code (2020-12-10)
* bkth, niklasb and saelo (from phoenhex Team) for the exploit PoC in Safari (Sep 26, 2018)
* sleirsgoevy for porting (although with low success rate) to PS4 FWs 7.00-7.02
* Vultra for discovering that the exploit worked on PS4 FW 6.00 (Dec 10, 2018)


==== Analysis ====
==== Analysis ====
* [https://github.com/WebKit/WebKit/commit/b99f0737d0bbcbc52c4b6e6edadcf4990173191f WebKit bad fix commit (2019-05-28)]
* Related: https://bugs.chromium.org/p/project-zero/issues/detail?id=1032
* [https://github.com/WebKit/WebKit/commit/b5d5412d9f517e25304aadb1b20dd5118a2c387d WebKit good fix commit (2020-09-11)]
* Related: https://doar-e.github.io/blog/2018/07/14/cve-2017-2446-or-jscjsglobalobjectishavingabadtime/
* [https://www.synacktiv.com/publications/this-is-for-the-pwners-exploiting-a-webkit-0-day-in-playstation-4.html Write-up by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)]
* https://github.com/WebKit/webkit/commit/b68b373dcbfbc68682ceeca8292c5c0051472071
* [http://i.blackhat.com/eu-20/Thursday/eu-20-Meffre-This-Is-For-The-Pwners-Exploiting-A-Webkit-0day-In-Playstation4.pdf Presentation slides by by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-12-10)]
* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-4358
* https://phoenhex.re/2018-09-26/safari-array-concat


==== Bug Description ====
==== 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 ====
==== Exploit Implementation ====
* [https://github.com/synacktiv/PS4-webkit-exploit-6.XX Initial 6.xx implementation by Quentin Meffre (@0xdagger) and Mehdi Talbi (@abu_y0ussef) (2020-11-12]
* [https://github.com/externalist/exploit_playground/blob/master/jsc_ConcatMemcpy_infoleak/ileak.html PoC for iOS]
* [https://github.com/sleirsgoevy/PS4-webkit-exploit-7.02 7.02 implementation with code execution by sleirsgoevy (2020-12-15)]
* [https://github.com/Josephmh97/PS4_jsc_ConcatMemcpy_POC PoC for PS4]
* [https://github.com/sleirsgoevy/ps4jb 6.72-7.02 Kernel exploit using this WebKit exploit by sleirsgoevy (2020-12-16)]
* [https://github.com/ChendoChap/ps4-ipv6-uaf/tree/7.00-7.02 7.00-7.02 Kernel exploit using this WebKit exploit by ChendoChap (2020-12-16)]


==== Patched ====
==== Patched ====
'''Yes''' in 8.00 FW.
'''Yes''' in 6.50 FW


==== Tested ====
==== Tested ====
Tested working on FWs 6.00-7.55, not working on FWs <= 5.56. HTML textarea guessed addresses for FWs 6.70-7.55 are known but not for FWs 6.00-6.51 so an attacker needs to make tests to determine these addresses on FWs 6.00-6.51.
Works on 6.00-6.20. Not working on PS4 FWs <= 5.56 because JSC (JavaScriptCore) was too old.
----
----


=== FW 6.00-6.72 - bad_hoist Type Confusion exploit (CVE-2018-4386) leading to arbirary RW ===
=== FW 4.50-5.56 - JSGlobalObject::haveABadTime() Type Confusion (CVE-2017-7005) leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Lokihardt (from Google Project Zer0) for the exploit PoC (Sep 13, 2018)
* Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 20, 2017)
* Fire30 for turning the vulnerability into exploit for PS4 (Dec 30, 2019)
* ALEXZZZ9 for the first PS4 implementation (on 5.01), and at same time for burning the exploit (Feb 20, 2018)
* sleirsgoevy for attempting to stabilize the PS4 exploit with a new implementation (Feb 23, 2020)
* qwertyoruiop for rewriting and porting to 5.05 and 5.50


==== Analysis ====
==== Analysis ====
* https://bugs.chromium.org/p/project-zero/issues/detail?id=1665
[https://bugs.chromium.org/p/project-zero/issues/detail?id=1208 Project Zer0 Bug Description]
* 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 ====
==== Bug Description ====
WebKit: JSC: BytecodeGenerator::hoistSloppyModeFunctionIfNecessary does not invalidate the ForInContext object.
When JSGlobalObject::haveABadTime() is called with arrays of a different JSGlobalObject type, type confusion can occur, leading to memory corruption.
 
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 ====
==== Exploit Implementation ====
* [https://github.com/Fire30/bad_hoist Initial implementation by Fire30]
* [https://github.com/ALEXZZZ9/PS4-5.01-WebKit-Exploit-PoC]
* [https://github.com/sleirsgoevy/bad_hoist Implementation with code execution by sleirsgoevy]
* [http://crack.bargains/550/ PS4 5.50 (WebKit Only)]
* [https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit/blob/master/expl.js]


==== Patched ====
==== Patched ====
'''Yes''' in 7.00 FW
'''Yes''' in 6.00 FW
----
----


=== FW 4.50-6.72 - DOMWindow::open heap UaF (CVE-2021-30849) leading to crash ===
=== FW ?.??-4.05-5.56 - Document::adoptNode() UaF (CVE-2017-2468) leading to crash ===


==== Credits ====
==== Credits ====
* Sergei Glazunov (from Google Project Zer0) for the exploit PoC (Jul 1, 2021)
* Lokihardt (from Google Project Zer0) for the exploit PoC (Jan 23, 2017)
* CelesteBlue for testing on PS4 and PS Vita (May 9, 2020)


==== Analysis ====
==== Analysis ====
* https://bugs.chromium.org/p/project-zero/issues/detail?id=2204
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1099 exploit report by Lokihardt (Jan 23, 2017)]
* [https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-2468 Mitre report]
* [https://www.exploit-db.com/exploits/41868 exploitDB report]
* [https://github.com/0xR0/uxss-db/tree/master/webkit/CVE-2017-2468 Mirror of report and PoC]
* [https://bugs.chromium.org/p/chromium/issues/detail?id=541206 Similar bug (CVE-2015-6770) with similar PoC (Oct 8, 2015)]


==== Bug Description ====
==== Bug Description ====


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/Metnew/uxss-db/tree/master/webkit/CVE-2017-2468 PoC that just crashes on PS4 FW 4.05-5.56 and PS Vita FW 3.60]


==== Patched ====
==== Patched ====
'''Yes''' in 7.00 FW.
'''Yes''' in 6.00 FW. Vulnerable at least on PS4 FWs 4.05-5.56 and PS Vita FW 3.60.
 
==== Tested ====
Vulnerable on PS4 FWs 4.50-6.72. Not vulnerable on FWs <= 4.07. Not vulnerable on FWs >=7.00 according to manual tests but need to check WebKit sources.
----
----


=== FW 4.50-6.20 - JSArray::shiftCountWithArrayStorage() OOB RW (CVE-2018-4441) leading to arbitrary RW ===
=== FW 4.50-5.56 - WebCore::HTMLFrameElementBase::marginHeight() Heap UaF (CVE-2016-1859) leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Lokihardt (from Google Project Zer0) for the exploit PoC (Oct 3, 2018)
* Liang Chen, wushi of KeenLab, Tencent working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-03-16)
* Specter for the rewriting for PS4 (Mar 8, 2019)
* St4rk for helping Specter


==== Analysis ====
==== Analysis ====
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1685 Bug report by Lokihardt (Oct 3, 2018)]
* [https://nvd.nist.gov/vuln/detail/CVE-2016-1859 NVD description of CVE-2016-1859 (May 5, 2016)]
* [https://github.com/WebKit/webkit/commit/51a62eb53815863a1bd2dd946d12f383e8695db0 WebKit fix commit (Oct 15, 2018)]
* [https://www.zerodayinitiative.com/advisories/ZDI-16-352/ ZDI advisory for CVE-2016-1859 (May 20, 2016)]
* [https://mastodon.social/@buherator/101654714198519755 Announce of incoming write-up by rkmylo and buherator/stratan/@5tratan, Meligra Team (Feb 25, 2019)]
* [https://www.blackhat.com/docs/us-16/materials/us-16-Molinyawe-Shell-On-Earth-From-Browser-To-System-Compromise-wp.pdf Writeup by Matt Molinyawe, Abdul-Aziz Hariri, and Jasiel Spelman (Trend Micro) (August 1, 2016)]
* [https://rstforums.com/forum/topic/110439-cve-2018-4441-oob-rw-via-jsarrayunshiftcountwitharraystorage-webkit/ Write-up mirrored by Nytro (Feb 27, 2019)]
* [http://arayz.github.io/933ky/A-general-attack-model-of-UAF-on-browser/ Writeup by Arayz (Wang Ao) (March 31, 2017)]
* [https://daehee87.github.io/data/ruma.pdf On the Analysis of Byte-Granularity Heap Randomization (October 24, 2019)]


==== Bug Description ====
==== 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.
The specific flaw exists within the handling of GraphicsContext objects. By manipulating a document's elements an attacker can force this object in memory to be reused after it has been freed. An attacker can leverage this vulnerability to execute code under the context of the current process.
 
CVE-2016-1859 is a use-after-free vulnerability that existed in the Safari web browser. A GraphicsContext object is used in the setPlatformTextDrawingMode function after it has been freed. The successful triggering of the use-after-free vulnerability itself does not allow the attacker to directly change the control flow or disclose arbitrary memory contents. However, the use-after-free yields an arbitrary-memory-write primitive by hijacking a destination pointer that will be used for the memcpy function. Once the arbitrary-memory-write primitive is achieved, the attacker sprays the heap with string objects to achieve the arbitrary-memory-read primitive. Relying on the pointer width heap alignment, the attacker can accurately predict the exact address of one of the string objects among the heap spray and pinpoint the address of member variable. At this point, the attacker can overwrite the length member variable of a string object and partially disclose the out-of-bound heap area exceeding the buffer address of the string. The partial disclosure of the heap memory allows the attacker to extend the information leak step-by-step and ultimately allows full chaining of ROP, which leads to arbitrary code execution.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/Cryptogenic/PS4-6.20-WebKit-Code-Execution-Exploit PS4 6.20 WebKit exploit by Specter]
* PoC publicly available
* No full exploit publicly available but exploitation description is detailed


==== Patched ====
==== Patched ====
'''Yes''' in 6.50 FW.
'''Yes''' in 6.00 FW. Vulnerable on PS4 FWs 4.50-5.56.
 
==== Tested ====
It does not work on <= 4.07 FW PS4 according to tests as the exploit fails at step "Triggering memory corruption".
----
----


=== FW 6.00-6.20 - JSC::arrayProtoPrivateFuncConcatMemcpy() Information Leak (CVE-2018-4358) ?leading to ASLR defeat? ===
=== FW 4.50-5.01 - Element::setAttributeNodeNS() UaF leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* bkth, niklasb and saelo (from phoenhex Team) for the exploit PoC in Safari (Sep 26, 2018)
* Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 15, 2017)
* Vultra for discovering that the exploit worked on PS4 FW 6.00 (Dec 10, 2018)
* qwertyoruiop for the PS4 exploit (October 2017)
* Specter for the writeup (May 27, 2018)


==== Analysis ====
==== Analysis ====
* Related: https://bugs.chromium.org/p/project-zero/issues/detail?id=1032
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1187 exploit report by Lokihardt (Mar 15, 2017)]
* Related: https://doar-e.github.io/blog/2018/07/14/cve-2017-2446-or-jscjsglobalobjectishavingabadtime/
* [https://twitter.com/VVildCard777/status/919843554964443137 First test on PS4 by WildCard (Oct 16, 2017)]
* https://github.com/WebKit/webkit/commit/b68b373dcbfbc68682ceeca8292c5c0051472071
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/WebKit/setAttributeNodeNS%20UAF%20Write-up.md Specter's setAttributeNodeNS Exploit Writeup]
* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-4358
* https://phoenhex.re/2018-09-26/safari-array-concat


==== Bug Description ====
==== 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 ====
==== Exploit Implementation ====
* [https://github.com/externalist/exploit_playground/blob/master/jsc_ConcatMemcpy_infoleak/ileak.html PoC for iOS]
[https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit PS4 5.05 WebKit + Kernel Exploit]
* [https://github.com/Josephmh97/PS4_jsc_ConcatMemcpy_POC PoC for PS4]


==== Patched ====
==== Patched ====
'''Yes''' in 6.50 FW
'''Yes''' in 5.03 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 ===
=== FW 3.15-4.07 - Stack Uninitialized Read UaF leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 20, 2017)
* qwertyoruiop for the exploit
* ALEXZZZ9 for the first PS4 implementation (on 5.01), and at same time for burning the exploit (Feb 20, 2018)
* Specter for the writeup
* qwertyoruiop for rewriting and porting to 5.05 and 5.50


==== Analysis ====
==== Analysis ====
[https://bugs.chromium.org/p/project-zero/issues/detail?id=1208 Project Zer0 Bug Description]
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/4.0x%20WebKit%20Exploit%20Writeup.md Specter's 4.0x WebKit Exploit Writeup]


==== Bug Description ====
==== Bug Description ====
When JSGlobalObject::haveABadTime() is called with arrays of a different JSGlobalObject type, type confusion can occur, leading to memory corruption.
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 ====
==== Exploit Implementation ====
* [https://github.com/ALEXZZZ9/PS4-5.01-WebKit-Exploit-PoC]
* [https://github.com/Cryptogenic/PS4-4.0x-Code-Execution-PoC Specter's commented and usable version]
* [http://crack.bargains/550/ PS4 5.50 (WebKit Only)]
* [https://gist.github.com/X41/36acd2a6939e4cebbecba45d35bf0d75 mirrorred expl.js from qwertyoruiop]
* [https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit/blob/master/expl.js]


==== Patched ====
==== Patched ====
'''Yes''' in 6.00 FW
'''Yes''' in 4.50 FW
 
==== Tested ====
Works on 3.15-4.07. Not working on <= 3.11.
----
----


=== FW ?.??-4.05-5.56 - Document::adoptNode() UaF (CVE-2017-2468) leading to crash ===
=== FW <= ?4.05? - Type confusion in WebCore::HTMLInputElement::onSearch (CVE-2017-2354) ===


==== Credits ====
==== Credits ====
* Lokihardt (from Google Project Zer0) for the exploit PoC (Jan 23, 2017)
* Neymar of Tencent's Xuanwu Lab working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-11)
* CelesteBlue for testing on PS4 and PS Vita (May 9, 2020)
* Brent Fulgham for fixing the bug in WebKit (2016-11-14)
* Jasiel Spelman (@WanderingGlitch) for his writeup (2017-12-20)


==== Analysis ====
==== Analysis ====
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1099 exploit report by Lokihardt (Jan 23, 2017)]
* [https://www.zerodayinitiative.com/blog/2017/12/20/invariantly-exploitable-input-an-apple-safari-bug-worth-revisiting Writeup by Jasiel Spelman (2017-12-20)]
* [https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-2468 Mitre report]
* [https://github.com/WebKit/WebKit-http/commit/cf2bf6e58f51267d7ae25fcb82a315377c8e5cf6 WebKit fix commit by Brent Fulgham (2016-11-14)]
* [https://www.exploit-db.com/exploits/41868 exploitDB report]
* [https://github.com/0xR0/uxss-db/tree/master/webkit/CVE-2017-2468 Mirror of report and PoC]
* [https://bugs.chromium.org/p/chromium/issues/detail?id=541206 Similar bug (CVE-2015-6770) with similar PoC (Oct 8, 2015)]


==== Bug Description ====
==== Bug Description ====
It is possible for JavaScript to change the type property of an input field. WebKit needs to gracefully handle this case.


==== Exploit Implementation ====
This bug could have been prevented had it a debug check been used instead of a runtime check. In fact, WebKit has support for this type of assertion already through a RELEASE_ASSERT macro, which would have turned this exploitable bug into a simple denial-of-service by immediately and safely crashing the browser.
* [https://github.com/Metnew/uxss-db/tree/master/webkit/CVE-2017-2468 PoC that just crashes on PS4 FW 4.05-5.56 and PS Vita FW 3.60]


==== Patched ====
The fix commit of the vulnerability adds a type traits specialization so that WebKit can properly downcast InputType elements. This should be used only to call search functions on actual search input types.
'''Yes''' in 6.00 FW. Vulnerable at least on PS4 FWs 4.05-5.56 and PS Vita FW 3.60.
----


=== FW 4.50-5.56 - WebCore::HTMLFrameElementBase::marginHeight() Heap UaF (CVE-2016-1859) leading to arbitrary RW ===
Although the access violation in WebCore::TimerBase::heapPop is where we see the result of the bug, it is not the cause of the issue. The crash actually occurs as a result of reading a pointer that comes from the 'this' object. Based on that, it would seem that something is wrong with the Timer object passed into the WebCore::TimerBase::heapPop function.


==== Credits ====
This vulnerability may be the one used by Chaintin Tech with a kernel exploit on PS4 FW 4.01 at GeekPwn 2016, a Tencent Security's conference, in Shanghai Station at the Pavilion Safety Research Lab, (https://www.chaitin.cn/ps4, https://www.psxhax.com/threads/ps4-4-01-linux-installation-ksploit-demo-at-geekpwn-2016.932/)
* Liang Chen, wushi of KeenLab, Tencent working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-03-16)
 
==== Analysis ====
* [https://nvd.nist.gov/vuln/detail/CVE-2016-1859 NVD description of CVE-2016-1859 (May 5, 2016)]
* [https://www.zerodayinitiative.com/advisories/ZDI-16-352/ ZDI advisory for CVE-2016-1859 (May 20, 2016)]
* [https://www.blackhat.com/docs/us-16/materials/us-16-Molinyawe-Shell-On-Earth-From-Browser-To-System-Compromise-wp.pdf Writeup by Matt Molinyawe, Abdul-Aziz Hariri, and Jasiel Spelman (Trend Micro) (August 1, 2016)]
* [http://arayz.github.io/933ky/A-general-attack-model-of-UAF-on-browser/ Writeup by Arayz (Wang Ao) (March 31, 2017)]
* [https://daehee87.github.io/data/ruma.pdf On the Analysis of Byte-Granularity Heap Randomization (October 24, 2019)]
 
==== Bug Description ====
The specific flaw exists within the handling of GraphicsContext objects. By manipulating a document's elements an attacker can force this object in memory to be reused after it has been freed. An attacker can leverage this vulnerability to execute code under the context of the current process.
 
CVE-2016-1859 is a use-after-free vulnerability that existed in the Safari web browser. A GraphicsContext object is used in the setPlatformTextDrawingMode function after it has been freed. The successful triggering of the use-after-free vulnerability itself does not allow the attacker to directly change the control flow or disclose arbitrary memory contents. However, the use-after-free yields an arbitrary-memory-write primitive by hijacking a destination pointer that will be used for the memcpy function. Once the arbitrary-memory-write primitive is achieved, the attacker sprays the heap with string objects to achieve the arbitrary-memory-read primitive. Relying on the pointer width heap alignment, the attacker can accurately predict the exact address of one of the string objects among the heap spray and pinpoint the address of member variable. At this point, the attacker can overwrite the length member variable of a string object and partially disclose the out-of-bound heap area exceeding the buffer address of the string. The partial disclosure of the heap memory allows the attacker to extend the information leak step-by-step and ultimately allows full chaining of ROP, which leads to arbitrary code execution.


==== Exploit Implementation ====
==== Exploit Implementation ====
* PoC publicly available
* PoC by Neymar (2016-11, disclosed publicly by Jasiel Spelman on 2017-12-20):
* No full exploit publicly available but exploitation description is detailed
<source lang="js">
 
<input id="m_input" type="search"></input>
==== Patched ====
<script type="text/javascript">
'''Yes''' in 6.00 FW. Vulnerable on PS4 FWs 4.50-5.56.
first = true;
m_input.addEventListener("input", function (e) {
if(first) {
first = false;
}
else {
m_input["type"] = "image";
}
}, false);
</script>
</source>
* [https://github.com/WebKit/WebKit-http/blob/master/LayoutTests/fast/forms/search-cancel-button-change-input.html Vulnerability test by Brent Fulgham (2016-11-15)]
 
==== Patched ====
'''Maybe''' in 4.06 FW
 
==== Tested ====
Not yet.
----
----


=== FW 4.50-5.01 - Element::setAttributeNodeNS() UaF leading to arbitrary RW ===
=== FW 3.15-3.70 - JSArray::sortCompactedVector() Heap UaF leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Lokihardt (from Google Project Zer0) for the exploit PoC (Mar 15, 2017)
* xyz for the original exploit on PSVita (HENkaku)
* qwertyoruiop for the PS4 exploit (October 2017)
* Fire30 for porting to PS4
* Specter for the writeup (May 27, 2018)
* Specter for improved PS4 playground


==== Analysis ====
==== Analysis ====
* [https://bugs.chromium.org/p/project-zero/issues/detail?id=1187 exploit report by Lokihardt (Mar 15, 2017)]
* [https://blog.xyz.is/2016/webkit-360.html PSVita 3.60 HENkaku WebKit exploit writeup]
* [https://twitter.com/VVildCard777/status/919843554964443137 First test on PS4 by WildCard (Oct 16, 2017)]
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/WebKit/setAttributeNodeNS%20UAF%20Write-up.md Specter's setAttributeNodeNS Exploit Writeup]


==== Bug Description ====
==== 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.  
When attempting to update a vector via sortCompactedVector() - data is written based on a pointer, though the pointer is not re-updated nor nulled. When this memory in free()'d, the reference is maintained and thus memory corruption can occur.


==== Exploit Implementation ====
==== Exploit Implementation ====
[https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit PS4 5.05 WebKit + Kernel Exploit]
* [https://github.com/henkaku/henkaku/blob/master/webkit/exploit.js PSVita 3.60 WebKit exploit by xyz]
* [https://github.com/Fire30/PS4-3.55-Code-Execution-PoC PS4 playground 3.15-3.70 by Fire30]
* [https://github.com/Cryptogenic/PS4-Playground-3.55 Improved PS4 playground 3.15-3.70 by Specter]


==== Patched ====
==== Patched ====
'''Yes''' in 5.03 FW.
'''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.15-4.07 - Stack Uninitialized Read UaF leading to arbitrary RW ===
=== FW <= 3.50 - WebCore::TimerBase::heapPopMin() Heap UaF leading to crash ===


==== Credits ====
==== Credits ====
* qwertyoruiop for the exploit
* Brent Fulgham for fixing the bug in WebKit (2016-05-16)
* Specter for the writeup


==== Analysis ====
==== Analysis ====
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/4.0x%20WebKit%20Exploit%20Writeup.md Specter's 4.0x WebKit Exploit Writeup]
* [https://github.com/WebKit/WebKit-http/commit/98845d940e30529098eea7e496af02e14301c704 WebKit fix commit (2016-05-17)]
* [https://xz.aliyun.com/t/292 Summary of Critical and Exploitable iOS Vulnerabilities in 2016 by Min (Spark) Zheng, Cererdlong, Eakerqiu @ Team OverSky]


==== Bug Description ====
==== 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.
"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 ====
==== Exploit Implementation ====
* [https://github.com/Cryptogenic/PS4-4.0x-Code-Execution-PoC Specter's commented and usable version]
* [http://psxhax.com/threads/ps4-3-50-webkit-exploit-from-playstation-4-dev-qwertyoruiop.450/ Article about qwertyoruiop's tests (2016-05-20)]
* [https://gist.github.com/X41/36acd2a6939e4cebbecba45d35bf0d75 mirrorred expl.js from qwertyoruiop]
* [http://psxhax.com/threads/ps4-heap-use-after-free-at-webcore-3-50-poc-by-hunter128.452/ Article about initial PoC for PS4 (2016-05-21)]
 
* [http://wololo.net/talk/viewtopic.php?t=45888 Initial PoC for PS4 (2016-05-21)]
* [https://web.archive.org/web/20161030085033/http://cryptoanarchic.me/wat.txt iOS 9.3.2 WebKit RCE via heapPopMin (2016-07)]
* [https://twitter.com/qwertyoruiopz/status/756268361282125824 qwertyoruiop's tweet (2016-07-22)]
* [https://github.com/Jailbreaks/jbme/tree/master mirror of iOS 9.3.2 WebKit RCE via heapPopMin]
 
==== Patched ====
==== Patched ====
'''Yes''' in 4.50 FW
'''Yes''' in 3.55 FW


==== Tested ====
==== Tested ====
Works on 3.15-4.07. Not working on <= 3.11.
Works on 3.15, 3.50 FW. Maybe working on 3.51 FW.
----
----


=== FW <= ?4.05? - Type confusion in WebCore::HTMLInputElement::onSearch (CVE-2017-2354) ===
=== FW <= ?2.50? - JavaScript OnLoad Handler Remote Code Execution Vulnerability (CVE-2005-1790) leading to crash or lag ===


==== Credits ====
==== Credits ====
* Neymar of Tencent's Xuanwu Lab working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-11)
* Benjamin Tobias Franz for the vulnerability discovery (2005-11-21)
* Brent Fulgham for fixing the bug in WebKit (2016-11-14)
* Stuart Pearson for the Proof of Concept on Microsoft Internet Explorer
* Jasiel Spelman (@WanderingGlitch) for his writeup (2017-12-20)
* Sam Sharps for the Metasploit port (2012-01)
* Jeerum for disclosing that the vulnerability affects PS4 <=2.50 (2014-10-31).


==== Analysis ====
==== Analysis ====
* [https://www.zerodayinitiative.com/blog/2017/12/20/invariantly-exploitable-input-an-apple-safari-bug-worth-revisiting Writeup by Jasiel Spelman (2017-12-20)]
* [https://web.archive.org/web/20150617052519/http://sebug.net:80/paper/Exploits-Archives/2012-exploits/1201-exploits/ms05_054_onload.rb.txt Metasploit file by Sam Sharps (2012-01)]
* [https://github.com/WebKit/WebKit-http/commit/cf2bf6e58f51267d7ae25fcb82a315377c8e5cf6 WebKit fix commit by Brent Fulgham (2016-11-14)]
* [https://malware.wicar.org/data/ms05_054_onload.html PoC by wicar.org (before 2012-11-10)]
* [https://wololo.net/talk/viewtopic.php?f=63&t=40446 PoC for PS4 by Jeerum (2014-10-31)]
* [https://www.youtube.com/watch?v=J_-1nyfCo84 PS4 4.55 test of 1js by Jeerum]


==== Bug Description ====
==== Bug Description ====
It is possible for JavaScript to change the type property of an input field. WebKit needs to gracefully handle this case.
This bug is triggered when the browser handles a JavaScript 'onLoad' handler in conjunction with an improperly initialized 'window()' JavaScript function. This exploit results in a call to an address lower than the heap. The javascript prompt() places our shellcode near where the call operand points to. We call prompt() multiple times in separate iframes to place our return address. We hide the prompts in a popup window behind the main window. We spray the heap a second time with our shellcode and point the return address to the heap. I use a fairly high address to make this exploit more reliable. Microsoft Internet Explorer will crash when the exploit completes. Also, please note that Microsoft Internet Explorer must allow popups in order to continue exploitation.


This bug could have been prevented had it a debug check been used instead of a runtime check. In fact, WebKit has support for this type of assertion already through a RELEASE_ASSERT macro, which would have turned this exploitable bug into a simple denial-of-service by immediately and safely crashing the browser.
==== Exploit Implementation ====


The fix commit of the vulnerability adds a type traits specialization so that WebKit can properly downcast InputType elements. This should be used only to call search functions on actual search input types.
==== Patched ====
'''Maybe'''
 
==== Tested ====
* Working on 1.76-2.50 FW: crash. 3.00-5.50 error CE-36329-3. 4.55 lag in background TV application (for example Netflix application).
----
 
=== 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)


Although the access violation in WebCore::TimerBase::heapPop is where we see the result of the bug, it is not the cause of the issue. The crash actually occurs as a result of reading a pointer that comes from the 'this' object. Based on that, it would seem that something is wrong with the Timer object passed into the WebCore::TimerBase::heapPop function.
==== Analysis ====
* [https://www.blackhat.com/docs/eu-14/materials/eu-14-Chen-WebKit-Everywhere-Secure-Or-Not.PDF BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' slides]
* [https://www.blackhat.com/docs/eu-14/materials/eu-14-Chen-WebKit-Everywhere-Secure-Or-Not-WP.pdf BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' PDF]
* [https://cansecwest.com/slides/2015/Liang_CanSecWest2015.pdf Attacking WebKit Applications by exploiting memory corruption bugs by Liang Chen]


This vulnerability may be the one used by Chaintin Tech with a kernel exploit on PS4 FW 4.01 at GeekPwn 2016, a Tencent Security's conference, in Shanghai Station at the Pavilion Safety Research Lab, (https://www.chaitin.cn/ps4, https://www.psxhax.com/threads/ps4-4-01-linux-installation-ksploit-demo-at-geekpwn-2016.932/)
==== 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 ====
==== Exploit Implementation ====
* PoC by Neymar (2016-11, disclosed publicly by Jasiel Spelman on 2017-12-20):
* [https://github.com/Fire30/PS4-2014-1303-POC ROP PoC for PS4 FW 2.03 by Fire30]
<source lang="js">
* [http://wololo.net/2016/04/21/proof-of-concept-webkit-exploit-running-on-ps4-firmwares-up wololo article]
<input id="m_input" type="search"></input>
* WebKit exploit for 3.30-3.36 FW PSVita by xyz: used in vitasploit
<script type="text/javascript">
* [https://github.com/RKX1209/CVE-2014-1303 PoC for Linux by RKX1209]
first = true;
m_input.addEventListener("input", function (e) {
if(first) {
first = false;
}
else {
m_input["type"] = "image";
}
}, false);
</script>
</source>
* [https://github.com/WebKit/WebKit-http/blob/master/LayoutTests/fast/forms/search-cancel-button-change-input.html Vulnerability test by Brent Fulgham (2016-11-15)]


==== Patched ====
==== Patched ====
'''Maybe''' in 4.06 FW
'''Yes''' in 2.50 FW


==== Tested ====
==== Tested ====
Not yet.
* 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 3.15-3.70 - JSArray::sortCompactedVector() Heap UaF leading to arbitrary RW ===
=== FW <= 2.03-? - WebCore::ImageInputType::attach Heap UaF (CVE-2013-2857) leading to ROP execution ===


==== Credits ====
==== Credits ====
* xyz for the original exploit on PSVita (HENkaku)
* Chromium bugs reporters
* Fire30 for porting to PS4
* JumpCallPop, jam1garner, hedgeberg for inital exploit on Wii U
* Specter for improved PS4 playground
* 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 ====
==== Analysis ====
* [https://blog.xyz.is/2016/webkit-360.html PSVita 3.60 HENkaku WebKit exploit writeup]
* [https://bugs.chromium.org/p/chromium/issues/detail?id=240124 Chromium bug report with a PoC]


==== Bug Description ====
==== Bug Description ====
When attempting to update a vector via sortCompactedVector() - data is written based on a pointer, though the pointer is not re-updated nor nulled. When this memory in free()'d, the reference is maintained and thus memory corruption can occur.
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 usermode ASLR since about FW 1.70 so ROP chain gadgets must be relocated at runtime. This means another vulnerability allowing usermode arbitrary read is needed.
* As usually an arbitrary read vulnerability also gives arbitrary write, and as arbitrary RW leads to usermode 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 usermode by restoring vtable.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/henkaku/henkaku/blob/master/webkit/exploit.js PSVita 3.60 WebKit exploit by xyz]
* [https://github.com/WiiUTest/JsTypeHax Initial Wii U implementation]
* [https://github.com/Fire30/PS4-3.55-Code-Execution-PoC PS4 playground 3.15-3.70 by Fire30]
* [https://github.com/WiiUTest/JsTypeHax/blob/master/payload/exploit_WORKING.html Wii U stabler implementation (last update May 22, 2018)]
* [https://github.com/Cryptogenic/PS4-Playground-3.55 Improved PS4 playground 3.15-3.70 by Specter]
* [https://github.com/wiiu-env/JsTypeHax Wii U tabler implementation (last update Jan 13, 2019)]
* [https://github.com/Hiperhazz/wiiuexploit/blob/master/firmware/Exploit.html Wii U stabler implementation by Hiperhazz (last update May 26, 2020)]
* [https://github.com/zoogie/new-browserhax/blob/master/index.html New3DS implementation by zoogie (last update Aug 9, 2020)]


==== Patched ====
==== Patched ====
'''Yes''' in 4.0?0? FW
'''Yes''' in ? FW


==== Tested ====
==== Tested ====
Works on 3.15-3.70. Not working on <= 3.11. Maybe working on 4.00.
* 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 <= 3.50 - WebCore::TimerBase::heapPopMin() Heap UaF leading to crash ===
=== FW <= 1.76 - JSArray::sort() Heap Overflow (CVE-2012-3748, PSA 2013-0903-1) leading to arbitrary RW ===


==== Credits ====
==== Credits ====
* Brent Fulgham for fixing the bug in WebKit (2016-05-16)
 
* 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 (October 23, 2014)
* sony for patching the exploit in FW 2.00 (October 27, 2014)
* CTurt for the rewriting (PS4 1.76 PlayGround) and implementation with his 1.76 kexploit (December 6, 2015) [https://twitter.com/CTurtE/status/673581693207502849]


==== Analysis ====
==== Analysis ====
* [https://github.com/WebKit/WebKit-http/commit/98845d940e30529098eea7e496af02e14301c704 WebKit fix commit (2016-05-17)]
* [https://packetstormsecurity.com/files/cve/CVE-2012-3748 CVE-2012-3748]
* [https://xz.aliyun.com/t/292 Summary of Critical and Exploitable iOS Vulnerabilities in 2016 by Min (Spark) Zheng, Cererdlong, Eakerqiu @ Team OverSky]
* [https://packetstormsecurity.com/files/123088/ PSA 2013-0903-1]
* [https://www.exploit-db.com/exploits/28081/ Exploit PoC by Vitaliy Toropov]


==== Bug Description ====
==== 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
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 ====
==== Exploit Implementation ====
* [http://psxhax.com/threads/ps4-3-50-webkit-exploit-from-playstation-4-dev-qwertyoruiop.450/ Article about qwertyoruiop's tests (2016-05-20)]
* [http://wololo.net/talk/viewtopic.php?p=368577 first POC for 1.76 PS4 by nas and Proxima]
* [http://psxhax.com/threads/ps4-heap-use-after-free-at-webcore-3-50-poc-by-hunter128.452/ Article about initial PoC for PS4 (2016-05-21)]
* [http://wololo.net/downloads/index.php/download/8230 mirror]
* [http://wololo.net/talk/viewtopic.php?t=45888 Initial PoC for PS4 (2016-05-21)]
* [http://daxhordes.org/ps4_176/ps4_dump.html live test]
* [https://web.archive.org/web/20161030085033/http://cryptoanarchic.me/wat.txt iOS 9.3.2 WebKit RCE via heapPopMin (2016-07)]
* [http://daxhordes.org/ps4_176/ps4_dump2.html livetest2]
* [https://twitter.com/qwertyoruiopz/status/756268361282125824 qwertyoruiop's tweet (2016-07-22)]
* [http://daxhordes.org/ps4_176/ps4_rop2.html ROP2]
* [https://github.com/Jailbreaks/jbme/tree/master mirror of iOS 9.3.2 WebKit RCE via heapPopMin]
* [https://cturt.github.io/PS4-playground/ PS4 playground 1.76 by CTurt]
* [https://bitbucket.org/DaveeFTW/psvita-260-webkit/src/master/ PSVita 2.00-3.20 WebKit exploit]


==== Patched ====
==== Patched ====
'''Yes''' in 3.55 FW
'''Yes''' in 2.00 FW


==== Tested ====
==== Tested ====
Works on 3.15, 3.50 FW. Maybe working on 3.51 FW.
* Working on PS4 1.00-1.76 FW, AppleWebKit/531.3-536.26
----
* Might work on PS4 FW 0.930.020.


=== FW <= ?2.50? - JavaScript OnLoad Handler Remote Code Execution Vulnerability (CVE-2005-1790) leading to crash or lag ===
=== Possible WebKit vulnerabilities ===


==== Credits ====
<pre>
* Benjamin Tobias Franz for the vulnerability discovery (2005-11-21)
CVE-2017-7064
* Stuart Pearson for the Proof of Concept on Microsoft Internet Explorer
https://project-zero.issues.chromium.org/issues/42450258
* Sam Sharps for the Metasploit port (2012-01)
* Jeerum for disclosing that the vulnerability affects PS4 <=2.50 (2014-10-31).


==== Analysis ====
CVE-2018-4192
* [https://web.archive.org/web/20150617052519/http://sebug.net:80/paper/Exploits-Archives/2012-exploits/1201-exploits/ms05_054_onload.rb.txt Metasploit file by Sam Sharps (2012-01)]
https://blog.ret2.io/2018/06/13/pwn2own-2018-vulnerability-discovery/
* [https://malware.wicar.org/data/ms05_054_onload.html PoC by wicar.org (before 2012-11-10)]
https://blog.ret2.io/2018/06/19/pwn2own-2018-root-cause-analysis/#arrayreverse-considered-harmful
* [https://wololo.net/talk/viewtopic.php?f=63&t=40446 PoC for PS4 by Jeerum (2014-10-31)]
https://blog.ret2.io/2018/07/11/pwn2own-2018-jsc-exploit/
* [https://www.youtube.com/watch?v=J_-1nyfCo84 PS4 4.55 test of 1js by Jeerum]


==== Bug Description ====
CVE-2018-4443
This bug is triggered when the browser handles a JavaScript 'onLoad' handler in conjunction with an improperly initialized 'window()' JavaScript function. This exploit results in a call to an address lower than the heap. The javascript prompt() places our shellcode near where the call operand points to. We call prompt() multiple times in separate iframes to place our return address. We hide the prompts in a popup window behind the main window. We spray the heap a second time with our shellcode and point the return address to the heap. I use a fairly high address to make this exploit more reliable. Microsoft Internet Explorer will crash when the exploit completes. Also, please note that Microsoft Internet Explorer must allow popups in order to continue exploitation.
WebKit JSC - 'AbstractValue::set' Use-After-Free
lokihardt of Google Project Zero
2019-01-22
https://www.exploit-db.com/exploits/46071


==== Exploit Implementation ====
Improper Restriction of Operations within the Bounds of a Memory Buffer


==== Patched ====
Unknown CVE
'''Maybe'''
Luca Todesco (qwertyruiopz)
before 2019-08-15
https://gist.github.com/jakeajames/5ceb90ebaa34eabb3e170b5c7eb2c7d1/revisions
</pre>


==== Tested ====
=== Resources for WebKit exploitation ===
* Working on 1.76-2.50 FW: crash. 3.00-5.50 error CE-36329-3. 4.55 lag in background TV application (for example Netflix application).
----


=== FW <= 2.03 - WebCore::CSSSelector Heap Overflow (CVE-2014-1303) leading to arbitrary RW ===
https://webkit.org/blog/12967/understanding-gc-in-jsc-from-scratch/


==== Credits ====
https://googleprojectzero.blogspot.com/2019/08/jsc-exploits.html
* 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 ====
== Usermode securities ==
* [https://www.blackhat.com/docs/eu-14/materials/eu-14-Chen-WebKit-Everywhere-Secure-Or-Not.PDF BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' slides]
* [https://www.blackhat.com/docs/eu-14/materials/eu-14-Chen-WebKit-Everywhere-Secure-Or-Not-WP.pdf BlackHat EU 2014 'WebKit Everywhere - Secure Or Not?' PDF]
* [https://cansecwest.com/slides/2015/Liang_CanSecWest2015.pdf Attacking WebKit Applications by exploiting memory corruption bugs by Liang Chen]


==== Bug Description ====
=== Usermode ASLR ===
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 ====
* Very old firmwares (<= 1.05) do not 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.
* [https://github.com/Fire30/PS4-2014-1303-POC ROP PoC for PS4 FW 2.03 by Fire30]
* To defeat usermode ASLR on FWs >=1.70, we can use the module imports table to find other modules address once we know SceWebkit2 address.
* [http://wololo.net/2016/04/21/proof-of-concept-webkit-exploit-running-on-ps4-firmwares-up wololo article]
* WebKit exploit for 3.30-3.36 FW PSVita by xyz: used in vitasploit
* [https://github.com/RKX1209/CVE-2014-1303 PoC for Linux by RKX1209]


==== Patched ====
=== Module imports table cleaned before execution ===
'''Yes''' in 2.50 FW


==== Tested ====
* Between 1.76 and 4.05, Sony did that to prevent WebKit exploiters from defeating usermode ASLR easily.
* 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).
* Now we have to dump entire usermode sandboxed memory, and by studying it we can defeat ASLR:
* Working on AppleWebKit/537.73
1. Chose a function (ex: __stack_chk_fail) imported from libkernel.sprx by libSceWebkit2.sprx
* Maybe not working on FW < 2.00.
----


=== FW <= 2.03-? - WebCore::ImageInputType::attach Heap UaF (CVE-2013-2857) leading to ROP execution ===
2. Read pointer contained at the address where the call is done


==== Credits ====
3. Substract to this pointer the offset of the function (ex: __stack_chk_fail) in LibKernel module
* 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 ====
4. This result is LibKernel base address. This method works for any imported module.
* [https://bugs.chromium.org/p/chromium/issues/detail?id=240124 Chromium bug report with a PoC]


==== Bug Description ====
For FW >= 6.00, for web applications, libkernel.sprx has been replaced by libkernel_web.sprx and libSceWebKit2 by libSceNKWebKit.sprx. libkernel.sprx is still used by other applications.
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:
=== DEP / NX ===
* 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 usermode ASLR since about FW 1.70 so ROP chain gadgets must be relocated at runtime. This means another vulnerability allowing usermode arbitrary read is needed.
* "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 usermode memory then executing it.
* As usually an arbitrary read vulnerability also gives arbitrary write, and as arbitrary RW leads to usermode code execution (by hijacking JS pointers in virtual table), this UaF is not needed at all.
* 2 ways to bypass this security: JiT vulnerability (FW <= 1.76) or ROP (all FWs).
* 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 usermode by restoring vtable.


==== Exploit Implementation ====
=== JiT removed from webbrowser ===
* [https://github.com/WiiUTest/JsTypeHax Initial Wii U implementation]
* [https://github.com/WiiUTest/JsTypeHax/blob/master/payload/exploit_WORKING.html Wii U stabler implementation (last update May 22, 2018)]
* [https://github.com/wiiu-env/JsTypeHax Wii U tabler implementation (last update Jan 13, 2019)]
* [https://github.com/Hiperhazz/wiiuexploit/blob/master/firmware/Exploit.html Wii U stabler implementation by Hiperhazz (last update May 26, 2020)]
* [https://github.com/zoogie/new-browserhax/blob/master/index.html New3DS implementation by zoogie (last update Aug 9, 2020)]


==== Patched ====
* 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.
'''Yes''' in ? FW
* Checking the source code at [https://doc.dl.playstation.net/doc/ps4-oss/webkit.html ps4-oss], starting as early as FW 6.00, ENABLE_JIT=OFF for -DPORT=PlayStation4. It means that JIT functionality is completely removed from WebKit and there is no JIT coprocess that is allowed to request RWX memory to even attack. Even if there are JIT bugs that can lead us to request RWX memory in other platforms, we can't on the PS4 as there is no longer any JIT process. Unchecked all source codes, JIT process could have been removed earlier than 6.00. All exploits must use ROP.
* Workaround is to use ROP.


==== Tested ====
=== Syscalls removed ===
* 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 ===
* See the PS4 [[Syscalls]] list.


==== Credits ====
=== Direct Syscall invocation disabled in PS4 Kernel ===


* Vitaliy Toropov for the exploit on Mac OS X Safari (September 4, 2013)
Between 2.00 and 2.57, SCE has disabled direct system calls by usermode, by adding some checks in the PS4 kernel. An attacker can no longer call any syscall he wants by specifying the call number in the rax register and jump directly to the call instructions part of a syscall stub. Indeed, now the PS4 (but not PS5) implementation of <code>amd64_syscall</code> checks the following:
* nas and Proxima for the first PS4 POC on 1.76 PS4 (October 23, 2014)
* The address in the Instruction Pointer (IP) of the call must be within the memory range of the associated libkernel module of the process,
* sony for patching the exploit in FW 2.00 (October 27, 2014)
* The code pointed by the Instruction Pointer (IP) must follow the syscall stub format,
* CTurt for the rewriting (PS4 1.76 PlayGround) and implementation with his 1.76 kexploit (December 6, 2015) [https://twitter.com/CTurtE/status/673581693207502849]
* The syscall number passed in argument to <code>amd64_syscall</code> must corresponds to the stub's syscall number. <code>amd64_syscall</code> checks the stub's <code>mov rax, syscall_number</code> instruction.


==== Analysis ====
Since PS4 version 3.00, issuing directly a syscall instruction crashes the application and gives error CE-34878-0, (<code>SCE_KERNEL_ABORT_REASON_SYSTEM_ILLEGAL_FUNCTION_CALL</code>), displaying the message "Kernel: The application directly issues a syscall instruction (24)".
* [https://packetstormsecurity.com/files/cve/CVE-2012-3748 CVE-2012-3748]
* [https://packetstormsecurity.com/files/123088/ PSA 2013-0903-1]
* [https://www.exploit-db.com/exploits/28081/ Exploit PoC by Vitaliy Toropov]


==== Bug Description ====
An attacker is now forced to use wrappers provided from the libkernel / libkernel_web / libkernel_sys modules to trigger system calls.
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 ====
The PS5 does not enforce the passed syscall number and thus any code can directly issue an arbitrary syscall even if the associated libkernel does not provide it.
* [http://wololo.net/talk/viewtopic.php?p=368577 first POC for 1.76 PS4 by nas and Proxima]
* [http://wololo.net/downloads/index.php/download/8230 mirror]
* [http://daxhordes.org/ps4_176/ps4_dump.html live test]
* [http://daxhordes.org/ps4_176/ps4_dump2.html livetest2]
* [http://daxhordes.org/ps4_176/ps4_rop2.html ROP2]
* [https://cturt.github.io/PS4-playground/ PS4 playground 1.76 by CTurt]
* [https://bitbucket.org/DaveeFTW/psvita-260-webkit/src/master/ PSVita 2.00-3.20 WebKit exploit]


==== Patched ====
=== bpf_write function stripped out of the kernel ===
'''Yes''' in 2.00 FW


==== Tested ====
* On 4.70, bpfwrite() was stripped out of the kernel entirely to patch kernel vulnerability exploited in 4.55 kexploit.
* Working on PS4 1.00-1.76 FW, AppleWebKit/531.3-536.26
* Might work on PS4 FW 0.930.020.


=== Possible WebKit vulnerabilities ===
=== bpf_open function blocked for unprivileged processes ===


Affecting WebKitGTK: CVE-2023-41074, CVE-2023-42917.
* 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.


== Usermode securities ==
=== bpf_ioctl function blocked or removed ===


=== Usermode ASLR ===
* On FW 5.50+, opening BPF is still possible in less sandboxed apps like TestKit/DevKits fSELFs. But this is useless because ioctl does not work.


* Very old firmwares (<= 1.05) do not 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.
=== Device access blocked/removed from webbrowser ===
* To defeat usermode 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 ===
* Around 6.50-6.70, device access got blocked or removed. Now you can no longer access devices from the web browser.


* Between 1.76 and 4.05, Sony did that to prevent WebKit exploiters from defeating usermode ASLR easily.
=== Pointer poisoning in WebKit on 6.xx firmwares ===
* Now we have to dump entire usermode sandboxed memory, and by studying it we can defeat ASLR:
1. Chose a function (ex: __stack_chk_fail) imported from libkernel.sprx by libSceWebkit2.sprx


2. Read pointer contained at the address where the call is done
* For select types implemented by WebKit (such as JSC::JSFunction), certain pointer fields are XOR'ed by a cryptographic key generated at runtime. The key is generated once every process launch, one must recover it to unpoison the pointers.


3. Substract to this pointer the offset of the function (ex: __stack_chk_fail) in LibKernel module
=== Flush-to-Zero and Denormals-are-Zero Floating-Point environment ===


4. This result is LibKernel base address. This method works for any imported module.
[https://en.wikipedia.org/wiki/Subnormal_number Subnormal numbers] (also called as denormal numbers in IEEE 754 documents before the 2008 version) are treated as 0 on the PlayStation runtime environment. This isn't technically a security technique but it does inhibit any exploit that uses floating-point numbers for read/write.


For FW >= 6.00, for web applications, libkernel.sprx has been replaced by libkernel_web.sprx and libSceWebKit2 by libSceNKWebKit.sprx. libkernel.sprx is still used by other applications.
An example entrypoint is WebKit where exploits have commonly used double arrays with incorrect length to read/write certain memory areas to gain arbitrary read/write or even code execution. With FTZ/DAZ, the possible 64-bit values one can write have become even more limited. Reads using double arrays are also affected. Even if the bit pattern is nonzero but encodes a subnormal, it will be read by the JavaScript engine as 0.


=== DEP / NX ===
== Kernel ==


* "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 usermode memory then executing it.
=== FW <= 11.52 - Double free in bnet_netevent_set_queue ===
* 2 ways to bypass this security: JiT vulnerability (FW <= 1.76) or ROP (all FWs).


=== JiT removed from webbrowser ===
==== Credits ====
 
* Anonymous for sharing 11.52 and 12.00 PS4 kernel dumps.
* 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.
* 2024-09-27 D-Link Turtle for diffing 11.52 and 12.00 PS4 kernel dumps.
* Checking the source code at [https://doc.dl.playstation.net/doc/ps4-oss/webkit.html ps4-oss], starting as early as FW 6.00, ENABLE_JIT=OFF for -DPORT=PlayStation4. It means that JIT functionality is completely removed from WebKit and there is no JIT coprocess that is allowed to request RWX memory to even attack. Even if there are JIT bugs that can lead us to request RWX memory in other platforms, we can't on the PS4 as there is no longer any JIT process. Unchecked all source codes, JIT process could have been removed earlier than 6.00. All exploits must use ROP.
* 2024-10-04 SlidyBat for figuring out the bug in bnet and its impact.
* Workaround is to use ROP.


=== Syscalls removed ===
==== Analysis ====
* [https://x.com/iMrDJAi/status/1842306232125964473/photo/1 Analysis by abc (2024-10-04)]


* See the PS4 [[Syscalls]] list.
==== Bug Description ====
A double free can happen by racing calls to bnet_netevent_set_queue and bnet_netevent_unset_queue.


=== Syscall 0 disabled i.e Error Kernel: The application directly issues a syscall instruction (24) ===
The lack of mutexes allowed double free as fdrop is called unconditionally in bnet_netevent_unset_queue.


* 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.
See also PS Vita SceNetPs kernel module that uses similar bnet functions.
* 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 ===
==== Exploit Implementation ====


* On 4.70, bpfwrite() was stripped out of the kernel entirely to patch kernel vulnerability exploited in 4.55 kexploit.
==== Patched ====
'''Yes''' in 12.00 FW. Maybe not working at all on PS5.


=== bpf_open function blocked for unprivileged processes ===
The bug was patched in PS4 FW 12.00 by adding some mutexes in bnet_netevent functions
----


* 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.
=== FW <= 11.00 - Remote vulnerabilities in spp (yielding kernel ASLR defeat) (CVE-2006-4304 and no-CVE) ===


=== bpf_ioctl function blocked or removed ===
==== Credits ====
 
* 2006-08-23 Martin Husemann, Pavel Cahyna for discovering the first spp bug (CVE-2006-4304) on FreeBSD 4.11-6.1.
* On FW 5.50+, opening BPF is still possible in less sandboxed apps like TestKit/DevKits fSELFs. But this is useless because ioctl does not work.
* 2023-09-22 TheFloW for discovering that PS4 and PS5 are vulnerable to CVE-2006-4304, discovering second spp bug, and chaining them together.
* 2024-01-27 anonymous for reporting publicly CVE-2006-4304 as working on PS4 and PS5. See [https://i0.wp.com/wololo.net/wagic/wp-content/uploads/2024/02/initial_claims.png?w=603&ssl=1] and [https://ibb.co/sVb39Zj].
* 2024-03 iMrDJAi for porting CVE-2006-4304 to PS4 and PS5.
* 2024-04-25 TheFloW for disclosing his HackerOne report including the second spp bug description.
* 2024-04-30 TheFloW for releasing his exploit code for PS4 9.00 and 11.00.


=== Device access blocked/removed from webbrowser ===
==== Analysis ====
* [https://www.freebsd.org/security/advisories/FreeBSD-SA-06:18.ppp.asc FreeBSD Security Advisory for CVE-2006-4304 (2006-08-23)]
* [https://hackerone.com/reports/2177925 HackerOne report about Remote vulnerabilities in spp by TheFloW (2023-09-22)]
* [https://romhack.io/wp-content/uploads/sites/3/2024/10/Andy-Nguyen-PlayStation-4-Remote-Kernel-Exploitation-RomHack-2024.pdf Slides of TheFloW's presentation at RomHack 2024 (2024-09-28)]
* [https://www.youtube.com/watch?v=LRdbnGkk7JA Video of TheFloW's presentation at RomHack 2024 (2024-09-28)]


* Around 6.50-6.70, device access got blocked or removed. Now you can no longer access devices from the web browser.
==== Bug Description ====
A malicious PPPoE server can cause denial-of-service or remote code execution in kernel context on the PS4/PS5. It does not require any usermode code execution to be triggered. There are two vulnerabilities that can be chained together to cause remote kernel Denial of Service, kernel ASLR defeat or kernel code execution : Heap buffer overwrite and overread in sppp_lcp_RCR and sppp_ipcp_RCR (CVE-2006-4304) and Integer underflow in sppp_pap_input leading to heap-buffer overread (no-CVE).


=== Pointer poisoning in WebKit on 6.xx firmwares ===
The PS4/PS5 must be connected using an ethernet cable to a device able to trigger PPPoE requests and analyze the responses.


* For select types implemented by WebKit (such as JSC::JSFunction), certain pointer fields are XOR'ed by a cryptographic key generated at runtime. The key is generated once every process launch, one must recover it to unpoison the pointers.
==== Exploit Implementation ====
* [https://github.com/iMrDJAi/FreeBSD9-CVE-2006-4304 CVE-2006-4304 PoC for FreeBSD9 by iMrDJAi (2024-04-07)]
* [https://gist.github.com/iMrDJAi/847a4f2eeff9669657ffcdf85ac7a901 CVE-2006-4304 PoC for PS4 and PS5 by iMrDJAi (2024-04-07)]
* [https://github.com/TheOfficialFloW/PPPwn spp exploit for PS4 9.00 and 11.00 by TheFloW (2024-04-30)]


== Kernel Exploits ==
==== Patched ====
'''Yes''' in 11.02 FW
----


=== FW <= 11.52 - Double free in bnet_netevent_set_queue ===
=== FW <= 9.00 - PPPoE driver remote buffer overflow (CVE-2022-29867) ===


==== Credits ====
==== Credits ====
* Anonymous for sharing 11.52 and 12.00 PS4 kernel dumps.
* 2021-09-24 m00nbsd for finding the vulnerability
* 2024-09-27 D-Link Turtle for diffing 11.52 and 12.00 PS4 kernel dumps.
* 2022-05-04 martin of NetBSD for fixing the vulnerability publicly in NetBSD 8 and 9
* 2024-10-04 SlidyBat for figuring out the bug in bnet and its impact.
* 2022-05-11 m00nbsd for disclosing the vulnerability publicly on HackerOne


==== Analysis ====
==== Analysis ====
* [https://x.com/iMrDJAi/status/1842306232125964473/photo/1 Analysis by abc (2024-10-04)]
* [https://hackerone.com/reports/1350653 HackerOne report by m00nbsd (2021-09-24)]
* [http://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2022-001.txt.asc NetBSD Security Advisory about CVE-2022-29867 (2022-05-04)]


==== Bug Description ====
==== Bug Description ====
A double free can happen by racing calls to bnet_netevent_set_queue and bnet_netevent_unset_queue.
The PlayStation 4 has a kernel PPPoE driver, that originates from NetBSD. This driver has a kernel heap overflow vulnerability, that an attacker can remotely trigger over the LAN, with the ability to control both the contents that are overflown and their sizes.


The lack of mutexes allowed double free as fdrop is called unconditionally in bnet_netevent_unset_queue.
Extract of NetBSD 8.3 changelog:
<pre>
sys/net/if_pppoe.c 1.179


See also PS Vita SceNetPs kernel module that uses similar bnet functions.
pppoe(4): fix CVE-2022-29867 - discovery phase local network
mbuf corruption.
[martin, ticket #1740]


==== Exploit Implementation ====
Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.


==== Patched ====
When we have received multiple PADO offer packets in the discovery
'''Yes''' in 12.00 FW. Maybe not working at all on PS5.
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.


The bug was patched in PS4 FW 12.00 by adding some mutexes in bnet_netevent functions
The second bug could cause code to trigger the first and create
----
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.


=== FW <= 11.00 - Remote vulnerabilities in spp (yielding kernel ASLR defeat) (CVE-2006-4304 and no-CVE) ===
Fixes CVE-2022-29867.
</pre>


==== Credits ====
Diff after fix commit in NetBSD 8:
* 2006-08-23 Martin Husemann, Pavel Cahyna for discovering the first spp bug (CVE-2006-4304) on FreeBSD 4.11-6.1.
<source lang="C">
* 2023-09-22 TheFloW for discovering that PS4 and PS5 are vulnerable to CVE-2006-4304, discovering second spp bug, and chaining them together.
--- src/sys/net/if_pppoe.c 2020/02/13 19:37:39 1.125.6.10
* 2024-01-27 anonymous for reporting publicly CVE-2006-4304 as working on PS4 and PS5. See [https://i0.wp.com/wololo.net/wagic/wp-content/uploads/2024/02/initial_claims.png?w=603&ssl=1] and [https://ibb.co/sVb39Zj].
+++ src/sys/net/if_pppoe.c 2022/05/04 15:36:35 1.125.6.11
* 2024-03 iMrDJAi for porting CVE-2006-4304 to PS4 and PS5.
@@ -1,4 +1,4 @@
* 2024-04-25 TheFloW for disclosing his HackerOne report including the second spp bug description.
-/* $NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $ */
* 2024-04-30 TheFloW for releasing his exploit code for PS4 9.00 and 11.00.
+/* $NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $ */
 
==== Analysis ====
/*-
* [https://www.freebsd.org/security/advisories/FreeBSD-SA-06:18.ppp.asc FreeBSD Security Advisory for CVE-2006-4304 (2006-08-23)]
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* [https://hackerone.com/reports/2177925 HackerOne report about Remote vulnerabilities in spp by TheFloW (2023-09-22)]
@@ -30,7 +30,7 @@
 
  */
==== Bug Description ====
A malicious PPPoE server can cause denial-of-service or remote code execution in kernel context on the PS4/PS5. It does not require any usermode code execution to be triggered. There are two vulnerabilities that can be chained together to cause remote kernel Denial of Service, kernel ASLR defeat or kernel code execution : Heap buffer overwrite and overread in sppp_lcp_RCR and sppp_ipcp_RCR (CVE-2006-4304) and Integer underflow in sppp_pap_input leading to heap-buffer overread (no-CVE).
#include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $");
The PS4/PS5 must be connected using an ethernet cable to a device able to trigger PPPoE requests and analyze the responses.
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $");
 
==== Exploit Implementation ====
#ifdef _KERNEL_OPT
* [https://github.com/iMrDJAi/FreeBSD9-CVE-2006-4304 CVE-2006-4304 PoC for FreeBSD9 by iMrDJAi (2024-04-07)]
#include "pppoe.h"
* [https://gist.github.com/iMrDJAi/847a4f2eeff9669657ffcdf85ac7a901 CVE-2006-4304 PoC for PS4 and PS5 by iMrDJAi (2024-04-07)]
@@ -871,6 +871,10 @@ breakbreak:;
* [https://github.com/TheOfficialFloW/PPPwn spp exploit for PS4 9.00 and 11.00 by TheFloW (2024-04-30)]
}
 
sc->sc_ac_cookie_len = ac_cookie_len;
==== Patched ====
memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
'''Yes''' in 11.02 FW
+ } else if (sc->sc_ac_cookie) {
----
+ free(sc->sc_ac_cookie, M_DEVBUF);
 
+ sc->sc_ac_cookie = NULL;
=== FW <= 9.00 - PPPoE driver remote buffer overflow (CVE-2022-29867) ===
+ sc->sc_ac_cookie_len = 0;
 
}
==== Credits ====
if (relay_sid) {
* 2021-09-24 m00nbsd for finding the vulnerability
if (sc->sc_relay_sid)
* 2022-05-04 martin of NetBSD for fixing the vulnerability publicly in NetBSD 8 and 9
@@ -886,6 +890,10 @@ breakbreak:;
* 2022-05-11 m00nbsd for disclosing the vulnerability publicly on HackerOne
}
 
sc->sc_relay_sid_len = relay_sid_len;
==== Analysis ====
memcpy(sc->sc_relay_sid, relay_sid, relay_sid_len);
* [https://hackerone.com/reports/1350653 HackerOne report by m00nbsd (2021-09-24)]
+ } else if (sc->sc_relay_sid) {
* [http://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2022-001.txt.asc NetBSD Security Advisory about CVE-2022-29867 (2022-05-04)]
+ free(sc->sc_relay_sid, M_DEVBUF);
+ sc->sc_relay_sid = NULL;
+ sc->sc_relay_sid_len = 0;
}
memcpy(&sc->sc_dest, eh->ether_shost, sizeof sc->sc_dest);
callout_stop(&sc->sc_timeout);
@@ -1313,6 +1321,9 @@ pppoe_get_mbuf(size_t len)
{
struct mbuf *m;
+ if (len + sizeof(struct ether_header) > MCLBYTES)
+ return NULL;
+
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return NULL;
</source>


==== Bug Description ====
==== Exploit Implementation ====
The PlayStation 4 has a kernel PPPoE driver, that originates from NetBSD. This driver has a kernel heap overflow vulnerability, that an attacker can remotely trigger over the LAN, with the ability to control both the contents that are overflown and their sizes.
* PoC (poc.c) by m00nbsd not disclosed publicly


Extract of NetBSD 8.3 changelog:
==== Patched ====
<pre>
'''Yes''' in 9.03 FW according to Specter by diffing PS4 9.00 and 9.03 kernels
sys/net/if_pppoe.c 1.179
----


pppoe(4): fix CVE-2022-29867 - discovery phase local network
=== FW <= 9.00 - exFAT driver heap-based buffer overflow ===
mbuf corruption.
[martin, ticket #1740]


Do not allocate mbuf clusters when the caller (eroneously) asks
==== Credits ====
for more than MCLBYTES size, instead fail the allocation.
* 2021-09-15 TheFloW for finding the vulnerability
* 2021-12-02 zecoxao for advicing to exploit the vulnerability after diffing PS4 9.00 and 9.03 kernels
* 2021-12-13 ChendoChap, Znullptr, Specter for PS4 9.00 kernel exploit implementation release


When we have received multiple PADO offer packets in the discovery
==== Analysis ====
phase, do not combine tags from different packets. We are supposed
* [https://twitter.com/notzecoxao/status/1466463051872448521 Vulnerability adviced by zecoxao for exploitation (2021-12-02)]
to pick one PADO packet and continue session establishment with that.
* [https://hackerone.com/reports/1340942 TheFloW's report on HackerOne (2021-09-15), disclosed on 2022-09-21]


The second bug could cause code to trigger the first and create
==== Bug Description ====
invalid response packets and also overwrite data outside of
The PS4 kernel exFAT driver has a heap-based buffer overflow vulnerability that can be triggered by inserting a malicious USB storage device in PS4 in addition to having usermode code execution. Exploitation requires to flash a crafted exFAT image to a common USB storage device.
the allocated mbuf cluster.


Fixes CVE-2022-29867.
==== Exploit Implementation ====
</pre>
* [https://github.com/ChendoChap/pOOBs4 ChendoChap's implementation for PS4 9.00 (2021-12-13)]


Diff after fix commit in NetBSD 8:
==== Patched ====
<source lang="C">
'''Yes''' in PS4 9.03 FW and PS5 4.50 FW
--- src/sys/net/if_pppoe.c 2020/02/13 19:37:39 1.125.6.10
----
+++ src/sys/net/if_pppoe.c 2022/05/04 15:36:35 1.125.6.11
 
@@ -1,4 +1,4 @@
=== FW <= 7.55 - IP6_EXTHDR_CHECK Double Free (CVE-2020-9892) ===
-/* $NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $ */
 
+/* $NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $ */
==== Credits ====
* 2019-09-15 tuexen for finding the FreeBSD vulnerability [https://reviews.freebsd.org/D21664]
/*-
* 2020-07-24 TheFloW for finding CVE-2020-9892 in XNU
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* 2020-07-26 TheFloW for porting CVE-2020-9892 to PS4
@@ -30,7 +30,7 @@
* 2020-07-27 TheFloW for publishing publicly a PoC leading to code execution on XNU. [https://twitter.com/theflow0/status/1324687305018408961]
  */
* 2021-01-12 TheFloW for disclosing publicly the PS4 vulnerability. [https://hackerone.com/reports/943231]
* 2021-01-20 sleirsgoevy for making a first working exploit for FreeBSD 9 [https://twitter.com/sleirsgoevy/status/1351689713564979200]
#include <sys/cdefs.h>
* 2021-03-03 sleirsgoevy for making a second working exploit for FreeBSD 9 [https://twitter.com/sleirsgoevy/status/1367098280736399368]
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $");
* 2021-03-12 sleirsgoevy for making the first public usable exploit for PS4 7.50-7.55 (https://twitter.com/sleirsgoevy/status/1370481212813348865)
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $");
 
==== Analysis ====
#ifdef _KERNEL_OPT
* [https://reviews.freebsd.org/D21664 Fix handling of Hop-by-Hop options over the loopback interface commits review (2019-09-15 to 2020-05-07)]
#include "pppoe.h"
* [https://support.apple.com/en-us/HT211288 Apple iOS 13.6 and iPadOS 13.6 Security Update (2020-07-24)]
@@ -871,6 +871,10 @@ breakbreak:;
* [https://support.apple.com/en-us/HT211289 Apple macOS Catalina 10.15.6 Security Update (2020-07-24)]
}
* [https://hackerone.com/reports/943231 TheFloW's report of the exploit with undisclosed PS4 and FreeBSD 9 PoCs]
sc->sc_ac_cookie_len = ac_cookie_len;
* [https://github.com/google/security-research/security/advisories/GHSA-gxcr-cw4q-9q78 TheFloW's writeup and PoC for XNU (2020-07-26)]
memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
* [https://github.com/freebsd/freebsd-src/commit/68e0e5a673c5026c68dba62314a2e58ad1533cfd#diff-816eb9feee4ece60d3c6e8933a75baf4fcfbdce0284500d86ac80e24827a19c8 Vulnerability adviced by TheFloW for exploitation (2018-02-05)]
+ } else if (sc->sc_ac_cookie) {
 
+ free(sc->sc_ac_cookie, M_DEVBUF);
==== Bug Description ====
+ sc->sc_ac_cookie = NULL;
Memory corruption can be achieved by sending fragmented IPv6 packets to loopback interface due to poor and inconsistent use of IP6_EXTHDR_CHECK.
+ sc->sc_ac_cookie_len = 0;
 
}
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.
if (relay_sid) {
 
if (sc->sc_relay_sid)
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.
@@ -886,6 +890,10 @@ breakbreak:;
 
}
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.
sc->sc_relay_sid_len = relay_sid_len;
 
memcpy(sc->sc_relay_sid, relay_sid, relay_sid_len);
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%.
+ } else if (sc->sc_relay_sid) {
+ free(sc->sc_relay_sid, M_DEVBUF);
+ sc->sc_relay_sid = NULL;
+ sc->sc_relay_sid_len = 0;
}
memcpy(&sc->sc_dest, eh->ether_shost, sizeof sc->sc_dest);
callout_stop(&sc->sc_timeout);
@@ -1313,6 +1321,9 @@ pppoe_get_mbuf(size_t len)
{
struct mbuf *m;
+ if (len + sizeof(struct ether_header) > MCLBYTES)
+ return NULL;
+
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return NULL;
</source>


==== Exploit Implementation ====
==== Exploit Implementation ====
* PoC (poc.c) by m00nbsd not disclosed publicly
* [https://github.com/google/security-research/security/advisories/GHSA-gxcr-cw4q-9q78 TheFloW's writeup and PoC for XNU (2020-07-27)]
* [https://gist.github.com/sleirsgoevy/ff591bfdc3a6f7573ed2388b018b31ec sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)]
* [https://asciinema.org/a/385584 Demonstration video of sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)]
* [https://gist.github.com/CelesteBlue-dev/de46d9e94823f0a6cf4b3b40ad635c14 Specter's kernel panic PoC for PS4 Web browser (2021-01-15)]
* [https://gist.github.com/CelesteBlue-dev/16303965ffea7e0a2c7c1d763cc721ec CelesteBlue's kernel panic PoC for PS4 Kit fSELF (2021-01-15)]
* [https://github.com/dayzerosec/PS4-Kernel-Exploit-Stream WiP exploit code by Specter and tihmstar (2021-02-24)]
* [https://gist.github.com/sleirsgoevy/35722572b0096f9acfd76a97b5678bed sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)]
* [https://asciinema.org/a/396409 Demonstration video of sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)]
* [https://github.com/sleirsgoevy/ps4jb2/blob/75x/src/jb.c sleirsgoevy's implementation for PS4 7.5x (2021-03-12)]
* [https://gist.github.com/Cryptogenic/448fd98813ab5a93182fb9620c013e17 Specter's implementation for FreeBSD 9 (2021-03-24)]


==== Patched ====
==== Patched ====
'''Yes''' in 9.03 FW according to Specter by diffing PS4 9.00 and 9.03 kernels
'''Yes''' in 8.00 FW
----
----


=== FW <= 9.00 - exFAT driver heap-based buffer overflow ===
=== FW <= 7.02 - IPV6_2292PKTOPTIONS UaF (yielding arbitrary kernel R/W) (CVE-2020-7457) ===


==== Credits ====
==== Credits ====
* 2021-09-15 TheFloW for finding the vulnerability
* 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. [https://twitter.com/Fire30_/status/1280228173888831490]
* 2021-12-02 zecoxao for advicing to exploit the vulnerability after diffing PS4 9.00 and 9.03 kernels
* 2020-07-06 TheFloW for publishing publicly a PoC leading to code execution on FreeBSD. [https://twitter.com/theflow0/status/1280224554393178122]
* 2021-12-13 ChendoChap, Znullptr, Specter for PS4 9.00 kernel exploit implementation release
* sleirsgoevy and ChendoChap for porting the PoC to PS4 and chaining it with the 6.72 and 7.02 WebKit exploits.
* SIE for not patching this vulnerability on PS5 even when patched on PS4.
* TheFlow for announcing that PS5 kernel was exploited: [https://twitter.com/theflow0/status/1457362920501829636 TheFloW's PS5 kernel exploit announcement (2021-11-07)] and later that it was that same vulnerability that was present in PS5 FW 3.00-4.51.


==== Analysis ====
==== Analysis ====
* [https://twitter.com/notzecoxao/status/1466463051872448521 Vulnerability adviced by zecoxao for exploitation (2021-12-02)]
* [https://hackerone.com/reports/826026 TheFloW's hackerone report of the PS4 kernel exploit with a FreeBSD 9-12 PoC]
* [https://hackerone.com/reports/1340942 TheFloW's report on HackerOne (2021-09-15), disclosed on 2022-09-21]
* [https://www.freebsd.org/security/advisories/FreeBSD-SA-20:20.ipv6.asc FreeBSD Security Advisory FreeBSD-SA-20:20.ipv6]
* [https://www.freebsd.org/security/patches/SA-20:20/ipv6.patch FreeBSD patch for FreeBSD-SA-20:20.ipv6]
* [https://hackerone.com/reports/1441103 TheFloW's hackerone report of the PS5 kernel exploit]


==== Bug Description ====
==== Bug Description ====
The PS4 kernel exFAT driver has a heap-based buffer overflow vulnerability that can be triggered by inserting a malicious USB storage device in PS4 in addition to having usermode code execution. Exploitation requires to flash a crafted exFAT image to a common USB storage device.
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.
 
Another description: There is a race and use-after-free vulnerability in the FreeBSD kernel IPv6 socket handling. A missing synchronization lock in the `IPV6_2292PKTOPTIONS` option handling in `setsockopt` permits racing `ip6_setpktopt` access to a freed `ip6_pktopts` struct. This exploit overwrites the `ip6po_pktinfo` pointer of a `ip6_pktopts` struct in freed memory to achieve arbitrary kernel read/write.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://github.com/ChendoChap/pOOBs4 ChendoChap's implementation for PS4 9.00 (2021-12-13)]
* [https://web.archive.org/web/20221114191136/https://hackerone-us-west-2-production-attachments.s3.us-west-2.amazonaws.com/Y13EyQCGKEqxH8PpJgFKh5uY?response-content-disposition=attachment%3B%20filename%3D%22exploit.c%22%3B%20filename%2A%3DUTF-8%27%27exploit.c&response-content-type=text%2Fx-c%2B%2Bsrc&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQGK6FURQZUKBWFOX%2F20221114%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221114T190929Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOL%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJGMEQCIFEUV16y5O0IfDfbCmJ%2F6CNBjc6kmS%2BLdyYBPFSMIVMSAiADc6fvThSy0kmHFzOgAuurPiybfKCotgtPfJV7%2BW%2BFISrVBAjb%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAMaDDAxMzYxOTI3NDg0OSIMz0dZbvRJU9aGlVs8KqkENy%2FVEqF6TYz2HV%2F9sZELOz%2BpxTJWSgQJD3vCru6Qzggs8Xgdri4orYmQzZKvAvhNa2npS%2F86NUBQwqurS2QL5yc7Sb0ZZn%2FcJnIA%2BBsk5lwmZyKy8WAo4Lug8AtID3L8mD5RRFBojcoyIvpbxXHakUn95b%2F44fV4W%2BvufW9YhsYK1FuM%2F0B6bRNUec5ny%2Fqla1KwOnjv7SINSCxdufU8sC1zTQ9RFNsYtNsOMDFPOQAR%2FAXomotb63jvMJROdCkcvoGPfozkJjYg5atl3d44fO%2FSfyYteUZB%2BIJwchX1HlAVK2vxrPuO%2FJTN9XzJvQsHjJFluix9rxBPmpROxI%2Ffi6NuDs0I2uv0%2BvCuGRpqcSqtXUKc3TRb5nQoNUsJDcMF9hXRio37LorziEo6N5Q7sDsygd0vOq6lNQqMZh8gyOwSpcSfsE9U0uMTIUXV9in8%2BF4k3F%2FLH4HzRpDIPJaSm%2FBGKlrFiTXdVExPGYkgJHdEIPL%2FPykEOaS3JXXcZlTrV7QQEUuq5a4gEZad8WHShcDOHoOujd5GTJmpctChhpDI3SrXdH%2BN%2B4h2venOtXxjRoYKemEWa4LFrj7rvynFDv2jijqCHdkMnGJo3bdGns7rEdPaeHSyVZSiWAY1MWwuYFYRkZIxq%2BlILvy1Mitp%2FEe70ZQ63pmir99p8dGiOYNKe%2FFoJI6zZm4uYVa%2Fxuwf3sD8Je6plXBy4%2BaPzbkQ6EY5BxGr%2FSdMnzDTiMqbBjqqAZeQf4BVmDmE50Upkzo0uDY9tVuKTV7pmJ8dSXhwZbOE5bjaUYBn6fgRxYFOfSf3QX6u1VSnbyDicpmDYkt4yuz%2BU7R%2Bx68pJY1%2BQyb7aGRmVSrm7lrTwGqz%2BcsOohl6cwONvLgfHPhztGD1qDRbS2cjXGcF30AR1cS0LbLq6zax8x2SnH8MfnGoAY3KI%2FTMRRzWA7qMETPrAEWYzRgGzqLkk%2FddHKZBLC4U&X-Amz-SignedHeaders=host&X-Amz-Signature=4a8fe44640d605e3ea252fe41d6b7d83c72aa082c7eb17e3d11d85b32d609b50 TheFloW's PoC for FreeBSD 9 and 12]
* [https://github.com/sleirsgoevy/ps4jb PS4 6.72-7.02 WebKit + Kernel Exploit implementation by sleirsgoevy]
* [https://github.com/ChendoChap/ps4-ipv6-uaf PS4 5.05-7.02 WebKit + Kernel Exploit implementation by ChendoChap]


==== Patched ====
==== Patched ====
'''Yes''' in PS4 9.03 FW and PS5 4.50 FW
'''Yes''' in PS4 7.50 FW and in PS5 5.00 or 5.02 FW. Not working in PS5 FWs <= 2.70.
----
----


=== FW <= 7.55 - IP6_EXTHDR_CHECK Double Free (CVE-2020-9892) ===
=== FW <= 5.07 - BPF Race Condition (Yielding Double Free()) ===


==== Credits ====
==== Analysis ====
* 2019-09-15 tuexen for finding the FreeBSD vulnerability [https://reviews.freebsd.org/D21664]
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/FreeBSD/PS4%205.05%20BPF%20Double%20Free%20Kernel%20Exploit%20Writeup.md Specter's Writeup of the 5.05 BPF Race Condition]
* 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. [https://twitter.com/theflow0/status/1324687305018408961]
* 2021-01-12 TheFloW for disclosing publicly the PS4 vulnerability. [https://hackerone.com/reports/943231]
* 2021-01-20 sleirsgoevy for making a first working exploit for FreeBSD 9 [https://twitter.com/sleirsgoevy/status/1351689713564979200]
* 2021-03-03 sleirsgoevy for making a second working exploit for FreeBSD 9 [https://twitter.com/sleirsgoevy/status/1367098280736399368]
* 2021-03-12 sleirsgoevy for making the first public usable exploit for PS4 7.50-7.55 (https://twitter.com/sleirsgoevy/status/1370481212813348865)


==== Analysis ====
==== Bug Description ====
* [https://reviews.freebsd.org/D21664 Fix handling of Hop-by-Hop options over the loopback interface commits review (2019-09-15 to 2020-05-07)]
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).
* [https://support.apple.com/en-us/HT211288 Apple iOS 13.6 and iPadOS 13.6 Security Update (2020-07-24)]
* [https://support.apple.com/en-us/HT211289 Apple macOS Catalina 10.15.6 Security Update (2020-07-24)]
* [https://hackerone.com/reports/943231 TheFloW's report of the exploit with undisclosed PS4 and FreeBSD 9 PoCs]
* [https://github.com/google/security-research/security/advisories/GHSA-gxcr-cw4q-9q78 TheFloW's writeup and PoC for XNU (2020-07-26)]
* [https://github.com/freebsd/freebsd-src/commit/68e0e5a673c5026c68dba62314a2e58ad1533cfd#diff-816eb9feee4ece60d3c6e8933a75baf4fcfbdce0284500d86ac80e24827a19c8 Vulnerability adviced by TheFloW for exploitation (2018-02-05)]


==== Bug Description ====
==== Exploit Implementation ====
Memory corruption can be achieved by sending fragmented IPv6 packets to loopback interface due to poor and inconsistent use of IP6_EXTHDR_CHECK.
* [http://crack.bargains/505k/ PS4 5.05 WebKit + Kernel Exploit]
* [https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit PS4 5.05 WebKit + Kernel Exploit Source]


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.
==== Patched ====
'''Yes''' in 5.50 FW
----


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.
=== FW <= 4.55 - BPF Race Condition (Yielding UaF) ===


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.
==== Analysis ====
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/FreeBSD/PS4%204.55%20BPF%20Race%20Condition%20Kernel%20Exploit%20Writeup.md Specter's Writeup of the 4.55 BPF Race Condition]


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%.
==== 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 ====
==== Exploit Implementation ====
* [https://github.com/google/security-research/security/advisories/GHSA-gxcr-cw4q-9q78 TheFloW's writeup and PoC for XNU (2020-07-27)]
[http://crack.bargains/455/ PS4 4.55 WebKit + Kernel Exploit]<br/>
* [https://gist.github.com/sleirsgoevy/ff591bfdc3a6f7573ed2388b018b31ec sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)]
[https://github.com/Cryptogenic/PS4-4.55-Kernel-Exploit PS4 4.55 WebKit + Kernel Exploit Source]
* [https://asciinema.org/a/385584 Demonstration video of sleirsgoevy's first exploit PoC for FreeBSD 9 (2021-01-20)]
 
* [https://gist.github.com/CelesteBlue-dev/de46d9e94823f0a6cf4b3b40ad635c14 Specter's kernel panic PoC for PS4 Web browser (2021-01-15)]
* [https://gist.github.com/CelesteBlue-dev/16303965ffea7e0a2c7c1d763cc721ec CelesteBlue's kernel panic PoC for PS4 Kit fSELF (2021-01-15)]
* [https://github.com/dayzerosec/PS4-Kernel-Exploit-Stream WiP exploit code by Specter and tihmstar (2021-02-24)]
* [https://gist.github.com/sleirsgoevy/35722572b0096f9acfd76a97b5678bed sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)]
* [https://asciinema.org/a/396409 Demonstration video of sleirsgoevy's second exploit PoC for FreeBSD 9 (2021-03-03)]
* [https://github.com/sleirsgoevy/ps4jb2/blob/75x/src/jb.c sleirsgoevy's implementation for PS4 7.5x (2021-03-12)]
* [https://gist.github.com/Cryptogenic/448fd98813ab5a93182fb9620c013e17 Specter's implementation for FreeBSD 9 (2021-03-24)]
 
==== Patched ====
==== Patched ====
'''Yes''' in 8.00 FW
'''Yes''' in 4.70 FW
----
----


=== FW <= 7.02 - IPV6_2292PKTOPTIONS UaF (yielding arbitrary kernel R/W) (CVE-2020-7457) ===
=== FW <= 6.00 ?6.02? - sys_getcontext Information Leak (kASLR defeat) (CVE-2018-17155) ===
 
==== 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. [https://twitter.com/Fire30_/status/1280228173888831490]
* 2020-07-06 TheFloW for publishing publicly a PoC leading to code execution on FreeBSD. [https://twitter.com/theflow0/status/1280224554393178122]
* sleirsgoevy and ChendoChap for porting the PoC to PS4 and chaining it with the 6.72 and 7.02 WebKit exploits.
* SIE for not patching this vulnerability on PS5 even when patched on PS4.
* TheFlow for announcing that PS5 kernel was exploited: [https://twitter.com/theflow0/status/1457362920501829636 TheFloW's PS5 kernel exploit announcement (2021-11-07)] and later that it was that same vulnerability that was present in PS5 FW 3.00-4.51.


==== Analysis ====
==== Analysis ====
* [https://hackerone.com/reports/826026 TheFloW's hackerone report of the PS4 kernel exploit with a FreeBSD 9-12 PoC]
* https://www.cvedetails.com/cve/CVE-2018-17155/
* [https://www.freebsd.org/security/advisories/FreeBSD-SA-20:20.ipv6.asc FreeBSD Security Advisory FreeBSD-SA-20:20.ipv6]
* coming soon by CelesteBlue
* [https://www.freebsd.org/security/patches/SA-20:20/ipv6.patch FreeBSD patch for FreeBSD-SA-20:20.ipv6]
* [https://hackerone.com/reports/1441103 TheFloW's hackerone report of the PS5 kernel exploit]


==== Bug Description ====
==== 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.
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().
 
Another description: There is a race and use-after-free vulnerability in the FreeBSD kernel IPv6 socket handling. A missing synchronization lock in the `IPV6_2292PKTOPTIONS` option handling in `setsockopt` permits racing `ip6_setpktopt` access to a freed `ip6_pktopts` struct. This exploit overwrites the `ip6po_pktinfo` pointer of a `ip6_pktopts` struct in freed memory to achieve arbitrary kernel read/write.


==== Exploit Implementation ====
==== Exploit Implementation ====
* [https://web.archive.org/web/20221114191136/https://hackerone-us-west-2-production-attachments.s3.us-west-2.amazonaws.com/Y13EyQCGKEqxH8PpJgFKh5uY?response-content-disposition=attachment%3B%20filename%3D%22exploit.c%22%3B%20filename%2A%3DUTF-8%27%27exploit.c&response-content-type=text%2Fx-c%2B%2Bsrc&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQGK6FURQZUKBWFOX%2F20221114%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221114T190929Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOL%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJGMEQCIFEUV16y5O0IfDfbCmJ%2F6CNBjc6kmS%2BLdyYBPFSMIVMSAiADc6fvThSy0kmHFzOgAuurPiybfKCotgtPfJV7%2BW%2BFISrVBAjb%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAMaDDAxMzYxOTI3NDg0OSIMz0dZbvRJU9aGlVs8KqkENy%2FVEqF6TYz2HV%2F9sZELOz%2BpxTJWSgQJD3vCru6Qzggs8Xgdri4orYmQzZKvAvhNa2npS%2F86NUBQwqurS2QL5yc7Sb0ZZn%2FcJnIA%2BBsk5lwmZyKy8WAo4Lug8AtID3L8mD5RRFBojcoyIvpbxXHakUn95b%2F44fV4W%2BvufW9YhsYK1FuM%2F0B6bRNUec5ny%2Fqla1KwOnjv7SINSCxdufU8sC1zTQ9RFNsYtNsOMDFPOQAR%2FAXomotb63jvMJROdCkcvoGPfozkJjYg5atl3d44fO%2FSfyYteUZB%2BIJwchX1HlAVK2vxrPuO%2FJTN9XzJvQsHjJFluix9rxBPmpROxI%2Ffi6NuDs0I2uv0%2BvCuGRpqcSqtXUKc3TRb5nQoNUsJDcMF9hXRio37LorziEo6N5Q7sDsygd0vOq6lNQqMZh8gyOwSpcSfsE9U0uMTIUXV9in8%2BF4k3F%2FLH4HzRpDIPJaSm%2FBGKlrFiTXdVExPGYkgJHdEIPL%2FPykEOaS3JXXcZlTrV7QQEUuq5a4gEZad8WHShcDOHoOujd5GTJmpctChhpDI3SrXdH%2BN%2B4h2venOtXxjRoYKemEWa4LFrj7rvynFDv2jijqCHdkMnGJo3bdGns7rEdPaeHSyVZSiWAY1MWwuYFYRkZIxq%2BlILvy1Mitp%2FEe70ZQ63pmir99p8dGiOYNKe%2FFoJI6zZm4uYVa%2Fxuwf3sD8Je6plXBy4%2BaPzbkQ6EY5BxGr%2FSdMnzDTiMqbBjqqAZeQf4BVmDmE50Upkzo0uDY9tVuKTV7pmJ8dSXhwZbOE5bjaUYBn6fgRxYFOfSf3QX6u1VSnbyDicpmDYkt4yuz%2BU7R%2Bx68pJY1%2BQyb7aGRmVSrm7lrTwGqz%2BcsOohl6cwONvLgfHPhztGD1qDRbS2cjXGcF30AR1cS0LbLq6zax8x2SnH8MfnGoAY3KI%2FTMRRzWA7qMETPrAEWYzRgGzqLkk%2FddHKZBLC4U&X-Amz-SignedHeaders=host&X-Amz-Signature=4a8fe44640d605e3ea252fe41d6b7d83c72aa082c7eb17e3d11d85b32d609b50 TheFloW's PoC for FreeBSD 9 and 12]
* QuickHEN by CelesteBlue (v2 not released yet)
* [https://github.com/sleirsgoevy/ps4jb PS4 6.72-7.02 WebKit + Kernel Exploit implementation by sleirsgoevy]
* KitHEN by CelesteBlue (not released yet)
* [https://github.com/ChendoChap/ps4-ipv6-uaf PS4 5.05-7.02 WebKit + Kernel Exploit implementation by ChendoChap]


==== Patched ====
==== Patched ====
'''Yes''' in PS4 7.50 FW and in PS5 5.00 or 5.02 FW. Not working in PS5 FWs <= 2.50.
'''Yes''' somewhere between 6.00 and 6.20 FW
----
----


=== FW <= 5.07 - BPF Race Condition (Yielding Double Free()) ===
=== FW <= 4.07 - sys_thr_get_ucontext Information Leak (kASLR defeat) ===


==== Analysis ====
==== Analysis ====
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/FreeBSD/PS4%205.05%20BPF%20Double%20Free%20Kernel%20Exploit%20Writeup.md Specter's Writeup of the 5.05 BPF Race Condition]
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/%22NamedObj%22%204.05%20Kernel%20Exploit%20Writeup.md#vector-sys_thr_get_ucontext Specter's Writeup]


==== Bug Description ====
==== 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).
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 ====
==== Exploit Implementation ====
* [http://crack.bargains/505k/ PS4 5.05 WebKit + Kernel Exploit]
[https://github.com/Cryptogenic/PS4-4.05-Kernel-Exploit PS4 4.05 WebKit + Kernel Exploit]
* [https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit PS4 5.05 WebKit + Kernel Exploit Source]


==== Patched ====
==== Patched ====
'''Yes''' in 5.50 FW
'''Yes''' in 4.50 FW
----
----


=== FW <= 4.55 - BPF Race Condition (Yielding UaF) ===
=== FW <= 4.05 - NamedObj Type Confusion (Yielding UaF) ===


==== Analysis ====
==== Credits ====
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/FreeBSD/PS4%204.55%20BPF%20Race%20Condition%20Kernel%20Exploit%20Writeup.md Specter's Writeup of the 4.55 BPF Race Condition]
* Chaitlin Tech for having been the first to show they had pwned PS4 FW 4.01 at Geekpwn convention. (2016-10-24)
[https://www.youtube.com/watch?v=KLkKql31d44 official video], [https://twitter.com/ChaitinTech/status/790945929624948736 tweet 1], [https://twitter.com/ChaitinTech/status/790947840495267841 tweet 2], [https://twitter.com/ChaitinTech/status/790949072429428737 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 ====
* [https://fail0verflow.com/blog/2017/ps4-namedobj-exploit/ fail0verflow's writeup on the PS4 1.01-4.05 namedobj kernel exploit] (2017-10-19)
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/NamedObj%20Kernel%20Exploit%20Overview.md Specter's first writeup] (2017-10-20)
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/%22NamedObj%22%204.05%20Kernel%20Exploit%20Writeup.md Specter's writeup on his PS4 4.05 implementation] (2017-12-28)
* [https://github.com/RPCSX/rpcsx/blob/0bbab3eae53d01afbcdb16e97043b58e26fb54bd/orbis-kernel/src/sys/sys_sce.cpp#L469 Reimplementation of the sys_namedobj_create function in the RPCSX emulator]
* [https://wololo.net/2023/09/04/ps4-ps5-reverse-engineering-101-the-basics-of-ps4-exploits/ Short analysis by wololo (2023-09-04)]


==== Bug Description ====
==== 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).
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 ====
==== Exploit Implementation ====
[http://crack.bargains/455/ PS4 4.55 WebKit + Kernel Exploit]<br/>
* [https://github.com/Cryptogenic/PS4-4.05-Kernel-Exploit PS4 4.05 WebKit + Kernel Exploit]
[https://github.com/Cryptogenic/PS4-4.55-Kernel-Exploit PS4 4.55 WebKit + Kernel Exploit Source]


==== Patched ====
==== Patched ====
'''Yes''' in 4.70 FW
'''Yes''' in 4.06 FW
 
==== Tested ====
Works on FWs 4.00-4.05. On <= 3.70 FW we have not found a way to leak the target object, but it might be doable as Fail0verflow did it on 1.01.
----
----


=== FW <= 6.00 ?6.02? - sys_getcontext Information Leak (kASLR defeat) (CVE-2018-17155) ===
=== FW <= ?4.05? - amd64_set_ldt Heap Overflow (CVE-2016-1885) ===
 
==== Credits ====
* 2016-10-25 This vulnerability was discovered and researched by Francisco Falcon from Core Exploit Writers Team
* 2016-10-25 Revised patch to address a problem pointed out by ahaha from Chaitin Tech.


==== Analysis ====
==== Analysis ====
* https://www.cvedetails.com/cve/CVE-2018-17155/
* https://www.freebsd.org/security/advisories/FreeBSD-SA-16:15.sysarch.asc
* coming soon by CelesteBlue
* https://www.coresecurity.com/core-labs/advisories/freebsd-kernel-amd64setldt-heap-overflow
* https://web.archive.org/web/20161028222346/https://www.securityfocus.com/archive/1/archive/1/537812/100/0/threaded
* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-1885
* https://www.mail-archive.com/svn-[email protected]/msg132464.html
* https://svnweb.freebsd.org/base?view=revision&revision=296956
* https://wololo.net/2016/10/26/details-surface-ps4-4-01-jailbreak-potentially-enough-public-release-soon


==== Bug Description ====
==== 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().
The IA-32 architecture allows programs to define segments, which provides based and size-limited view into the program address space. The memory-resident processor structure, called Local Descriptor Table, usually abbreviated LDT, contains definitions of the segments. Since incorrect or malicious segments would breach system integrity, operating
systems do not provide processes direct access to the LDT, instead they provide system calls which allow controlled installation and removal of segments.
 
A special combination of sysarch(2) arguments, specify a request to uninstall a set of descriptors from the LDT. The start descriptor is cleared and the number of descriptors are provided. Due to lack of sufficient bounds checking during argument validity verification, unbound zero'ing of the process LDT and adjacent memory can be initiated from usermode.
 
sysarch is syscall #165 on FreeBSD 9.1 and on PS4. Sony removed set_ldt between System Software version 1.76 and 4.05, according to Red-EyeX32.


==== Exploit Implementation ====
==== Exploit Implementation ====
* QuickHEN by CelesteBlue (v2 not released yet)
* KitHEN by CelesteBlue (not released yet)


==== Patched ====
==== Patched ====
'''Yes''' somewhere between 6.00 and 6.20 FW
'''Yes''' in some FW <= 4.05 and >= 2.00 as set_ldt was removed. The PS4 is maybe not vulnerable because of a possible lack of 32bit implementation for syscalls.
----


=== FW <= 4.07 - sys_thr_get_ucontext Information Leak (kASLR defeat) ===
==== Tested ====
 
Not yet.
==== Analysis ====
[https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/%22NamedObj%22%204.05%20Kernel%20Exploit%20Writeup.md#vector-sys_thr_get_ucontext Specter's Writeup]
 
==== 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 ====
[https://github.com/Cryptogenic/PS4-4.05-Kernel-Exploit 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)
[https://www.youtube.com/watch?v=KLkKql31d44 official video], [https://twitter.com/ChaitinTech/status/790945929624948736 tweet 1], [https://twitter.com/ChaitinTech/status/790947840495267841 tweet 2], [https://twitter.com/ChaitinTech/status/790949072429428737 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 ====
* [https://fail0verflow.com/blog/2017/ps4-namedobj-exploit/ fail0verflow's writeup on the 1.01-4.05 namedobj kernel exploit] (2017-10-19)
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/NamedObj%20Kernel%20Exploit%20Overview.md Specter's first writeup] (2017-10-20)
* [https://github.com/Cryptogenic/Exploit-Writeups/blob/master/PS4/%22NamedObj%22%204.05%20Kernel%20Exploit%20Writeup.md 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 ====
[https://github.com/Cryptogenic/PS4-4.05-Kernel-Exploit 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 have not found a way to leak the target object, but it might be doable as Fail0verflow did it on 1.01.
----
----


Line 1,665: Line 1,537:
* Discovered by yifan lu (2017-02-19), plutoo and Proxima (2018-08-09), Davee (2018-12-29) for PS Vita, by flatz (2021-12-18) for PlayStation 4.
* Discovered by yifan lu (2017-02-19), plutoo and Proxima (2018-08-09), Davee (2018-12-29) for PS Vita, by flatz (2021-12-18) for PlayStation 4.


=== Bug description ===
==== Bug description ====
 
The PS4 Crypto Coprocessor (CCP) interface in Secure Kernel has a bug that allows to dump (or better saying, bruteforce) key rings from SAMU. A crypto flaw was in the ability to issue HMAC operation with key length stricly lower than 16. For example, by setting it to 1 you can bruteforce key bytes one by one by comparing HMAC result with HMAC result with known partial key.
 
This trick may work on other crypto hardware as well if it does not restrict key lengths. Amazingly, Intel Secure Key Storage (SKS) of CSME subsystem also has a bug allowing to brute-force any key slot, but the issue exists at hardware level - insecure design of the keys distribution to crypto engines (AES, SHA, RC4). Intel did not recognize the bug arguing that to access SKS the CSME privileged arbitrary code execution is required, but SKS is exactly designed to protect the ROM generated keys from CSME firmware...
 
This exploit can be used to dump the PFS AES XTS and HMAC keys of a specific PS4 game PKG. Then one can use maxton's LibOrbisPkg or flatz's pkg_pfs_tool to unpack this PKG file.
 
It also lets one retrieve portability master keys. They decrypt blobs (stored in non-secure world, like in [[SceShellcore]]) that contain the portability keys.
 
Below is a sample code to dump some "raw" keys (as named by flatz).
<source lang="C">
unsigned int key_count = 0x160;
unsigned int max_key_size = 0x40;
unsigned int *key_ids = (unsigned int *) malloc (key_count * 4);
unsigned int key_id = 0;
while (key_id < 0x160) {
    key_ids[key_id] = key_id;
    key_id++;
}
uint8_t* key_data = NULL;
size_t key_data_size = 0;
dump_raw_keys(key_ids, key_count, max_key_size, &key_data, &key_data_size);
hexdump(&key_data, &key_data_size);
</source>
 
A sample code to dump portability keys is available on [https://github.com/SiSTR0/ps4-hen-vtx/compare/master...jocover:ps4-hen-vtx:samu_key_dump#diff-e44475b3203baef04439ee15f01629a5752685028fc9118e3d2087dab7379698R908 line 908 of kpayload/source/samu_dump.c]. Note that not all keys are used as some may be deprecated or added with System Software revisions.


The PS4 Crypto Coprocessor (CCP) interface in Secure Kernel has a bug that allows to dump (or better saying, bruteforce) key rings from SAMU.
Dumped savedata keys would be per-save, as the dumped key ring should only contain the derivated key (XTS) but not the one used to generate it.
That is how AES/HMAC keys from PFS, portability keys, VTRM keys, etc can be retrieved. A crypto flaw was in the ability to issue HMAC operation with key length stricly lower than 16. For example, by setting it to 1 you can bruteforce key bytes one by one by comparing HMAC result with HMAC result with known partial key.


This trick may work on other crypto hardware as well if it does not restrict key lengths. Amazingly, Intel Secure Key Storage (SKS) of CSME subsystem also has a bug allowing to brute-force any key slot, but the issue exists at hardware level - insecure design of  the keys distribution to crypto engines (AES, SHA, RC4). Intel did not recognize the bug arguing that to access SKS the CSME privileged arbitrary code execution is required, but SKS is exactly designed to protect the ROM generated keys from CSME firmware...
Finally, one can retrieve its per-console VTRM keys (which are notably used for per-account securities like for act.dat and [[RIF]]).


This can be used to dump the AES XTS key and HMAC key of a specific PS4 game PKG. Then one can use maxton's LibOrbisPkg or flatz's pkg_pfs_tool to unpack this PKG file.
However, master keyrings are the 0, 1, and 2 ones and cannot be dump them with this trick because they get locked during the [[bootprocess]] and cannot be read nor written nor copied to other keyrings. See also [https://wiki.henkaku.xyz/vita/Cmep_Key_Ring_Base PS Vita keyrings].


==== Analysis ====
==== Analysis ====
Line 1,679: Line 1,576:
* https://twitter.com/qlutoo/status/1027691272369262594
* https://twitter.com/qlutoo/status/1027691272369262594
* https://www.lolhax.org/2019/01/02/extracting-keys-f00d-crumbs-raccoon-exploit/
* https://www.lolhax.org/2019/01/02/extracting-keys-f00d-crumbs-raccoon-exploit/
* https://twitter.com/flat_z/status/1472243592815169546
* [https://twitter.com/flat_z/status/1472243592815169546 Short explanation by flatz (2021-12-18)]


==== Implementation ====
==== Implementation ====


* [https://github.com/jocover/ps4-hen-vtx/releases/tag/pfs_dump Compiled payload for PS4 5.05 by jogolden]
* [https://github.com/jocover/ps4-hen-vtx/releases/tag/pfs_dump Compiled payload for PS4 5.05 by jogolden (2023-03-18)]
* [https://github.com/jocover/ps4-hen-vtx/tree/samu_key_dump Implementation for PS4 5.05 by jogolden]
* [https://github.com/jocover/ps4-hen-vtx/tree/samu_key_dump Implementation for PS4 5.05 by jogolden (2023-03-18)]
* [https://gist.github.com/flatz/22215327864d7512e52268f9c9c51cd8 Exploit PoC for PS4 7.55 by flatz]
* [https://github.com/SiSTR0/ps4-hen-vtx/compare/master...jocover:ps4-hen-vtx:samu_key_dump Minimal implementation for PS4 5.05 by jogolden (2023-03-18)]
* [https://gist.github.com/flatz/22215327864d7512e52268f9c9c51cd8 Exploit PoC for PS4 7.55 by flatz (2021-12-18)]


==== Patched ====
==== Patched ====
Line 1,801: Line 1,699:
It was also not present on 1.76 and below, so probably appeared when Sony worked on adding ASLR in PS4 Kernel. Also note that Matroska kernel is present on 3.15 even though there is no Kernel ASLR in this version.
It was also not present on 1.76 and below, so probably appeared when Sony worked on adding ASLR in PS4 Kernel. Also note that Matroska kernel is present on 3.15 even though there is no Kernel ASLR in this version.


== Hardware Exploits ==
== Hardware ==


=== PCIe man-in-the-middle attack ===
=== PCIe man-in-the-middle attack ===

Latest revision as of 02:10, 19 December 2024

Usermode Exploits (Game Savedata)[edit | edit source]

PS1 games savedata exploits[edit | edit source]

See PS1 Emulation for a list of candidate games.

See PS1 Dev Wiki for a list of PS1 savedata exploits.

PS2 games savedata exploits[edit | edit source]

See PS2 Emulation for a list of candidate games.

See PS2 Dev Wiki for a list of PS2 savedata exploits.

PSP games savedata exploits[edit | edit source]

See PSP Emulation for a list of candidate games.

See PSP Dev Wiki for a list of PSP savedata exploits.

PS4/PS5 PS2emu sandbox escape (mast1c0re)[edit | edit source]

Advantages of the PS4/PS5 PS2emu sandbox escape exploit over most WebKit exploits:

  • Bigger kernel attack surface (more usermode privileges) versus WebKit very restricted and becoming more and more with firmware revisions. For example, the PS2emu process uses libkernel_sys, which supports nmount and so mounting of system partitions, whilst neither libkernel_web nor regular libkernel do.
  • 100% reliable versus WebKit exploits becoming less and less stable with firmware revisions
  • Firmware agnostic (ROP-less code execution) versus almost one WebKit revision every three firmware update

Credits[edit | edit source]

  • CTurt for discovering these vulnerabilities in September 2021.
  • CTurt for public disclosure on twitter (2022-09-14).
  • flatz, balika011, theflow0, chicken(s), PlayStation for helping CTurt.
  • McCaulay for sharing publicly his implementation in February 2023.

Analysis[edit | edit source]

Bug Description[edit | edit source]

After getting code execution in a PS2onPS4 game using a savedata exploit, it is possible to exploit the PS2 emulator to get x86-64 usermode ROP execution. It is then possible, without a kernel exploit, to load another PS2 game in the emulator with a compatibility rate based on the PS2 emulator configuration.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

No as of PS4 FW 11.50 and PS5 FW 8.00. Using the PS2onPS4 game Okage Shadow King, the exploit should work starting from PS4 FW 3.15 and PS5 FW 1.00.

PS4/PS5 game savedata Lua exploit[edit | edit source]

Credits[edit | edit source]

Bug description[edit | edit source]

Some PS4 (and maybe PS5) games, in disc version (usually also available in PS Store version, some even in free demo version, but potentially patched), can be exploited as they allow the user to execute Lua code by crafting an evil save data. By running malicious Lua code, the attacker can escape the Lua sandbox and obtain usermode arbitrary read-write then ROP chain execution in usermode.

On PS Vita, you can simply install the DRM demos, the same way as you would for Bitter Smile Demo (see h-encore by TheFloW).

If you have access to the PS4/PS5 PS Store, you can simply buy the trial version to test it.

Artemis and MUGEN engines are known to use Lua and so are vulnerable to various sandbox escape exploits.

Most of Artemis games automatically load save9999.dat file from save data folder when the game boots. By editing this file, one can load custom LUA scripts.

Game boots -> "save9999.dat" is loaded -> "inject.iet" is loaded -> "inject.lua" is loaded.

You might have to create a different save9999.dat file for each game as the Lua interpreter version might differ.

On Windows, you have access to luasocket and os.execute. However, on PS Vita/PS4/PS5, you have limited access.

You have to copy PS Vita/PS4/PS5 savedata files to the console.

Vulnerable games[edit | edit source]

See Artemis Engine for a list of candidate games.

Confirmed exploitable games:

  • Raspberry Cube (CUSA16074)
  • Aibeya (CUSA17068)
  • Hamidashi Creative (CUSA27389)
  • Hamidashi Creative Demo (CUSA27390)

Other games that may use Lua scripts:

Analysis[edit | edit source]

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

No as of PS4 FW ?12.00? and PS5 FW 7.61.

Usermode Exploits (BD-J)[edit | edit source]

Advantages of most BD-J exploits over most WebKit exploits:

  • Bigger kernel attack surface (more usermode privileges) versus WebKit very restricted and becoming more and more with firmware revisions. For example, the BD-J process uses libkernel_sys, which supports nmount and so mount of system partitions, whilst neither libkernel_web nor regular libkernel do.
  • 100% reliable versus WebKit exploits becoming less and less stable with firmware revisions
  • Firmware agnostic (ROP-less code execution) versus almost one WebKit revision every three firmware update
  • JIT enabled allowing to write a kernel exploit in C versus writing in assembly and JavaScript since around FW 2.00

FW <= 10.71 - BD-JB2 - Path traversal sandbox escape by TheFloW[edit | edit source]

Credits[edit | edit source]

  • TheFloW for the exploits finding (before 2023-09-11), ethical disclose to SCE (2023-09-22) and public disclosure (2023-10-25)
  • Previous BD-JB contributors

Analysis[edit | edit source]

Bug Description[edit | edit source]

Basing on the BD-JB1 exploit files, in /bdmv/bdjo.xml changing bdjo/applicationManagementTable/baseDirectory to a path of the form `file:///app0/cdc/lib/../../../disc/BDMV/JAR/00000.jar` allows loading a JAR Java executable file. This vulnerability can efficiently replace the UserPreferenceManagerImpl to extend the supported System Software versions range compared to BD-JB1.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

No as of PS4 FW 10.71 (maybe patched on PS4 FW 11.00). Yes on PS5 FW 8.00. Probably not patched on PS3.

FW <= 9.00 - BD-JB - Five vulnerabilities chained by TheFloW[edit | edit source]

Credits[edit | edit source]

  • CTurt for FreeDVDBoot exploit on PS2 and the idea to hack BD-J on PS3 and PS4 on twitter (2020-06-27)
  • TheFloW for finding these vulnerabilities (around 2021-10-24) and disclosing them publicly on hackerone and hardwear.io (2022-06-10)
  • Sleirsgoevy for writing the first public implementation (2022-06-16)
  • psxdev, sleirsgoevy and John Törnblom for the public implementations

Analysis[edit | edit source]

Bug Description[edit | edit source]

This exploit chain alone does not allow one to run pirated games on PS4 or PS5 as there is not enough RAM allowed in the BD-J process and there are other constraints.

TODO!: ADD DESCRIPTION OF EACH ONE OF THE 5 BUGS:

#1 - userprefs hijack (?PS3?, PS4, PS5)[edit | edit source]

com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl userprefs hijack leads to classes instantiation under privileged context.

#2 - com.oracle.security.Service (?PS3?, PS4, not PS5)[edit | edit source]

com.oracle.security.Service leads to privileged constructor call.

#3 - com.sony.gemstack.org.dvb.io.ixc.IxcProxy leading to privileged method call (?PS3?, PS4, PS5)[edit | edit source]

com.sony.gemstack.org.dvb.io.ixc.IxcProxy leads to privileged method call.

#4 - JIT compiler hack (?PS3?, PS4, not PS5)[edit | edit source]

JIT compiler hack leads to usermode arbitrary RW and usermode arbitrary code execution.

#5 - UDF buffer overflow (?PS3?, PS4, PS5)[edit | edit source]

The UDF driver in kernel contains a buffer overflow. Note that no implementation of the UDF kernel exploit has ever been done even by TheFloW, only a kernel panic PoC.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

No as of PS4 FW 9.00 and PS5 FW 4.03. At least partially patched on PS4 FW 9.50 and PS5 FW 5.00.

On PS4 FW 9.03 and PS5 FW ?4.50?, the bug #5 (UDF) has been patched.

Usermode Exploits (WebKit)[edit | edit source]

WebKit sources[edit | edit source]

WebKit sources

WebKit sources archived currently up to version 11.00. Useful for people that cannot access PlayStation URLs and also for when Sony will inevitably stop hosting the sources.

FW ?6.00-11.52? - get_by_id_with_this associated with ProxyObject can leak JSScope objects[edit | edit source]

Credits[edit | edit source]

  • Alexey Shvayka for discovery (2021-05-05) and incremental fixes (from 2021-05-20 to 2024-07-31)
  • Filip Pizlo for reviewing and not pushing it (2021-06-10)
  • Ahmad Saleem for reminding WebKit that it is still not fixed (2022-09-03)
  • Yusuke Suzuki and Justin Michaud for fix commits review.

Analysis[edit | edit source]

Bug Description[edit | edit source]

  • TODO: document the general vulnerability coming from |this|.

According to the spec [1], `var base = { foo }; with (base) foo();` should be called with `this` value of `base`, which is why FunctionCallResolveNode moves resolved scope to thisRegister(). That is arguably a bad design, and there is an effort [2] to abolish using JSScope as `this` value.

When `this` value is accessed by JS code, it's being sanitized via ToThis (JSScope replaced with `undefined`), yet not in case of `super.property` access calling into ProxyObject `get` trap, which passes raw `this` value as receiver parameter, leaking JSScope to be exploited.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Maybe

Tested[edit | edit source]

Not tested yet on PS4 or PS5.


FW ?6.00-11.52? - Integer underflow in JSC genericTypedArrayViewProtoFuncCopyWithin (CVE-2023-38600)[edit | edit source]

Credits[edit | edit source]

  • anonymous researcher for discovering the vulnerability and reporting it to Zero Day Initiative (2023-05)
  • Yusuke Suzuki and Mark Lam for fixing the bug in WebKit (2023-07-31)
  • Hossein Lotfi for publishing a writeup (2023-10-18)

Analysis[edit | edit source]

Bug Description[edit | edit source]

It is required to recompute length properly when resize happens during TypedArray copyWithin.

copyWithin's side effectful operation can resize resizable ArrayBuffer. WebKit has a code catching this and recompute the appropriate copy count again, but it can overflow if `to` or `from` are larger than the newly updated `length`. The patch handles this case correctly: returning since there is no copying content in this case.

The issue was patched by aborting the copy if either of the two variables to or from is larger than the updated length.

The values used during the exploit were sane as they went through a sanitizer function. However, in the final stage, the values were updated without checking if there are inside the buffer length bounds.

According to PS4 WebKit source code for System Software version 11.00, not only it is not patched but it uses code from 2021! Looking at a version close to one in the PS4 source code for System Software version 11.00, it should be exploitable.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Maybe in FW 11.50.

Tested[edit | edit source]

Not tested yet on PS4 nor PS5. To test on PS4 11.00.


FW ?6.00-11.00? - CloneDeserializer::deserialize() UaF (CVE-2023-28205) leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • Clément Lecigne of Google's Threat Analysis Group and Donncha Ó Cearbhaill of Amnesty International’s Security Lab for discovering the vulnerability and reporting it to Apple (2023-04-10)
  • Justin Michaud, Mark Lam and JonWBedard for fixing the bug in WebKit (2023-04-17)
  • abc (anonymous) for making an OOM PoC for PS4 and PS5 (2024-12-01)

Analysis[edit | edit source]

Bug Description[edit | edit source]

Previously, CloneDeserializer::deserialize() was storing pointers to newly created objects in a few Vectors, in a MarkedArgumentBufferBase. This is problematic because the GC is not aware of Vectors, and cannot scan them. Instead, CloneDeserializer::deserialize() should store cell pointers in a MarkedVector.

The PoC code triggers a use-after-free (UaF) vulnerability by delaying the addition of Map and Date objects, which allows the garbage collector (GC) to free them. This can potentially lead to accessing freed objects to corrupt memory. Then it cannot avoid executing a release assert that causes an Out-Of-Memory crash.

The WebKit patch refactors the MarkedArgumentBuffer class into a MarkedVector template class.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes on PS4 FW ?11.00? and PS5 FW ?8.00?.

Tested[edit | edit source]

Tested working on PS4 FWs ? and PS5 FWs 6.00-7.61.


FW 6.00-9.60 - FrameLoader::loadInSameDocument() UaF (CVE-2022-22620) leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • Sergei Glazunov, Google Project Zero, for reporting the bug in 2013-01 and answering Maddie Stone's questions in 2022 (2013)
  • Maddie Stone, Google Project Zero, for sharing a write-up describing this vulnerability (2022-06-14)
  • abc (anonymous) for making an OOM PoC for webkit-gtk, PS4 and PS5 (2023-10-03) then making an arbitrary RW PoC (PSFree) for webkit-gtk, PS4 6.00-9.60 and PS5 1.00-5.50 (2023-10-24)
  • CelesteBlue for testing and porting abc' PSFree to PS4 6.00-9.60 and PS5 1.00-5.50 (2023-11-04)

Analysis[edit | edit source]

Bug Description[edit | edit source]

The History API allows access to (and modification of) a stack of the pages visited in the current frame, and these page states are stored as a SerializedScriptValue. The History API exposes a getter for state, and a method replaceState() which allows overwriting the "most recent" history entry.

The bug is that FrameLoader::loadInSameDocument() takes the state as an argument (stateObject), but does not increase its reference count. Only a HistoryItem object holds a reference to the stateObject. loadInSameDocument() can trigger a callback into user JavaScript through the onblur event. The user's callback can call replaceState() to replace the HistoryItem's state with a new object, therefore dropping the only reference to the stateObject. When the callback returns, loadInSameDocument() will still use this free'd object in its call to statePopped(), leading to the use-after-free.

When loadInSameDocument() is called it changes the focus to the element its scrolling to. If we set the focus on a different element prior to loadInSameDocument()'s execution, the blur event will be fired on that element. Then we can free the stateObject by calling replaceState() in the onblur event handler.

The bug is triggered by history.back() with the target state whose URL contains a hash. Here's a Proof-of-Concept that will crash:

input = document.body.appendChild(document.createElement('input'));

foo = document.body.appendChild(document.createElement('a'));
foo.id = 'foo';

function pop(event) {
    alert('you get a crash after you close this alert');
    event.state; // use the freed SerializedScriptValue
    alert('WebKit version not vulnerable');
}

addEventListener('popstate', pop);

history.pushState('state1', '', location + '#foo'); // URL with a hash
history.pushState('state2', '');

setTimeout(() => {
    input.focus();
    input.onblur = () => {
        history.replaceState('state3', '')
    };
    setTimeout(() => {
        history.back(); // trigger loadInSameDocument()
    }, 1000);
}, 1000);

The user may then trigger a double free and escalate it into an arbitrary read primitive via spraying WTF::StringImpls like in the buildBubbleTree() UaF exploit. The read primitive is used to create the addrof() primitive and is used to save addresses of buffers that will be used to modify a SerializedScriptValue. After freeing the StringImpl (triple free), SerializedScriptValues are sprayed via the postMessage() JavaScript function until one is allocated using the previously freed memory.

The method used to modify the fields of the StringImpl for arbitrary reads can be used can also be used to modify the SerializedScriptValue. Appropriate fields can modified to have deserialization create a JSC::JSArrayBufferView whose m_vector field will point to another JSArrayBufferView, which will be called the worker. The user can modify the worker's fields for arbitrary read/write. Deserialization is done via msg.data where msg is the MessageEvent from postMessage().

A way to know if the system is vulnerable is the appearance of the input HTML element in the PoC page. If the HTML input field stays focused (blue outline) after the second timeout, then the vulnerability is not present. Note that Maddie Stone's PoC will never trigger any sort of crash on release builds as it was meant for builds with memory sanitation that can detect UaFs.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes on PS4 FW 10.00 and PS5 FW 6.00.

The patch changes the stateObject argument to loadInSameDocument from a raw pointer, SerializedScriptValue*, to a reference-counted pointer, RefPtr<SerializedScriptValue>, so that loadInSameDocument now increments the reference count on the object.

Tested[edit | edit source]

Tested working on PS4 FWs 6.00-9.60 and PS5 FWs 1.00-5.50. PS4 FWs <= 5.56 are invulnerable as the HTML input field stays focused (blue outline) after second timeout whilst it should not if the console were exploitable.


FW 9.00-9.04 - WebCore::CSSFontFaceSet vulnerabilities leading to arbitrary RW[edit | edit source]

There are many FontFaceSet vulnerabilities. Explore [1].

Credits[edit | edit source]

  • Myles C. Maxfield (litherum), Apple, for adding the vulnerability in WebKit (2016-02-22) then fixing and so disclosing the vulnerability (2021-08-26)
  • Maddie Stone, Google Project Zero, for sharing 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)
  • sleirsgoevy for making the first exploit PoC for Safari (2021-10-24) and the first exploit PoC for PS4 FW 9.00-9.04 and PS5 FW 3.00-4.50 (2021-10-27)

Analysis[edit | edit source]

Bug Description[edit | edit source]

Description in WebKit fix commit by Myles C. Maxfield:

After r256659, asking for a failed CSSFontFace's families() returns nullopt. It is possible to add a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed and do not update our internal data structures, because there's no need to - we cannot do anything useful with a failed font. If you _then_ try to remove the font from the CSSFontFace, we do not call families(), but instead just pull out the raw m_families member, and look in our internal data structures for it, but we do not 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 do not 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.

Description by sleirsgoevy:

On PS4 FWs 9.00-9.04 the constructor returns with an exception, but to C++ code that ignores it. That is how an invalid font is created in the first place. On earlier PS4 FWs the exception is propagated to JavaScript.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes on PS4 FW 9.50 and No as of PS5 FW 4.51 (need to test on PS5 FWs >=5.00). Not working on PS4 FWs <9.00 and PS5 FWs <2.10.

Might have been introduced in PS4 FW 3.50 and before PS5 FW 1.00 according to dates (need to check). However the vulnerability cannot be exploited in some conditions depending on how WebKit was compiled. For example, on PS4 FWs 7.55-8.52 and PS5 FWs <= 2.00, the FontFaceSet constructor returns with an exception that is propagated to JavaScript, preventing exploitation this way.

Tested[edit | edit source]

Tested working on PS4 FWs 9.00-9.04 and PS5 FWs 3.00-4.51. Untested: PS5 FWs 2.10-2.70 and >=5.00.


FW 6.00-7.55 - WebCore::ValidationMessage::buildBubbleTree() UaF leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • 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 ([2]) and sharing the code (2020-12-10)
  • sleirsgoevy for porting (although with low success rate) to PS4 FWs 7.00-7.02

Analysis[edit | edit source]

Bug Description[edit | edit source]

  • 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[edit | edit source]

Patched[edit | edit source]

Yes in 8.00 FW.

Tested[edit | edit source]

Tested working on FWs 6.00-7.55, not working on FWs <= 5.56. HTML textarea guessed addresses for FWs 6.70-7.55 are known but not for FWs 6.00-6.51 so an attacker needs to make tests to determine these addresses on FWs 6.00-6.51.


FW 6.00-6.72 - bad_hoist Type Confusion exploit (CVE-2018-4386) leading to arbirary RW[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

WebKit: JSC: BytecodeGenerator::hoistSloppyModeFunctionIfNecessary does not 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[edit | edit source]

Patched[edit | edit source]

Yes in 7.00 FW


FW 4.50-6.72 - DOMWindow::open heap UaF (CVE-2021-30849) leading to crash[edit | edit source]

Credits[edit | edit source]

  • Sergei Glazunov (from Google Project Zer0) for the exploit PoC (Jul 1, 2021)

Analysis[edit | edit source]

Bug Description[edit | edit source]

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 7.00 FW.

Tested[edit | edit source]

Vulnerable on PS4 FWs 4.50-6.72. Not vulnerable on FWs <= 4.07. Not vulnerable on FWs >=7.00 according to manual tests but need to check WebKit sources.


FW 4.50-6.20 - JSArray::shiftCountWithArrayStorage() OOB RW (CVE-2018-4441) leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 6.50 FW.

Tested[edit | edit source]

It does not work on <= 4.07 FW PS4 according to tests as the exploit fails at step "Triggering memory corruption".


FW 6.00-6.20 - JSC::arrayProtoPrivateFuncConcatMemcpy() Information Leak (CVE-2018-4358) ?leading to ASLR defeat?[edit | edit source]

Credits[edit | edit source]

  • bkth, niklasb and saelo (from phoenhex Team) for the exploit PoC in Safari (Sep 26, 2018)
  • Vultra for discovering that the exploit worked on PS4 FW 6.00 (Dec 10, 2018)

Analysis[edit | edit source]

Bug Description[edit | edit source]

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 6.50 FW

Tested[edit | edit source]

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[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Project Zer0 Bug Description

Bug Description[edit | edit source]

When JSGlobalObject::haveABadTime() is called with arrays of a different JSGlobalObject type, type confusion can occur, leading to memory corruption.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 6.00 FW


FW ?.??-4.05-5.56 - Document::adoptNode() UaF (CVE-2017-2468) leading to crash[edit | edit source]

Credits[edit | edit source]

  • Lokihardt (from Google Project Zer0) for the exploit PoC (Jan 23, 2017)
  • CelesteBlue for testing on PS4 and PS Vita (May 9, 2020)

Analysis[edit | edit source]

Bug Description[edit | edit source]

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 6.00 FW. Vulnerable at least on PS4 FWs 4.05-5.56 and PS Vita FW 3.60.


FW 4.50-5.56 - WebCore::HTMLFrameElementBase::marginHeight() Heap UaF (CVE-2016-1859) leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • Liang Chen, wushi of KeenLab, Tencent working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-03-16)

Analysis[edit | edit source]

Bug Description[edit | edit source]

The specific flaw exists within the handling of GraphicsContext objects. By manipulating a document's elements an attacker can force this object in memory to be reused after it has been freed. An attacker can leverage this vulnerability to execute code under the context of the current process.

CVE-2016-1859 is a use-after-free vulnerability that existed in the Safari web browser. A GraphicsContext object is used in the setPlatformTextDrawingMode function after it has been freed. The successful triggering of the use-after-free vulnerability itself does not allow the attacker to directly change the control flow or disclose arbitrary memory contents. However, the use-after-free yields an arbitrary-memory-write primitive by hijacking a destination pointer that will be used for the memcpy function. Once the arbitrary-memory-write primitive is achieved, the attacker sprays the heap with string objects to achieve the arbitrary-memory-read primitive. Relying on the pointer width heap alignment, the attacker can accurately predict the exact address of one of the string objects among the heap spray and pinpoint the address of member variable. At this point, the attacker can overwrite the length member variable of a string object and partially disclose the out-of-bound heap area exceeding the buffer address of the string. The partial disclosure of the heap memory allows the attacker to extend the information leak step-by-step and ultimately allows full chaining of ROP, which leads to arbitrary code execution.

Exploit Implementation[edit | edit source]

  • PoC publicly available
  • No full exploit publicly available but exploitation description is detailed

Patched[edit | edit source]

Yes in 6.00 FW. Vulnerable on PS4 FWs 4.50-5.56.


FW 4.50-5.01 - Element::setAttributeNodeNS() UaF leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

PS4 5.05 WebKit + Kernel Exploit

Patched[edit | edit source]

Yes in 5.03 FW.


FW 3.15-4.07 - Stack Uninitialized Read UaF leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • qwertyoruiop for the exploit
  • Specter for the writeup

Analysis[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 4.50 FW

Tested[edit | edit source]

Works on 3.15-4.07. Not working on <= 3.11.


FW <= ?4.05? - Type confusion in WebCore::HTMLInputElement::onSearch (CVE-2017-2354)[edit | edit source]

Credits[edit | edit source]

  • Neymar of Tencent's Xuanwu Lab working with Trend Micro's Zero Day Initiative for discovering this vulnerability (2016-11)
  • Brent Fulgham for fixing the bug in WebKit (2016-11-14)
  • Jasiel Spelman (@WanderingGlitch) for his writeup (2017-12-20)

Analysis[edit | edit source]

Bug Description[edit | edit source]

It is possible for JavaScript to change the type property of an input field. WebKit needs to gracefully handle this case.

This bug could have been prevented had it a debug check been used instead of a runtime check. In fact, WebKit has support for this type of assertion already through a RELEASE_ASSERT macro, which would have turned this exploitable bug into a simple denial-of-service by immediately and safely crashing the browser.

The fix commit of the vulnerability adds a type traits specialization so that WebKit can properly downcast InputType elements. This should be used only to call search functions on actual search input types.

Although the access violation in WebCore::TimerBase::heapPop is where we see the result of the bug, it is not the cause of the issue. The crash actually occurs as a result of reading a pointer that comes from the 'this' object. Based on that, it would seem that something is wrong with the Timer object passed into the WebCore::TimerBase::heapPop function.

This vulnerability may be the one used by Chaintin Tech with a kernel exploit on PS4 FW 4.01 at GeekPwn 2016, a Tencent Security's conference, in Shanghai Station at the Pavilion Safety Research Lab, (https://www.chaitin.cn/ps4, https://www.psxhax.com/threads/ps4-4-01-linux-installation-ksploit-demo-at-geekpwn-2016.932/)

Exploit Implementation[edit | edit source]

  • PoC by Neymar (2016-11, disclosed publicly by Jasiel Spelman on 2017-12-20):
<input id="m_input" type="search"></input>
<script type="text/javascript">
	first = true;
	m_input.addEventListener("input", function (e) {
		if(first) {
			first = false;
		}
		else {
			m_input["type"] = "image";
		}
	}, false);
</script>

Patched[edit | edit source]

Maybe in 4.06 FW

Tested[edit | edit source]

Not yet.


FW 3.15-3.70 - JSArray::sortCompactedVector() Heap UaF leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • xyz for the original exploit on PSVita (HENkaku)
  • Fire30 for porting to PS4
  • Specter for improved PS4 playground

Analysis[edit | edit source]

Bug Description[edit | edit source]

When attempting to update a vector via sortCompactedVector() - data is written based on a pointer, though the pointer is not re-updated nor nulled. When this memory in free()'d, the reference is maintained and thus memory corruption can occur.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 4.0?0? FW

Tested[edit | edit source]

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[edit | edit source]

Credits[edit | edit source]

  • Brent Fulgham for fixing the bug in WebKit (2016-05-16)

Analysis[edit | edit source]

Bug Description[edit | edit source]

"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[edit | edit source]

Patched[edit | edit source]

Yes in 3.55 FW

Tested[edit | edit source]

Works on 3.15, 3.50 FW. Maybe working on 3.51 FW.


FW <= ?2.50? - JavaScript OnLoad Handler Remote Code Execution Vulnerability (CVE-2005-1790) leading to crash or lag[edit | edit source]

Credits[edit | edit source]

  • Benjamin Tobias Franz for the vulnerability discovery (2005-11-21)
  • Stuart Pearson for the Proof of Concept on Microsoft Internet Explorer
  • Sam Sharps for the Metasploit port (2012-01)
  • Jeerum for disclosing that the vulnerability affects PS4 <=2.50 (2014-10-31).

Analysis[edit | edit source]

Bug Description[edit | edit source]

This bug is triggered when the browser handles a JavaScript 'onLoad' handler in conjunction with an improperly initialized 'window()' JavaScript function. This exploit results in a call to an address lower than the heap. The javascript prompt() places our shellcode near where the call operand points to. We call prompt() multiple times in separate iframes to place our return address. We hide the prompts in a popup window behind the main window. We spray the heap a second time with our shellcode and point the return address to the heap. I use a fairly high address to make this exploit more reliable. Microsoft Internet Explorer will crash when the exploit completes. Also, please note that Microsoft Internet Explorer must allow popups in order to continue exploitation.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Maybe

Tested[edit | edit source]

  • Working on 1.76-2.50 FW: crash. 3.00-5.50 error CE-36329-3. 4.55 lag in background TV application (for example Netflix application).

FW <= 2.03 - WebCore::CSSSelector Heap Overflow (CVE-2014-1303) leading to arbitrary RW[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 2.50 FW

Tested[edit | edit source]

  • 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[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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 usermode ASLR since about FW 1.70 so ROP chain gadgets must be relocated at runtime. This means another vulnerability allowing usermode arbitrary read is needed.
  • As usually an arbitrary read vulnerability also gives arbitrary write, and as arbitrary RW leads to usermode 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 usermode by restoring vtable.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in ? FW

Tested[edit | edit source]

  • 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[edit | edit source]

Credits[edit | edit source]

  • 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 (October 23, 2014)
  • sony for patching the exploit in FW 2.00 (October 27, 2014)
  • CTurt for the rewriting (PS4 1.76 PlayGround) and implementation with his 1.76 kexploit (December 6, 2015) [5]

Analysis[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 2.00 FW

Tested[edit | edit source]

  • Working on PS4 1.00-1.76 FW, AppleWebKit/531.3-536.26
  • Might work on PS4 FW 0.930.020.

Possible WebKit vulnerabilities[edit | edit source]

CVE-2017-7064
https://project-zero.issues.chromium.org/issues/42450258

CVE-2018-4192
https://blog.ret2.io/2018/06/13/pwn2own-2018-vulnerability-discovery/
https://blog.ret2.io/2018/06/19/pwn2own-2018-root-cause-analysis/#arrayreverse-considered-harmful
https://blog.ret2.io/2018/07/11/pwn2own-2018-jsc-exploit/

CVE-2018-4443
WebKit JSC - 'AbstractValue::set' Use-After-Free
lokihardt of Google Project Zero
2019-01-22
https://www.exploit-db.com/exploits/46071

Improper Restriction of Operations within the Bounds of a Memory Buffer

Unknown CVE
Luca Todesco (qwertyruiopz)
before 2019-08-15
https://gist.github.com/jakeajames/5ceb90ebaa34eabb3e170b5c7eb2c7d1/revisions

Resources for WebKit exploitation[edit | edit source]

https://webkit.org/blog/12967/understanding-gc-in-jsc-from-scratch/

https://googleprojectzero.blogspot.com/2019/08/jsc-exploits.html

Usermode securities[edit | edit source]

Usermode ASLR[edit | edit source]

  • Very old firmwares (<= 1.05) do not 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 usermode 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[edit | edit source]

  • Between 1.76 and 4.05, Sony did that to prevent WebKit exploiters from defeating usermode ASLR easily.
  • Now we have to dump entire usermode sandboxed memory, and by studying it we can defeat ASLR:

1. Chose a function (ex: __stack_chk_fail) imported from libkernel.sprx by libSceWebkit2.sprx

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.

For FW >= 6.00, for web applications, libkernel.sprx has been replaced by libkernel_web.sprx and libSceWebKit2 by libSceNKWebKit.sprx. libkernel.sprx is still used by other applications.

DEP / NX[edit | edit source]

  • "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 usermode memory then executing it.
  • 2 ways to bypass this security: JiT vulnerability (FW <= 1.76) or ROP (all FWs).

JiT removed from webbrowser[edit | edit source]

  • 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.
  • Checking the source code at ps4-oss, starting as early as FW 6.00, ENABLE_JIT=OFF for -DPORT=PlayStation4. It means that JIT functionality is completely removed from WebKit and there is no JIT coprocess that is allowed to request RWX memory to even attack. Even if there are JIT bugs that can lead us to request RWX memory in other platforms, we can't on the PS4 as there is no longer any JIT process. Unchecked all source codes, JIT process could have been removed earlier than 6.00. All exploits must use ROP.
  • Workaround is to use ROP.

Syscalls removed[edit | edit source]

Direct Syscall invocation disabled in PS4 Kernel[edit | edit source]

Between 2.00 and 2.57, SCE has disabled direct system calls by usermode, by adding some checks in the PS4 kernel. An attacker can no longer call any syscall he wants by specifying the call number in the rax register and jump directly to the call instructions part of a syscall stub. Indeed, now the PS4 (but not PS5) implementation of amd64_syscall checks the following:

  • The address in the Instruction Pointer (IP) of the call must be within the memory range of the associated libkernel module of the process,
  • The code pointed by the Instruction Pointer (IP) must follow the syscall stub format,
  • The syscall number passed in argument to amd64_syscall must corresponds to the stub's syscall number. amd64_syscall checks the stub's mov rax, syscall_number instruction.

Since PS4 version 3.00, issuing directly a syscall instruction crashes the application and gives error CE-34878-0, (SCE_KERNEL_ABORT_REASON_SYSTEM_ILLEGAL_FUNCTION_CALL), displaying the message "Kernel: The application directly issues a syscall instruction (24)".

An attacker is now forced to use wrappers provided from the libkernel / libkernel_web / libkernel_sys modules to trigger system calls.

The PS5 does not enforce the passed syscall number and thus any code can directly issue an arbitrary syscall even if the associated libkernel does not provide it.

bpf_write function stripped out of the kernel[edit | edit source]

  • 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[edit | edit source]

  • 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[edit | edit source]

  • On FW 5.50+, opening BPF is still possible in less sandboxed apps like TestKit/DevKits fSELFs. But this is useless because ioctl does not work.

Device access blocked/removed from webbrowser[edit | edit source]

  • Around 6.50-6.70, device access got blocked or removed. Now you can no longer access devices from the web browser.

Pointer poisoning in WebKit on 6.xx firmwares[edit | edit source]

  • For select types implemented by WebKit (such as JSC::JSFunction), certain pointer fields are XOR'ed by a cryptographic key generated at runtime. The key is generated once every process launch, one must recover it to unpoison the pointers.

Flush-to-Zero and Denormals-are-Zero Floating-Point environment[edit | edit source]

Subnormal numbers (also called as denormal numbers in IEEE 754 documents before the 2008 version) are treated as 0 on the PlayStation runtime environment. This isn't technically a security technique but it does inhibit any exploit that uses floating-point numbers for read/write.

An example entrypoint is WebKit where exploits have commonly used double arrays with incorrect length to read/write certain memory areas to gain arbitrary read/write or even code execution. With FTZ/DAZ, the possible 64-bit values one can write have become even more limited. Reads using double arrays are also affected. Even if the bit pattern is nonzero but encodes a subnormal, it will be read by the JavaScript engine as 0.

Kernel[edit | edit source]

FW <= 11.52 - Double free in bnet_netevent_set_queue[edit | edit source]

Credits[edit | edit source]

  • Anonymous for sharing 11.52 and 12.00 PS4 kernel dumps.
  • 2024-09-27 D-Link Turtle for diffing 11.52 and 12.00 PS4 kernel dumps.
  • 2024-10-04 SlidyBat for figuring out the bug in bnet and its impact.

Analysis[edit | edit source]

Bug Description[edit | edit source]

A double free can happen by racing calls to bnet_netevent_set_queue and bnet_netevent_unset_queue.

The lack of mutexes allowed double free as fdrop is called unconditionally in bnet_netevent_unset_queue.

See also PS Vita SceNetPs kernel module that uses similar bnet functions.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 12.00 FW. Maybe not working at all on PS5.

The bug was patched in PS4 FW 12.00 by adding some mutexes in bnet_netevent functions


FW <= 11.00 - Remote vulnerabilities in spp (yielding kernel ASLR defeat) (CVE-2006-4304 and no-CVE)[edit | edit source]

Credits[edit | edit source]

  • 2006-08-23 Martin Husemann, Pavel Cahyna for discovering the first spp bug (CVE-2006-4304) on FreeBSD 4.11-6.1.
  • 2023-09-22 TheFloW for discovering that PS4 and PS5 are vulnerable to CVE-2006-4304, discovering second spp bug, and chaining them together.
  • 2024-01-27 anonymous for reporting publicly CVE-2006-4304 as working on PS4 and PS5. See [6] and [7].
  • 2024-03 iMrDJAi for porting CVE-2006-4304 to PS4 and PS5.
  • 2024-04-25 TheFloW for disclosing his HackerOne report including the second spp bug description.
  • 2024-04-30 TheFloW for releasing his exploit code for PS4 9.00 and 11.00.

Analysis[edit | edit source]

Bug Description[edit | edit source]

A malicious PPPoE server can cause denial-of-service or remote code execution in kernel context on the PS4/PS5. It does not require any usermode code execution to be triggered. There are two vulnerabilities that can be chained together to cause remote kernel Denial of Service, kernel ASLR defeat or kernel code execution : Heap buffer overwrite and overread in sppp_lcp_RCR and sppp_ipcp_RCR (CVE-2006-4304) and Integer underflow in sppp_pap_input leading to heap-buffer overread (no-CVE).

The PS4/PS5 must be connected using an ethernet cable to a device able to trigger PPPoE requests and analyze the responses.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 11.02 FW


FW <= 9.00 - PPPoE driver remote buffer overflow (CVE-2022-29867)[edit | edit source]

Credits[edit | edit source]

  • 2021-09-24 m00nbsd for finding the vulnerability
  • 2022-05-04 martin of NetBSD for fixing the vulnerability publicly in NetBSD 8 and 9
  • 2022-05-11 m00nbsd for disclosing the vulnerability publicly on HackerOne

Analysis[edit | edit source]

Bug Description[edit | edit source]

The PlayStation 4 has a kernel PPPoE driver, that originates from NetBSD. This driver has a kernel heap overflow vulnerability, that an attacker can remotely trigger over the LAN, with the ability to control both the contents that are overflown and their sizes.

Extract of NetBSD 8.3 changelog:

sys/net/if_pppoe.c			1.179

	pppoe(4): fix CVE-2022-29867 - discovery phase local network
	mbuf corruption.
	[martin, ticket #1740]

Do not allocate mbuf clusters when the caller (eroneously) asks
for more than MCLBYTES size, instead fail the allocation.

When we have received multiple PADO offer packets in the discovery
phase, do not combine tags from different packets. We are supposed
to pick one PADO packet and continue session establishment with that.

The second bug could cause code to trigger the first and create
invalid response packets and also overwrite data outside of
the allocated mbuf cluster.

Fixes CVE-2022-29867.

Diff after fix commit in NetBSD 8:

--- src/sys/net/if_pppoe.c	2020/02/13 19:37:39	1.125.6.10
+++ src/sys/net/if_pppoe.c	2022/05/04 15:36:35	1.125.6.11
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.10 2020/02/13 19:37:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125.6.11 2022/05/04 15:36:35 sborrill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -871,6 +871,10 @@ breakbreak:;
 			}
 			sc->sc_ac_cookie_len = ac_cookie_len;
 			memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
+		} else if (sc->sc_ac_cookie) {
+			free(sc->sc_ac_cookie, M_DEVBUF);
+			sc->sc_ac_cookie = NULL;
+			sc->sc_ac_cookie_len = 0;
 		}
 		if (relay_sid) {
 			if (sc->sc_relay_sid)
@@ -886,6 +890,10 @@ breakbreak:;
 			}
 			sc->sc_relay_sid_len = relay_sid_len;
 			memcpy(sc->sc_relay_sid, relay_sid, relay_sid_len);
+		} else if (sc->sc_relay_sid) {
+			free(sc->sc_relay_sid, M_DEVBUF);
+			sc->sc_relay_sid = NULL;
+			sc->sc_relay_sid_len = 0;
 		}
 		memcpy(&sc->sc_dest, eh->ether_shost, sizeof sc->sc_dest);
 		callout_stop(&sc->sc_timeout);
@@ -1313,6 +1321,9 @@ pppoe_get_mbuf(size_t len)
 {
 	struct mbuf *m;
 
+	if (len + sizeof(struct ether_header) > MCLBYTES)
+		return NULL;
+
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL)
 		return NULL;

Exploit Implementation[edit | edit source]

  • PoC (poc.c) by m00nbsd not disclosed publicly

Patched[edit | edit source]

Yes in 9.03 FW according to Specter by diffing PS4 9.00 and 9.03 kernels


FW <= 9.00 - exFAT driver heap-based buffer overflow[edit | edit source]

Credits[edit | edit source]

  • 2021-09-15 TheFloW for finding the vulnerability
  • 2021-12-02 zecoxao for advicing to exploit the vulnerability after diffing PS4 9.00 and 9.03 kernels
  • 2021-12-13 ChendoChap, Znullptr, Specter for PS4 9.00 kernel exploit implementation release

Analysis[edit | edit source]

Bug Description[edit | edit source]

The PS4 kernel exFAT driver has a heap-based buffer overflow vulnerability that can be triggered by inserting a malicious USB storage device in PS4 in addition to having usermode code execution. Exploitation requires to flash a crafted exFAT image to a common USB storage device.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in PS4 9.03 FW and PS5 4.50 FW


FW <= 7.55 - IP6_EXTHDR_CHECK Double Free (CVE-2020-9892)[edit | edit source]

Credits[edit | edit source]

  • 2019-09-15 tuexen for finding the FreeBSD vulnerability [8]
  • 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. [9]
  • 2021-01-12 TheFloW for disclosing publicly the PS4 vulnerability. [10]
  • 2021-01-20 sleirsgoevy for making a first working exploit for FreeBSD 9 [11]
  • 2021-03-03 sleirsgoevy for making a second working exploit for FreeBSD 9 [12]
  • 2021-03-12 sleirsgoevy for making the first public usable exploit for PS4 7.50-7.55 (https://twitter.com/sleirsgoevy/status/1370481212813348865)

Analysis[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 8.00 FW


FW <= 7.02 - IPV6_2292PKTOPTIONS UaF (yielding arbitrary kernel R/W) (CVE-2020-7457)[edit | edit source]

Credits[edit | edit source]

  • 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. [13]
  • 2020-07-06 TheFloW for publishing publicly a PoC leading to code execution on FreeBSD. [14]
  • sleirsgoevy and ChendoChap for porting the PoC to PS4 and chaining it with the 6.72 and 7.02 WebKit exploits.
  • SIE for not patching this vulnerability on PS5 even when patched on PS4.
  • TheFlow for announcing that PS5 kernel was exploited: TheFloW's PS5 kernel exploit announcement (2021-11-07) and later that it was that same vulnerability that was present in PS5 FW 3.00-4.51.

Analysis[edit | edit source]

Bug Description[edit | edit source]

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.

Another description: There is a race and use-after-free vulnerability in the FreeBSD kernel IPv6 socket handling. A missing synchronization lock in the `IPV6_2292PKTOPTIONS` option handling in `setsockopt` permits racing `ip6_setpktopt` access to a freed `ip6_pktopts` struct. This exploit overwrites the `ip6po_pktinfo` pointer of a `ip6_pktopts` struct in freed memory to achieve arbitrary kernel read/write.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in PS4 7.50 FW and in PS5 5.00 or 5.02 FW. Not working in PS5 FWs <= 2.70.


FW <= 5.07 - BPF Race Condition (Yielding Double Free())[edit | edit source]

Analysis[edit | edit source]

Specter's Writeup of the 5.05 BPF Race Condition

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 5.50 FW


FW <= 4.55 - BPF Race Condition (Yielding UaF)[edit | edit source]

Analysis[edit | edit source]

Specter's Writeup of the 4.55 BPF Race Condition

Bug Description[edit | edit source]

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[edit | edit source]

PS4 4.55 WebKit + Kernel Exploit
PS4 4.55 WebKit + Kernel Exploit Source

Patched[edit | edit source]

Yes in 4.70 FW


FW <= 6.00 ?6.02? - sys_getcontext Information Leak (kASLR defeat) (CVE-2018-17155)[edit | edit source]

Analysis[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

  • QuickHEN by CelesteBlue (v2 not released yet)
  • KitHEN by CelesteBlue (not released yet)

Patched[edit | edit source]

Yes somewhere between 6.00 and 6.20 FW


FW <= 4.07 - sys_thr_get_ucontext Information Leak (kASLR defeat)[edit | edit source]

Analysis[edit | edit source]

Specter's Writeup

Bug Description[edit | edit source]

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[edit | edit source]

PS4 4.05 WebKit + Kernel Exploit

Patched[edit | edit source]

Yes in 4.50 FW


FW <= 4.05 - NamedObj Type Confusion (Yielding UaF)[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Yes in 4.06 FW

Tested[edit | edit source]

Works on FWs 4.00-4.05. On <= 3.70 FW we have not found a way to leak the target object, but it might be doable as Fail0verflow did it on 1.01.


FW <= ?4.05? - amd64_set_ldt Heap Overflow (CVE-2016-1885)[edit | edit source]

Credits[edit | edit source]

  • 2016-10-25 This vulnerability was discovered and researched by Francisco Falcon from Core Exploit Writers Team
  • 2016-10-25 Revised patch to address a problem pointed out by ahaha from Chaitin Tech.

Analysis[edit | edit source]

Bug Description[edit | edit source]

The IA-32 architecture allows programs to define segments, which provides based and size-limited view into the program address space. The memory-resident processor structure, called Local Descriptor Table, usually abbreviated LDT, contains definitions of the segments. Since incorrect or malicious segments would breach system integrity, operating systems do not provide processes direct access to the LDT, instead they provide system calls which allow controlled installation and removal of segments.

A special combination of sysarch(2) arguments, specify a request to uninstall a set of descriptors from the LDT. The start descriptor is cleared and the number of descriptors are provided. Due to lack of sufficient bounds checking during argument validity verification, unbound zero'ing of the process LDT and adjacent memory can be initiated from usermode.

sysarch is syscall #165 on FreeBSD 9.1 and on PS4. Sony removed set_ldt between System Software version 1.76 and 4.05, according to Red-EyeX32.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in some FW <= 4.05 and >= 2.00 as set_ldt was removed. The PS4 is maybe not vulnerable because of a possible lack of 32bit implementation for syscalls.

Tested[edit | edit source]

Not yet.


<= 3.15 - .symtab kernel table of symbols kept on low FWs[edit | edit source]

Credits[edit | edit source]

  • CelesteBlue for backporting kernel exploits to dump PS4 3.50 kernel (2019-05-09) and 3.15 (2019-05-25)
  • zecoxao and SocraticBliss for analysing kernel dumps

Bug description[edit | edit source]

After Sony removed .strtab since FW 1.03 and .dynstr/.dynsym since FW 2.50 from PS4 kernel binary, they still kept the .symtab one.

Patched[edit | edit source]

Yes in 3.50 FW.


<= 2.50 - .dynstr/.dynsym kernel table of symbols kept on low FWs[edit | edit source]

Bug description[edit | edit source]

After Sony removed .strtab from PS4 kernel binary since FW 1.03, they still kept the .dynstr/.dynsym one.

Patched[edit | edit source]

Yes in 2.50 FW.


FW <= 1.76 - dlclose Kernel Heap Overflow[edit | edit source]

Credits[edit | edit source]

  • 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[edit | edit source]

Analysis of sys_dynlib_prepare_dlclose PS4 kernel heap overflow (by CTurt with the help of qwertyoruiop)

Bug Description[edit | edit source]

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[edit | edit source]

Public release by kR105

Patched[edit | edit source]

Yes in 2.00 FW


FW <= 1.76 - BadIRET (CVE-2014-9322, CVE-2015-5675)[edit | edit source]

Credits[edit | edit source]

  • 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) [15], [16]
  • Volodymyr Pikhur for exploiting FreeBSD and PS4 in private (2015-09-24) [17]
  • CTurt for porting the exploit from FreeBSD 9 to PS4 (2015-12-06) [18]

Analysis[edit | edit source]

Bug Description[edit | edit source]

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 usermode memory, providing an attacker with a method of privilege escalation.

Exploit Implementation[edit | edit source]

Patched[edit | edit source]

Yes in 2.00 FW


FW ??? - setlogin Information Leak (CVE-2014-8476)[edit | edit source]

Warning: this has not been tested on PS4.

Credits[edit | edit source]

  • 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[edit | edit source]

Bug Description[edit | edit source]

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[edit | edit source]

Patched[edit | edit source]

Maybe.


<= 1.01 - .strtab/.symtab kernel table of symbols kept on very low FWs[edit | edit source]

Bug description[edit | edit source]

  • Sony used to have two tables of symbols on very low versions: .strtab/.symtab and .dynstr/.dynsym (.strtab/.symtab had all symbols, .dynstr/.dynsym had ~75% of them).

Patched[edit | edit source]

Yes in 1.03 FW. Seen in 1.01 PS4 kernel.

Kernel securities[edit | edit source]

Kernel ASLR[edit | edit source]

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[edit | edit source]

PS4 APU does not support SMEP ("Supervisor Mode Execution Prevention") so there is no way it supports SMAP ("Supervisor Mode Access Prevention"). However, in PS4 5.0x FW and above, a sort of SMAP was added to the kernel to prevent exploiters from pivoting the kernel stack pointer (RSP) to usermode memory: attempting to do so would crash the system. Sony probably added checks into the scheduler to check the stack pointer (RSP) against usermode addresses when running in kernel context. A new exploitation strategy is needed to run kernel ROP chains because an exploiters now needs to get his kernel ROP chain inside kernel memory to be executed.

SMAP bypass method: JOP[edit | edit source]

To bypass PS4 SMAP, 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 kernel ROP chain into RSP. qwertyoruiop explained: "JOP seems to work, but exploit is not reliable enough to repeat it multiple times implementing logic in-between (like on the FW 4.55 kernel bug where every primitive would re-exploit the bug). Using pure JOP logic would be long because of the need to find good instructions gadgets, and would vary a lot from a FW version to another. The strategy chosen is thread-safe and calling-convention aware, but most importantly pivot-less. We use JOP to implement a simple loop based on deref&branch logic. Every iteration runs a function prolog followed by a branch. This pushes lots of stack frames on stack, padding RSP. When loop is done, prepare call to memcpy with RDI = RSP, RSI = controlled pointer, RDX = (size of pushed stack frame * number of iterations - 1). We overwrite all fake frames but one with ROP. Memcpy will return into our first gadget, kickstarting the chain. At tail end of chain we just return into matching function epilog to resume clean execution by popping the one untouched frame. RSP never pivoted so PS4 successfully runs the kernel ROP chain."

SMAP bypass method: cli/sti[edit | edit source]

A PS4 SMAP bypass has been showed by sleirsgoevy in his 6.72 PS4 kernel exploit implementation. It consists in wrapping 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 kernel ROP execution, and other cores have no way of detecting the stack pivot, so the mitigation is defeated.

PS5 SMAP bypass method: CVE-2021-29628[edit | edit source]

A SMAP bypass has been found by m00nbsd while working on FreeBSD 12. It is named CVE-2021-29628 and affects FreeBSD 12.2 and later (til it was patched). It does not work on PS4 because PS4 kernel is based on FreeBSD 9 which did not contain the vulnerability and because PS4 SMAP does not come from FreeBSD but is custom from Sony. It used to work on PS5 before it was disclosed and patched. See CVE-2021-29628 on PS5 Dev Wiki.

CR0.WP protection[edit | edit source]

At least since PS4 System Software version 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):

  • Execute an unintended "move to cr0" instruction 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). This seems impossible on PS5 with a classic kernel exploit because of XOM.
  • Since the IDT (Interrupt Descriptor Table) is writable on FreeBSD, PS4 and PS5, 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 an "add rsp, ... ; ret" instruction, or whatever), then the UD2 instruction in the mitigation code will happily jump to it instead of the real handler, with CR0.WP cleared. To be precise, one must set up IDT handlers and point the IST (Interrupt Stack) to a ROP chain. It is required to poison the upper 16 bits of a pointer to make it non-canonical. Finally, write a custom page fault handler to run any kernel code you want. This technique proposed by sleirsgoevy since PS4 System Software version 6.51 was later adapted to PS5. However, this method slows down system performance compared to native execution because alone it can just run kernel ROP chains and it requires knowledge of gadgets positions. So on PS4, it is better to only use the IDT trick initially in a kernel exploit to patch kernel and allow non-ROP code execution for example by allowing JIT. On PS5, it is required to bypass XOM so an hypervisor exploit is required.

Secure Modules[edit | edit source]

<= ?7.55? - Missing HMAC key length check in Secure Kernel leading to Partial SAMU KeyRings bruteforce[edit | edit source]

Credits[edit | edit source]

  • Discovered by yifan lu (2017-02-19), plutoo and Proxima (2018-08-09), Davee (2018-12-29) for PS Vita, by flatz (2021-12-18) for PlayStation 4.

Bug description[edit | edit source]

The PS4 Crypto Coprocessor (CCP) interface in Secure Kernel has a bug that allows to dump (or better saying, bruteforce) key rings from SAMU. A crypto flaw was in the ability to issue HMAC operation with key length stricly lower than 16. For example, by setting it to 1 you can bruteforce key bytes one by one by comparing HMAC result with HMAC result with known partial key.

This trick may work on other crypto hardware as well if it does not restrict key lengths. Amazingly, Intel Secure Key Storage (SKS) of CSME subsystem also has a bug allowing to brute-force any key slot, but the issue exists at hardware level - insecure design of the keys distribution to crypto engines (AES, SHA, RC4). Intel did not recognize the bug arguing that to access SKS the CSME privileged arbitrary code execution is required, but SKS is exactly designed to protect the ROM generated keys from CSME firmware...

This exploit can be used to dump the PFS AES XTS and HMAC keys of a specific PS4 game PKG. Then one can use maxton's LibOrbisPkg or flatz's pkg_pfs_tool to unpack this PKG file.

It also lets one retrieve portability master keys. They decrypt blobs (stored in non-secure world, like in SceShellcore) that contain the portability keys.

Below is a sample code to dump some "raw" keys (as named by flatz).

unsigned int key_count = 0x160;
unsigned int max_key_size = 0x40;
unsigned int *key_ids = (unsigned int *) malloc (key_count * 4);
unsigned int key_id = 0;
while (key_id < 0x160) {
    key_ids[key_id] = key_id;
    key_id++;
}
uint8_t* key_data = NULL;
size_t key_data_size = 0;
dump_raw_keys(key_ids, key_count, max_key_size, &key_data, &key_data_size);
hexdump(&key_data, &key_data_size);

A sample code to dump portability keys is available on line 908 of kpayload/source/samu_dump.c. Note that not all keys are used as some may be deprecated or added with System Software revisions.

Dumped savedata keys would be per-save, as the dumped key ring should only contain the derivated key (XTS) but not the one used to generate it.

Finally, one can retrieve its per-console VTRM keys (which are notably used for per-account securities like for act.dat and RIF).

However, master keyrings are the 0, 1, and 2 ones and cannot be dump them with this trick because they get locked during the bootprocess and cannot be read nor written nor copied to other keyrings. See also PS Vita keyrings.

Analysis[edit | edit source]

Implementation[edit | edit source]

Patched[edit | edit source]

Yes since a PS4 FW between 7.55 (unpatched) and 9.00 (patched).


<= 4.07 - Crashdumps encryption using symmetrical key and same key across software revisions[edit | edit source]

Credits[edit | edit source]

  • Discovered by ps4_enthusiast of fail0verflow (2017-12-27).

Bug description[edit | edit source]

The PS4 crashdumps encryption keys never changed between 1.01 and 3.15 FWs. Then between 3.50 and 4.07 FWs, Sony developers changed the keys many times but still used symmetrical key.

Analysis[edit | edit source]

Patched[edit | edit source]

Yes on PS4 FW 4.50 by using asymmetrical key. Tested between 1.01 and 4.07 PS4 FWs.


<= 3.70 - Reused keys lead to decryption of any PS4 1.00- 3.70 usermode SELF[edit | edit source]

Bug description[edit | edit source]

Sony reused encryption keys from System Software version 1.00 to 3.70 for PS4 usermode modules. As a result, any PS4 usermode module from those FWs can be decrypted on a PS4 running FW between 1.00 and 3.70.

Patched[edit | edit source]

Yes in 4.00 FW with the introduction of new keyset.


<= 2.50 - IDPS leak in sceSblAuthMgrDriveData on low retail FWs[edit | edit source]

Credits[edit | edit source]

  • Discovered by flatz (2018-08-27).

Bug analysis[edit | edit source]

By calling the sceSblAuthMgrDriveData kernel function on a PS4, which is a wrapper to the Authentication Secure Module associated fonction, it is possible to dump its IDPS (Console ID). It is possible because some PlayStation 4 operating system developer from Sony forgot to encrypt sceSblAuthMgrDriveData output by the Authentication Secure Module and that is how it was patched later. The PS4 IDPS is stored encrypted in an EID block in the Serial Flash.

To dump the PS4's IDPS, execute sceSblAuthMgrDriveData(0, in_buf, 0x160, out_buf, 0xA4, 1). Pass 0x160 bytes at 0x90C00 from sflash0s1.crypt into `in_buf` and dump `out_buf`.

Analysis[edit | edit source]

Implementation[edit | edit source]

Patched[edit | edit source]

Yes in PS4 3.00 retail FW. Works on any PS4 TestKit/DevKit FW.


<= ?1.62? - Missing version checks allow decryption of any GEN3 PUP[edit | edit source]

Credits[edit | edit source]

  • Discovered by flatz (2016).

Bug description[edit | edit source]

A bug in the Secure Module that handle PUP decryption allows any PS4 GEN3 on FW 1.62 or below to decrypt any GEN3 PUP (retail, TestKit, DevKit, Beta) with a version above 1.00 (post-prototype).https://github.com/SocraticBliss/ps4-pup_decrypt

The Secure Module mailbox code does not reset state after SMI checks failure, so to decrypt an arbitrary PUP, you need to ignore the mailbox error after executing the PupDecryptHeader command (1).

Implementation[edit | edit source]

Any PS4 PUP decryptor kernel payload that ignore the mailbox error could be used. See PUP#Decrypter_(first_step) for implementations.

Patched[edit | edit source]

Yes around PS4 FW 1.70.

Secure Kernel[edit | edit source]

<=?3.70? - Kernel ASLR collision leads to decrypted kernel partial leak - Matroska vulnerability[edit | edit source]

Credits[edit | edit source]

  • anonymous for sharing decrypted PS4 6.00b1 kernel file (2019-03-20)
  • shykelit for dumping 3.55 Jig PS4 kernel (2019-04-17)
  • zecoxao for discovering Matroska kernels and giving them that name (2019-04-18)
  • z80 for dumping 3.70 PS4 DevKit kernel (2019-04-18)
  • AlexAltea for reverse engineering kernel, ubios and vbios
  • Many people for sharing dumps of their PS4 kernels
  • CelesteBlue for backporting kernel exploits to dump PS4 4.74 kernel (2018-11-18), 3.50 (2019-05-09), 3.70 (2019-05-15) and 3.15 (2019-05-25)

Bug description[edit | edit source]

The kernel memory contains the kernel fSELF but with decrypted data, which in turn can be decompressed to grab ubios, vbios, kernel boot code and partial kernel.

By dumping PS4 kernel memory with a kernel exploit, in order to dump the x86 kernel, we sometimes find a strange fSELF. This fSELF is only partial: 1.5MB, but should be 17MB if it was the x86 kernel. Luckily it is only compressed, not encrypted. When uncompressing it using offzip, we can see only 1 segment. That is because the other segments have been cutted and the segment is incomplete. But we can see that it is the decrypted x86 kernel, as confirmed by diffing with anonymously shared decrypted full x86 kernel. In the decrypted x86 kernel, you can see a second ELF header. It is once again only compressed and not encrypted, and this is what zecoxao named the "Matroska kernel".

Sadly, this vulnerability is random, as it relies on kernel ASLR which is itself random. So depending on the System Software version, as modules have different sizes, kernel ASLR has more (100% on 3.15, 3.50 and 3.70) or less (1% on ?4.74?) chances to leak the Matroska kernel. It is unknown how we could improve this success rate. Maybe by instead of rebooting, causing a kernel panic or rebooting to recovery, entering rest mode then disconnecting power supply. A way to accelerate the process would be to scan kernel memory and check magics to see if there is a Matroska kernel. If there is, dump it, else reboot and cross fingers.

Note: vbios seems to be the same from 3.50 to 6.00b1 at least.

Analysis[edit | edit source]

Since PS4 3.50 FW, ASLR (Address Space Layout Randomization) has been enabled in PS4 kernel.

During PS4 boot, the following operations are executed:

  • the encrypted x86 kernel is loaded from Serial Flash
  • the secure kernel decrypt the x86 kernel SELF, without uncompressing it to some fixed address: at 0xFFFFFFFF84000000 in the case of 3.xx and 5.xx firmwares or 0xFFFFFFFFC4000000 in the case of 4.xx.
  • the secure kernel randomly chooses a base address for Kernel ASLR, starting from 0xFFFFFFFF80000000.
  • the secure kernel uncompresses the x86 kernel to the address determined by Kernel ASLR.

On some PS4 boots, Kernel ASLR base address can be very near of Matroska kernel address and the lack of memory separation and wipe renders the dump of Matroska kernel possible with only kernel memory read access.

Patched[edit | edit source]

Yes partially in 4.00 FW by increasing the kernel ASLR base address but it might have reappeared in newer versions like since 5.00 or 4.74, but with lower success rate.

It was also not present on 1.76 and below, so probably appeared when Sony worked on adding ASLR in PS4 Kernel. Also note that Matroska kernel is present on 3.15 even though there is no Kernel ASLR in this version.

Hardware[edit | edit source]

PCIe man-in-the-middle attack[edit | edit source]

  • First done on PS4 FW 1.01 by failoverflow on PS4 launch!
  • Detailed at 33c3: 33c3 slides by Marcan
  • Permits kernel and usermode dumping

Syscon glitching[edit | edit source]

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[edit | edit source]

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:

Arbitrary code execution in AMD SMU by incomplete hashing and bounds checking[edit | edit source]

Credits[edit | edit source]

  • Rudolf Marek discovered, disclosed to AMD then publicly through the following timeline:
    • Christmas 2013 - SMU firmware was analyzed from public AMD documentation
    • April 2014 - Bug was found in the SMU firmware
    • 2014-04-30 - Request to AMD sent
    • 2014-05-15 - Reply by AMD
    • 2014-05-16 - Encrypted communication, sending details
    • 2014-07-09 - AMD acknowledges the problem
    • In the meanwhile - Occasional communication
    • 2014-11-25 - AMD sends to Rudolf Marek a list of AMD AGESA versions which contain a fix

Bug description[edit | edit source]

A security vulnerability, discovered by Rudolf Marek in April 2014, in the recent AMD processors (Trinity and Richland, of FM2 socket) allows arbitrary code execution on the AMD System Management Unit (SMU).

It consists in two bugs in the SMU of AMD Trinity and Richland CPUs:

  • The AMD SMU firmware is not padded so some part (256 bytes) of the runtime firmware is not correctly covered by protection cover (0x55 0xaa ...).
  • The AMD SMU request function incorrectly checks bounds.

Similar, but not same problem affected AMD Kabini and Kaveri CPUs. It also likely affects PS4 as its APU is AMD Kabini/Jaguar.

Thanks to this vulnerability, the AMD SMU firmware can be dumped. From the dump, the Keys#AMD_SMU_Keys HMAC-SHA1 key was obtained.

Thanks to the knowledge of this key, the AMD SMU firmware could possibly be replaced by a custom one.

Analysis[edit | edit source]

Patched[edit | edit source]

Maybe after 2014-11-25, SMU vulnerability found by Rudolf Marek could have been patched on PS4 as AMD released patches: the fixed SMU firmware is part of updated AMD AGESA.

Untested - Arbitrary code execution in AMD SMU by custom firmware[edit | edit source]

Credits[edit | edit source]

  • Rudolf Marek for his exploit and documentation (2014)
  • zecoxao for public disclose (2023-05-17)

Bug description[edit | edit source]

It turns out that the "debug key" used to hash "debug" firmwares from AMD SMU effectively works on all retail (CEX) versions of the PS4 AMD SMU firmware as well.

According to zecoxao, as SMU is very privileged in PS4 (but not so privileged in PS5), one could probably dump his own PS4 keys/fuses with AMD SMU code execution. This could possibly lead to decryption of latest PS4 games, SEN access on PS4 running out-of-date System Software, conversion of any PS4 between CEX and DEX, as well as decrypting the PS4 Kernel and derived binaries.

Analysis[edit | edit source]

Patched[edit | edit source]

Maybe on recent PS4 firmwares with a BIOS update that would require a different and possibly more secure digest or signature.