PS4/PS5 Exploitation For Noobs; Part I: Internals
TODO: add more stuff and finish.
I have, for a long time, been specialising in “exotic systems”, targeting undocumented environments such as iOS, its most secure components iBoot and SecureROM, and I want to document the internals of the PS4 and PS5 operating systems in a very organised, steamlined and detailed manner, in what is perhaps the first public endeavour of its kind, omitting semi-private forums and disorganised wikis. As such:
What follows is a documentation of Orbis, the operating system of the PlayStation 4, and of its successor on the PlayStation 5.
I. Origins
For our purposes, unless told otherwise, PS4 and PS5 are interchangeable.
The PS4’s operating system is Orbis, based off FreeBSD 9. It includes a list of proprietary syscalls, appended to this work and documented to the best of my ability, with prototypes and other useful information. Sony had shipped BSD code before, the PS3’s network stack was BSD-derived, and the PlayStation Vita’s operating system was built on BSD foundations as well. Futhermore explaining this, the BSD licence lets a vendor modify a kernel without forcing an open-source release. FreeBSD in particular brings a mature TCP/IP stack, a complete POSIX userland, the GEOM storage framework, and a hardened virtual memory system that had already survived two decades of servers. Sony needed an operating system for a machine that is, under the hood, an x86-64 PC with unusual memory and an unusual GPU. FreeBSD 9 was the closest starting point that came with no strings attached.
Orbis is a codename that leaked in 2012, a year before the console shipped in November 2013, and stuck to the operating system itself. The PS5’s operating system descends from Orbis directly and was codenamed Prospero and reporting based on firmware analysis puts its base at a later FreeBSD, 11 or 12. Treat the two systems as one lineage with two security architectures.
Sony built a second, private layer on top of FreeBSD; a dynamic linker that loads signed modules at runtime through dedicated syscalls, a sandbox for every title, a package and filesystem format of its own, and a security processor that holds every key that matters and answers to the kernel through a narrow command interface BUS. Orbis is thus best understood as a junction of two systems sharing one kernel.
I.II. Hardware
The PS4 is built around a single AMD SoC (system on a chip), codenamed Liverpool. The CPU is eight Jaguar cores at 1.6 GHz, ordinary x86-64, two clusters of four sharing an L2 cache each and a Marvell 88W8897 Wi-Fi+BT chipset. The GPU sits on the same die with 18 compute units of AMD’s Graphics Core Next architecture, 1.84 teraflops, sharing one pool of 8 GB of GDDR5 with the CPU. There is no separate video memory. The GPU reaches memory over two buses: Garlic, built for speed with high bandwidth and no coherency guarantees, used for rendering data the CPU has finished with and Onion, the slow cache-coherent path used for data the CPU and GPU share.
Below the main chip sits the southbridge, Aeolia on the launch model and Belize on the later revisions. It is an isolated computer in its own right, an ARM processor with its own RAM running its own BSD-derived system, and it owns everything that must keep working while the main system sleeps: network downloads in rest mode, USB, the disc drive, storage. The hard drive hangs off the southbridge. Ever downloaded a game overnight? That was Aeolia.
Inside the main die, next to the CPU cores, sits SAMU, the System Architecture Management Unit, a secure processor (akin to SecureROM) with its own firmware, its own RAM, and custody of the cryptographic material that decrypt signed executables, the keys that unwrap title content, the root of the chain that starts at the boot ROM. The main CPU can ask SAMU to perform operations to prevent user-mode/kernel-mode from having access to them.
The PS5 keeps the general architecture, with an eight Zen 2 cores CPU at up to 3.5 GHz, a RDNA 2 GPU with 36 compute units reaching 10.28 teraflops. Memory doubles to 16 GB of GDDR6. Storage became the famous part with a custom NVMe SSD and an I/O complex beside it with dedicated DMA engines, coherency engines, and a hardware decompressor for the Kraken format, built so that compressed data moves from flash to RAM at speeds the CPU alone could never sustain. And the security architecture hardens. The PS5 kernel runs under a hypervisor whose main visible job is to enforce execute-only memory on the kernel itself.
I.III. Code execution
Orbis OS allows execution of ELF binaries, relying on the hardware security mechanisms described above, without verifying binary integrity/chain of trust, allowing any app sandbox escape (or vulnerability) to be substantially easier to exploit. See: difficulties of exploiting iOS systems.
The executable format is FreeBSD’s ELF64 for x86-64, wrapped in a container Sony calls SELF, signed ELF. Every eboot.bin on every disc and every download is a SELF, an container with a header and an unique magic, a table of the keys that encrypt the ELF segments, and metadata the kernel and SAMU need before execution. The ELF inside is a position-independent executable with Sony-specific program headers and dynamic tags.
One such header, PT_SCE_DYNLIBDATA, carries the module’s import and export data. The dynamic section carries a build-specific fingerprint.
The SELF segments are encrypted and SAMU is involved in getting them decrypted, that much is real. But there is no iOS-style SSV chain where every page of every binary is hash-checked against a signature the kernel trusts before it is allowed to run, and keeps being checked. Once you are in, you are in! This is why PS4 jailbreaks, once a kernel exploit lands, end up running unsigned code with very little further complex exploitation, and why the same class of bug on other mobile platforms is the start of a much longer week.
The rest of the loading model is modules; Userland is not statically linked the way a FreeBSD program is, a title is an eboot plus a set of .prx modules, each one a SELF, loaded at runtime by the kernel. You ask the kernel to load a module, you get a handle back, you resolve symbols by name with dynlib_dlsym. The kernel does the relocations and keeps the module list. The syscalls for this are in the appendix, they are the ones with dynlib_ in the name, and there are a lot of them.
Every title also runs in a sandbox. Its own mount namespace, inside a per-title directory under /mnt/sandbox with a randomised suffix, mounted as its root, and very little visibility of anything else. There are syscalls, is_in_sandbox and sandbox_path, for this.
Memory rules are the standard, nothing interesting; W^X, a page is writable or executable and flipping it is a syscall. (k)ASLR on top, the executable is position-independent and lands at a random base.
On PS5 all of this still applies, with the hypervisor underneath it, only the memory adversarial usage differs because of the execute-only kernel described above. The public PS5 work of the last few years is mostly people fighting the hypervisor, which tells you where the actual security budget went this generation.
Proprietary syscalls, a working list
Orbis keeps the FreeBSD syscall table and appends Sony’s entries. This list is partial, grouped by what the syscalls are for.
| Category | Function/Item | Description |
|---|---|---|
| Dynamic linking | dynlib_load_prx |
Loads a .prx and returns a handle. |
| Dynamic linking | dynlib_unload_prx |
Releases a loaded .prx. |
| Dynamic linking | dynlib_dlsym |
Resolves a symbol by name in a loaded module. |
| Dynamic linking | dynlib_get_list / dynlib_get_info |
Enumerate and describe loaded modules. |
| Dynamic linking | dynlib_do_copy_relocations / dynlib_process_needed_and_relocate |
The kernel-mode linker stuff. |
| Dynamic linking | dynlib_get_proc_param |
Returns the loading process’s parameter block. |
| Synchronisation | evf_create, evf_open, evf_wait, evf_trywait, evf_set, evf_clear, evf_cancel, evf_delete, evf_close |
Event flags family. Titles use these instead of the POSIX ones for anything that matters. |
| Synchronisation | osem_create, osem_open, osem_wait, osem_trywait, osem_post, osem_cancel, osem_delete, osem_close |
Semaphores family. Titles use these instead of the POSIX ones for anything that matters. |
| Memory and process | batch_map |
Applies a batch of map and unmap operations in one call; exists for the graphics stack. |
| Memory and process | mdbg_call |
The debugger’s entry point. |
| Memory and process | get_proc_type_info |
Describes a process to the system. |
| Memory and process | query_memory_protection |
Reports what protection a mapping actually has. |
| Identity and sandbox | is_in_sandbox / sandbox_path |
As above. |
| Identity and sandbox | get_self_auth_info |
Returns the caller’s authority information, which the system checks before letting a title ask SAMU for things. |
| Identity and sandbox | get_sdk_compiled_version / get_ppr_sdk_compiled_version |
Report which SDK generation a binary was built with. |
| Platform services | regmgr_call |
Talks to the registry manager, the key-value store the system software uses for its own settings. |
| Platform services | opmc_set_ctr / opmc_get_ctr |
Performance counters. |
| Platform services | pfs_crypto_open / pfs_crypto_close |
Deal with the package filesystem’s keys. |
| Platform services | get_random |
Returns bytes from the platform random source. |