Skip to content
RCE Disclosed report Advanced

bd-j exploit chain

The report describes five vulnerabilities in PlayStation firmware that can be chained to achieve JIT execution and run arbitrary payloads. The chain includes insecure deserialisation, arbitrary class instantiation, permission bypass, a write-what-where primitive in the compiler, and a buffer overflow in the UDF driver.

Andy Nguyen Follow

Originally disclosed on HackerOne

Bounty$20,000 High View original
  • Triaged in 11 days
  • Fixed in 5 months
  • Paid in 18 days
  • Disclosed after 8 months

Summary by the program

Hey PlayStation!

Below are 5 vulnerabilities chained together that allows an attacker to gain JIT capabilities and execute arbitrary payloads. The provided payload triggers a buffer overflow that causes a kernel panic. Please consider each of the vulnerabilities individually. AFAIK, this is the first exploit chain that is being submitted to you :)

Vulnerabilities

[MEDIUM] [PS4] [PS5] Vulnerability 1

The class com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl deserializes the userprefs file under privileged context using readObject() which is insecure:

Java
    private void initPreferences() {
        try {
            UserPreferenceManagerImpl.preferences = AccessController.doPrivileged((PrivilegedExceptionAction<String[][]>)new ReadPreferenceAction());
        }
        catch (PrivilegedActionException ex) {}
        if (UserPreferenceManagerImpl.preferences == null) {
            UserPreferenceManagerImpl.preferences = new String[UserPreferenceManagerImpl.PREFERENCES.length][];
        }
        if (UserPreferenceManagerImpl.preferences[3] == null) {
            UserPreferenceManagerImpl.preferences[3] = new String[] { "26" };
            this.savePreferences();
        }
    }
Java
    private static class ReadPreferenceAction implements PrivilegedExceptionAction
    {
        public Object run() throws Exception {
            String[][] array = null;
            ObjectInputStream objectInputStream = null;
            try {
                objectInputStream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(RootCertManager.getOriginalPersistentRoot() + "/userprefs")));
                array = (String[][])objectInputStream.readObject();
            }
            finally {
                if (objectInputStream != null) {
                    objectInputStream.close();
                }
            }
            return array;
        }
    }

An attacker can replace the userprefs file with a malicious serialized object to instantiate classes under privileged context. On older firmwares such as 5.05, where the commit https://github.com/openjdk/jdk/commit/020204a972d9be8a3b2b9e75c2e8abea36d787e9#diff-2c19943dd71743c3de69aa065025e753ca2e1f3b7ebc798e0d954de75d995de5 is not present, exploitation of this vulnerability is easy: An attacker can instantiate a ClassLoader subclass to call defineClass with all permissions and finally bypass the security manager.

[MEDIUM] [PS4] Vulnerability 2

The class com.oracle.security.Service contains a method newInstance which calls Class.forName on an arbitrary class name. This allows arbitrary classes, even restricted ones (for example in sun.), to be instantiated. This works for all classes with public constructors that have single arguments. The check in newInstance can be bypassed by calling com.oracle.ProviderAdapter.setProviderAccessor on a custom ProviderAccessor implementation.

Java
        if (!this.registered) {
            if (ProviderAdapter.getService(this.provider, this.type, this.algorithm) != this) {
                throw new NoSuchAlgorithmException("Service not registered with Provider " + this.provider.getName() + ": " + this);
            }
            this.registered = true;
        }

[MEDIUM] [PS4] [PS5] Vulnerability 3

The class com.sony.gemstack.org.dvb.io.ixc.IxcProxy contains the protected method invokeMethod which can call methods under privileged context. Permission checks in methods can be bypassed if the following conditions are met:

  • The method is public and non-static.
  • The method's class is public, non-final and can be instantiated.

In such a scenario, an attacker can write a subclass of the target class which implements an interface where the desired method throws RemoteException.

For example, there are permission checks in File.list(). An attacker can bypass them with the following classes:

Java
class FileImpl extends File implements FileInterface {
  FileImpl(String pathname) {
    super(pathname);
  }
}
Java
interface FileInterface extends Remote {
  public String[] list() throws RemoteException;
}

This vulnerability can be used to leak the file system structure as well as dumping files (for example from /app0/).

[HIGH] [PS4] Vulnerability 4

The "compiler receiver thread" receives a structure of size 0x58 bytes from the runtime process:

C
typedef struct {
  uint8_t cmd; // 0x00
  uint64_t arg0; // 0x08
  uint64_t arg1; // 0x10
  uint64_t arg2; // 0x18
  uint64_t arg3; // 0x20
  uint64_t arg4; // 0x28
  uintptr_t runtime_data; // 0x30
  uintptr_t compiler_data; // 0x38
  uint64_t data1; // 0x40
  uint64_t data2; // 0x48
  uint64_t unk; // 0x50
} CompilerAgentRequest; // 0x58

CompilerAgentRequest req;
while (CompilerAgent::readn(s, &req, sizeof(req)) > 0) {
  uint8_t ack = 0xAA;
  CompilerAgent::writen(s, &ack, sizeof(ack));
  if (req.compiler_data != 0) {
    memcpy(req.compiler_data + 0x28, &req, sizeof(req));
    ...
  }
  ...
}

This struct contains a pointer at offset 0x38 (we call it compiler_data) from the compiler process which is used to make a backup of the request structure. An attacker can simply send an untrusted pointer and the compiler receiver thread will copy data from the request into its memory. In other words, we have a write-what-where primitive. An attacker can exploit this vulnerability by supplying a pointer to JIT memory and store the content to be written in the request. The compiler will write this data into JIT memory and therefore give us the opportunity to execute arbitrary payloads. This has severe implications:

  • An ELF loader can be written to load and execute pirated games.
  • Kernel exploitation becomes trivial as there is no SMEP and one can simply jump to user with a corrupted function pointer.

[HIGH] [PS4] [PS5] Vulnerability 5

The UDF driver https://github.com/williamdevries/UDF is used on the PS4 and PS5 which contains a buffer overflow. An attacker can make the size inf_len larger than sector_size (the assumption of internal allocation is that the data is smaller than the sector size) and cause an overflow with memcpy().

C
int
udf_read_internal(struct udf_node *node, uint8_t *blob)
{
	struct file_entry *fe = node->fe;
	struct extfile_entry *efe = node->efe;
	struct udf_mount *ump;
	uint64_t inflen;
	int addr_type, icbflags;
	uint32_t sector_size;
	uint8_t *pos;

	/* get extent and do some paranoia checks */
	ump = node->ump;
	sector_size = ump->sector_size;

	if (fe != NULL) {
		inflen = le64toh(fe->inf_len);
		pos = &fe->data[0] + le32toh(fe->l_ea);
		icbflags = le16toh(fe->icbtag.flags);
	} else {
		inflen = le64toh(efe->inf_len);
		pos = &efe->data[0] + le32toh(efe->l_ea);
		icbflags = le16toh(efe->icbtag.flags);
	}
	addr_type = icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK;

	/* copy out info */
	memset(blob, 0, sector_size);
	memcpy(blob, pos, inflen);

	return (0);
}

Proof-of-concept

Attached is the exploit chain bd-jb as a .iso file which demonstrates the exploitation of vulnerabilities 1-4 that demonstrates the ability to run arbitrary payloads. Burn the iso image with UDF 2.5 file system. You can send the payload using nc $PS4IP 1337 < payload.bin. The provided payload causes a kernel panic by triggering vulnerability 5 (the file /PWN/0 has been modified to use internal allocation and has a size of 4MB filled with A). Tested on latest firmware 9.00.

Impact

  • With these vulnerabilities, it is possible to ship pirated games on bluray discs. That is possible even without a kernel exploit as we have JIT capabilities.

The original report as published on HackerOne, by theflow0. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

Context

This report describes a chain of five vulnerabilities in the PlayStation 4 and, for three of them, the PlayStation 5, submitted to the PlayStation program on HackerOne by theflow0. The chain is called bd-jb and its goal is to gain JIT capabilities and execute arbitrary payloads. The researcher states that, as far as they know, this is the first exploit chain submitted to the program.

The entry point is the Blu-ray Disc Java (BD-J) environment. BD-J applications run on a Java stack, and the first three vulnerabilities live in classes that this stack exposes: com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl, com.oracle.security.Service and com.sony.gemstack.org.dvb.io.ixc.IxcProxy. The fourth vulnerability is in the JIT compiler's receiver thread, and the fifth is in the UDF file system driver used to read disc images.

The report asks the program to consider each vulnerability individually, and rates them as follows:

# Component Severity Affected
1 UserPreferenceManagerImpl deserialisation Medium PS4, PS5
2 com.oracle.security.Service.newInstance Medium PS4
3 IxcProxy.invokeMethod Medium PS4, PS5
4 Compiler receiver thread write-what-where High PS4
5 UDF driver buffer overflow High PS4, PS5

Setup

The chain is delivered as an .iso file, bd-jb, which must be burned with the UDF 2.5 file system. The payload is sent to the console over the network:

Bash
nc $PS4IP 1337 < payload.bin

The researcher tested the chain on the latest firmware at the time, 9.00. The proof-of-concept demonstrates exploitation of vulnerabilities 1 to 4, that is, the ability to run arbitrary payloads. The supplied payload then deliberately triggers vulnerability 5 to cause a kernel panic: the file /PWN/0 has been modified to use internal allocation and has a size of 4MB filled with A.

Finding it

Each link in the chain is a separate weakness in code reachable from the BD-J sandbox. The researcher presents them one by one, with the relevant source.

Vulnerability 1: privileged deserialisation of userprefs

The class com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl reads the userprefs file under privileged context. The initialisation path is:

Java
    private void initPreferences() {
        try {
            UserPreferenceManagerImpl.preferences = AccessController.doPrivileged((PrivilegedExceptionAction<String[][]>)new ReadPreferenceAction());
        }
        catch (PrivilegedActionException ex) {}
        if (UserPreferenceManagerImpl.preferences == null) {
            UserPreferenceManagerImpl.preferences = new String[UserPreferenceManagerImpl.PREFERENCES.length][];
        }
        if (UserPreferenceManagerImpl.preferences[3] == null) {
            UserPreferenceManagerImpl.preferences[3] = new String[] { "26" };
            this.savePreferences();
        }
    }

The privileged action itself opens the file and calls readObject() on it:

Java
    private static class ReadPreferenceAction implements PrivilegedExceptionAction
    {
        public Object run() throws Exception {
            String[][] array = null;
            ObjectInputStream objectInputStream = null;
            try {
                objectInputStream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(RootCertManager.getOriginalPersistentRoot() + "/userprefs")));
                array = (String[][])objectInputStream.readObject();
            }
            finally {
                if (objectInputStream != null) {
                    objectInputStream.close();
                }
            }
            return array;
        }
    }

The problem is that readObject() is insecure: an attacker who can replace the userprefs file with a malicious serialised object can instantiate classes under privileged context. On older firmwares such as 5.05, where the OpenJDK commit [redacted] is not present, exploitation is described as easy: an attacker can instantiate a ClassLoader subclass to call defineClass with all permissions and finally bypass the security manager.

Vulnerability 2: arbitrary class instantiation through com.oracle.security.Service

The class com.oracle.security.Service contains a method newInstance which calls Class.forName on an arbitrary class name. This allows arbitrary classes, including restricted ones such as those in sun., to be instantiated. It works for all classes with public constructors that take a single argument.

The registration check in newInstance can be bypassed by calling com.oracle.ProviderAdapter.setProviderAccessor with a custom ProviderAccessor implementation:

Java
        if (!this.registered) {
            if (ProviderAdapter.getService(this.provider, this.type, this.algorithm) != this) {
                throw new NoSuchAlgorithmException("Service not registered with Provider " + this.provider.getName() + ": " + this);
            }
            this.registered = true;
        }

Vulnerability 3: privileged method invocation through IxcProxy

The class com.sony.gemstack.org.dvb.io.ixc.IxcProxy contains the protected method invokeMethod, which can call methods under privileged context. Permission checks inside those methods can be bypassed when two conditions are met:

  1. The method is public and non-static.
  2. The method's class is public, non-final and can be instantiated.

In that case an attacker writes a subclass of the target class which implements an interface where the desired method throws RemoteException. The example given is File.list(), which has permission checks. The bypass uses these two types:

Java
class FileImpl extends File implements FileInterface {
  FileImpl(String pathname) {
    super(pathname);
  }
}
Java
interface FileInterface extends Remote {
  public String[] list() throws RemoteException;
}

With this, the researcher could leak the file system structure and dump files, for example from /app0/.

Vulnerability 4: write-what-where in the compiler receiver thread

The "compiler receiver thread" receives a structure of size 0x58 bytes from the runtime process:

C
typedef struct {
  uint8_t cmd; // 0x00
  uint64_t arg0; // 0x08
  uint64_t arg1; // 0x10
  uint64_t arg2; // 0x18
  uint64_t arg3; // 0x20
  uint64_t arg4; // 0x28
  uintptr_t runtime_data; // 0x30
  uintptr_t compiler_data; // 0x38
  uint64_t data1; // 0x40
  uint64_t data2; // 0x48
  uint64_t unk; // 0x50
} CompilerAgentRequest; // 0x58

CompilerAgentRequest req;
while (CompilerAgent::readn(s, &req, sizeof(req)) > 0) {
  uint8_t ack = 0xAA;
  CompilerAgent::writen(s, &ack, sizeof(ack));
  if (req.compiler_data != 0) {
    memcpy(req.compiler_data + 0x28, &req, sizeof(req));
    ...
  }
  ...
}

The struct holds a pointer at offset 0x38, called compiler_data, which comes from the compiler process and is used to make a backup of the request structure. An attacker can simply send an untrusted pointer, and the compiler receiver thread will copy data from the request into its memory. That is a write-what-where primitive. By supplying a pointer into JIT memory and placing the content to be written in the request, the compiler writes the data into JIT memory, which gives the opportunity to execute arbitrary payloads.

The researcher highlights two severe implications: an ELF loader can be written to load and execute pirated games, and kernel exploitation becomes trivial because there is no SMEP and one can simply jump to user space with a corrupted function pointer.

Vulnerability 5: buffer overflow in the UDF driver

The UDF driver at https://github.com/williamdevries/UDF is used on the PS4 and PS5 and contains a buffer overflow. The internal allocation assumes the data is smaller than the sector size, but inf_len can be made larger than sector_size, and the memcpy() then overflows:

C
int
udf_read_internal(struct udf_node *node, uint8_t *blob)
{
	struct file_entry *fe = node->fe;
	struct extfile_entry *efe = node->efe;
	struct udf_mount *ump;
	uint64_t inflen;
	int addr_type, icbflags;
	uint32_t sector_size;
	uint8_t *pos;

	/* get extent and do some paranoia checks */
	ump = node->ump;
	sector_size = ump->sector_size;

	if (fe != NULL) {
		inflen = le64toh(fe->inf_len);
		pos = &fe->data[0] + le32toh(fe->l_ea);
		icbflags = le16toh(fe->icbtag.flags);
	} else {
		inflen = le64toh(efe->inf_len);
		pos = &efe->data[0] + le32toh(efe->l_ea);
		icbflags = le16toh(efe->icbtag.flags);
	}
	addr_type = icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK;

	/* copy out info */
	memset(blob, 0, sector_size);
	memcpy(blob, pos, inflen);

	return (0);
}

Exploitation

Step 1: reach privileged code from BD-J

The chain starts inside the BD-J sandbox. Vulnerability 1 gives code execution in a privileged AccessController.doPrivileged context by way of a crafted userprefs file, provided the firmware lacks the referenced OpenJDK fix. Vulnerability 2 widens the set of classes that can be instantiated, including restricted sun. classes, by abusing Service.newInstance and replacing the provider accessor. Vulnerability 3 turns any public, non-static method on a public, non-final, instantiable class into a privileged call, which is enough to enumerate the file system and read files such as those under /app0/.

Step 2: obtain a write-what-where in the compiler

With the Java-side primitives in hand, the attacker talks to the compiler receiver thread. The request structure is fully attacker-controlled, including compiler_data at offset 0x38. Setting that field to a chosen address makes the thread execute:

C
    memcpy(req.compiler_data + 0x28, &req, sizeof(req));

which copies the 0x58-byte request to the chosen address plus 0x28. Pointing it at JIT memory places attacker-chosen bytes into executable memory.

Step 3: deliver and run the payload

The chain is shipped as the bd-jb .iso, burned with UDF 2.5. The payload is sent over TCP:

Bash
nc $PS4IP 1337 < payload.bin

On firmware 9.00 this demonstrates exploitation of vulnerabilities 1 to 4 and the ability to run arbitrary payloads.

Step 4: trigger the UDF overflow

The supplied payload also exercises vulnerability 5. The file /PWN/0 has been modified to use internal allocation and has a size of 4MB filled with A, so inf_len exceeds sector_size and the memcpy() in udf_read_internal overflows the destination. In the proof-of-concept this results in a kernel panic.

Root cause

Each link is a distinct mistake:

  • Deserialisation under privilege. ReadPreferenceAction runs inside doPrivileged and calls readObject() on a file the attacker can replace, so the serialised stream is trusted with the privileges of the privileged block. The OpenJDK change referenced by the researcher is what makes this hard on newer firmware; on 5.05 it is absent.
  • Unchecked class loading. Service.newInstance resolves an arbitrary class name through Class.forName, including restricted packages, and the registration check that should gate it can be sidestepped by installing a custom ProviderAccessor through ProviderAdapter.setProviderAccessor.
  • Privileged dispatch on attacker-defined types. IxcProxy.invokeMethod invokes methods under privileged context, and the permission checks inside the target method can be routed around by subclassing the target and implementing a remote interface whose method signature throws RemoteException.
  • Trusting a pointer from the peer. The compiler receiver thread takes compiler_data from the request and uses it directly as a destination for memcpy, with no validation that it points into memory the compiler owns.
  • Missing length check. udf_read_internal zeroes sector_size bytes but copies inflen bytes, without verifying that inflen is not larger than sector_size.

On the mitigation side, the researcher notes that the PS4 lacks SMEP, which is why a corrupted function pointer can be used to jump to user space and why kernel exploitation becomes trivial once the write primitive exists.

Impact

The chain gives JIT capabilities and arbitrary payload execution. The researcher lists the concrete consequences:

  • Pirated games can be shipped on Blu-ray discs, and this is possible even without a kernel exploit because the chain provides JIT capabilities.
  • An ELF loader can be written to load and execute pirated games.
  • Kernel exploitation becomes trivial on the PS4 because there is no SMEP and one can jump to user space with a corrupted function pointer.
  • Vulnerability 3 alone allows leaking the file system structure and dumping files such as those under /app0/.

The proof-of-concept payload ends in a kernel panic through vulnerability 5.

Fix

The report does not describe any remediation applied by the vendor.

Variants to test

  • Other privileged deserialisation sinks. Look for doPrivileged blocks that read files an unprivileged party can write, and check whether the firmware carries the OpenJDK fix. A positive result is a crafted serialised file that instantiates an attacker-chosen class with elevated permissions.
  • Other reflective factories. Search for Class.forName combined with newInstance on attacker-influenced names, and for accessor or callback setters that can replace the object performing the registration check. A positive result is instantiation of a class in a restricted package such as sun..
  • Other privileged proxies. Find classes with public, non-static methods that perform permission checks and are public, non-final and instantiable. A positive result is a subclass plus remote interface that performs the protected operation, as with File.list().
  • Other pointer fields in IPC structures. Audit structures received from a less privileged process for pointer members used as memcpy destinations. A positive result is a controlled write to a chosen address, ideally into JIT memory.
  • Other file system parsers. Check length fields such as inf_len against the allocation size before copying. A positive result is a crash or corruption from an image whose length field exceeds the sector size.

Hunting notes

This kind of bug tends to hide at the boundary between a sandboxed runtime and privileged platform code: preference and configuration files that are deserialised, reflective service factories, and proxy classes that dispatch calls with elevated rights. On the compiler side, the interesting surface is any inter-process structure whose pointer fields are trusted. On the storage side, it is parsers for disc image formats, where length fields from the image are used without comparison against the buffer size.

During recon, the signals are privileged blocks that read attacker-writable files, class-loading helpers that accept arbitrary names, and IPC handlers that copy data to addresses taken from the message. The researcher delivered the chain as an .iso to be burned with UDF 2.5, demonstrating arbitrary payload execution on firmware 9.00 and sending the payload with nc to port 1337, with the UDF overflow causing a kernel panic.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 21 min read.

What happened, in plain words

A security researcher found five separate weaknesses in the PlayStation 4 and, for three of them, the PlayStation 5. Joined together in a chain, they let an attacker run their own code on the console. The chain is called bd-jb, and the researcher submitted it to the PlayStation bug bounty program on HackerOne. As far as the researcher knows, it was the first exploit chain ever submitted to that program.

The starting point is the Blu-ray Disc Java (BD-J) environment. Blu-ray discs can carry small Java programs that run on the player, and on a PlayStation the player is the console itself. Those programs are supposed to be locked in a sandbox, a restricted area where they can do only a limited set of things. The first three weaknesses are in Java classes that this sandbox exposes, and they let the attacker climb out of the sandbox step by step. The fourth weakness is in the JIT compiler, the part of the console that turns Java code into fast machine code while it runs. The fifth is in the UDF driver, the code that reads the file system on a disc image.

The report asks the program to consider each weakness on its own, and rates them like this:

# Component Severity Affected
1 UserPreferenceManagerImpl deserialisation Medium PS4, PS5
2 com.oracle.security.Service.newInstance Medium PS4
3 IxcProxy.invokeMethod Medium PS4, PS5
4 Compiler receiver thread write-what-where High PS4
5 UDF driver buffer overflow High PS4, PS5

A quick word on the vocabulary that runs through the whole report. A sandbox is like a playpen: a program inside it can move around, but only within the walls. Privileged context means code that runs with more rights than normal, the way a bank clerk behind the counter can open drawers a customer cannot. Serialisation is a way of saving an object (a bundle of data and code) to a file so it can be loaded again later; deserialisation is the loading back. If an attacker can swap the saved file for one of their own, the loading program may build objects the attacker chose, with whatever rights the loader has. That is the theme of the first weakness.

Setup

The chain is delivered as an .iso file, bd-jb, which must be burned with the UDF 2.5 file system. An ISO file is a disc image: a single file that contains everything a disc would contain, which you can burn onto a real disc or mount as if it were one. UDF is the file system standard used on Blu-ray discs, and 2.5 is a particular version of it.

The payload is then sent to the console over the network:

Bash
nc $PS4IP 1337 < payload.bin

Line by line: nc is netcat, a small tool that opens a network connection and pipes data through it. $PS4IP is a placeholder for the console's address on the local network. 1337 is the port number the console is listening on. The < symbol means "take the contents of the following file and feed them into the command's input", so payload.bin is the file whose bytes get sent. In plain terms: connect to the console on port 1337 and send it the payload file.

The researcher tested the chain on the latest firmware at the time, 9.00. Firmware is the built-in software of the console, and Sony ships numbered updates for it. The proof-of-concept demonstrates exploitation of weaknesses 1 to 4, that is, the ability to run arbitrary payloads. The supplied payload then deliberately triggers weakness 5 to cause a kernel panic: the file /PWN/0 has been modified to use internal allocation and has a size of 4MB filled with A. A kernel panic is the operating system's emergency stop when it detects that something has gone badly wrong internally; it is a crash, not a controlled exploit.

Finding it

Each link in the chain is a separate weakness in code reachable from the BD-J sandbox. The researcher presents them one by one, with the relevant source.

Vulnerability 1: privileged deserialisation of userprefs

The class com.sony.gemstack.org.dvb.user.UserPreferenceManagerImpl reads the userprefs file under privileged context. A class is a blueprint in object-oriented programming; an object is a thing built from that blueprint. userprefs is a file that stores user preferences, and the class name says it manages them. The initialisation path is:

Java
    private void initPreferences() {
        try {
            UserPreferenceManagerImpl.preferences = AccessController.doPrivileged((PrivilegedExceptionAction<String[][]>)new ReadPreferenceAction());
        }
        catch (PrivilegedActionException ex) {}
        if (UserPreferenceManagerImpl.preferences == null) {
            UserPreferenceManagerImpl.preferences = new String[UserPreferenceManagerImpl.PREFERENCES.length][];
        }
        if (UserPreferenceManagerImpl.preferences[3] == null) {
            UserPreferenceManagerImpl.preferences[3] = new String[] { "26" };
            this.savePreferences();
        }
    }

Line by line: private void initPreferences() declares a method, a named block of code, that sets the preferences up and returns nothing. try { starts a block where errors are caught rather than crashing the program. AccessController.doPrivileged(...) is the key line: it runs the given action with elevated rights, the way a manager signs off a transaction a cashier cannot approve alone. The action is a new ReadPreferenceAction, cast to PrivilegedExceptionAction<String[][]>, meaning it is expected to return a two-dimensional array of strings. The result is stored in a static field preferences. catch (PrivilegedActionException ex) {} swallows any error silently. The two if blocks then fill in defaults: if nothing was loaded, an empty array is created; if the fourth entry is missing, it is set to "26" and the preferences are saved. The important part is that the reading happens inside doPrivileged.

The privileged action itself opens the file and calls readObject() on it:

Java
    private static class ReadPreferenceAction implements PrivilegedExceptionAction
    {
        public Object run() throws Exception {
            String[][] array = null;
            ObjectInputStream objectInputStream = null;
            try {
                objectInputStream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(RootCertManager.getOriginalPersistentRoot() + "/userprefs")));
                array = (String[][])objectInputStream.readObject();
            }
            finally {
                if (objectInputStream != null) {
                    objectInputStream.close();
                }
            }
            return array;
        }
    }

Line by line: this is a nested class called ReadPreferenceAction that implements the PrivilegedExceptionAction interface, so it can be handed to doPrivileged. Its run() method is what actually executes. String[][] array = null; prepares a variable for the result, and ObjectInputStream objectInputStream = null; prepares a variable for the stream that will read the file. Inside the try, new FileInputStream(...) opens the file at the path built from RootCertManager.getOriginalPersistentRoot() plus /userprefs, new BufferedInputStream(...) wraps it for efficient reading, and new ObjectInputStream(...) wraps that so Java objects can be read from it. Then objectInputStream.readObject() reads one object from the file and casts it to a two-dimensional string array. The finally block closes the stream whether or not an error happened, and return array; hands the result back.

The problem is that readObject() is insecure: an attacker who can replace the userprefs file with a malicious serialised object can instantiate classes under privileged context. In everyday terms, imagine a form that says "write down what you want and we will build it for you, with manager approval". If anyone can swap the form, they can ask for something the clerk would never be allowed to build on their own. On older firmwares such as 5.05, where the OpenJDK commit [redacted] is not present, exploitation is described as easy: an attacker can instantiate a ClassLoader subclass to call defineClass with all permissions and finally bypass the security manager. A ClassLoader is the part of Java that loads classes into memory, and defineClass is the method that turns raw bytes into a usable class; the security manager is Java's built-in guard that checks whether an action is allowed. If the attacker can define their own class with all permissions, the guard has nothing left to check.

Vulnerability 2: arbitrary class instantiation through com.oracle.security.Service

The class com.oracle.security.Service contains a method newInstance which calls Class.forName on an arbitrary class name. Class.forName takes a name as text and loads the class with that name, like a librarian fetching a book by title. If the title can be anything, the librarian will fetch books from locked shelves too. This allows arbitrary classes, including restricted ones such as those in sun., to be instantiated. It works for all classes with public constructors that take a single argument. A constructor is the setup routine that runs when an object is created, and public means other code is allowed to call it.

The registration check in newInstance can be bypassed by calling com.oracle.ProviderAdapter.setProviderAccessor with a custom ProviderAccessor implementation:

Java
        if (!this.registered) {
            if (ProviderAdapter.getService(this.provider, this.type, this.algorithm) != this) {
                throw new NoSuchAlgorithmException("Service not registered with Provider " + this.provider.getName() + ": " + this);
            }
            this.registered = true;
        }

Line by line: if (!this.registered) checks whether this service has not yet been marked as registered. Inside, ProviderAdapter.getService(this.provider, this.type, this.algorithm) asks the adapter which service object is registered for this provider, type and algorithm, and != this compares the answer with the current object. If they differ, the code throws a NoSuchAlgorithmException with a message saying the service is not registered with the provider. If they match, this.registered = true; records that the check passed. The check is meant to stop unregistered services from being used, but it relies on the adapter object. If the attacker can replace the adapter through setProviderAccessor, they control the answer to the question, and the check passes for whatever they like.

Vulnerability 3: privileged method invocation through IxcProxy

The class com.sony.gemstack.org.dvb.io.ixc.IxcProxy contains the protected method invokeMethod, which can call methods under privileged context. Protected is an access level between private and public: only the class itself, its subclasses and its package can call it. Permission checks inside those methods can be bypassed when two conditions are met:

  1. The method is public and non-static. A static method belongs to the class itself rather than to an object, so it cannot be overridden per object.
  2. The method's class is public, non-final and can be instantiated. Final means the class cannot be subclassed.

In that case an attacker writes a subclass of the target class which implements an interface where the desired method throws RemoteException. An interface is a contract listing method names without their bodies; a class that implements it promises to provide them. RemoteException is an error type used in Java's remote method invocation, where a call travels over a network. The example given is File.list(), which has permission checks. File is Java's representation of a file or folder, and list() returns the names inside a folder. The bypass uses these two types:

Java
class FileImpl extends File implements FileInterface {
  FileImpl(String pathname) {
    super(pathname);
  }
}

Line by line: class FileImpl extends File implements FileInterface declares a new class that inherits everything from File and also promises to honour the FileInterface contract. The constructor FileImpl(String pathname) takes a path as text, and super(pathname); passes it up to the parent File constructor so the object is set up as a normal file. Nothing else is added: the point is simply to be a File that also counts as a FileInterface.

Java
interface FileInterface extends Remote {
  public String[] list() throws RemoteException;
}

Line by line: interface FileInterface extends Remote declares an interface that builds on Java's Remote marker, which tells the remote-call machinery that this type is meant to be called across a boundary. Inside, public String[] list() throws RemoteException; declares a list method returning an array of strings and announces that it may fail with a RemoteException. Because the proxy sees a remote-style method, it dispatches the call through its privileged path, and the permission check inside the real File.list() is routed around. With this, the researcher could leak the file system structure and dump files, for example from /app0/. Leaking the structure means learning which files and folders exist; dumping means copying their contents out.

Vulnerability 4: write-what-where in the compiler receiver thread

The "compiler receiver thread" receives a structure of size 0x58 bytes from the runtime process. A thread is one line of execution inside a program, and a structure is a fixed layout of fields in memory, like a printed form with boxes at fixed positions. The numbers like 0x58 are hexadecimal, a base-16 way of writing numbers that programmers use because it maps neatly onto memory; 0x58 is 88 in ordinary decimal.

C
typedef struct {
  uint8_t cmd; // 0x00
  uint64_t arg0; // 0x08
  uint64_t arg1; // 0x10
  uint64_t arg2; // 0x18
  uint64_t arg3; // 0x20
  uint64_t arg4; // 0x28
  uintptr_t runtime_data; // 0x30
  uintptr_t compiler_data; // 0x38
  uint64_t data1; // 0x40
  uint64_t data2; // 0x48
  uint64_t unk; // 0x50
} CompilerAgentRequest; // 0x58

CompilerAgentRequest req;
while (CompilerAgent::readn(s, &req, sizeof(req)) > 0) {
  uint8_t ack = 0xAA;
  CompilerAgent::writen(s, &ack, sizeof(ack));
  if (req.compiler_data != 0) {
    memcpy(req.compiler_data + 0x28, &req, sizeof(req));
    ...
  }
  ...
}

Line by line: typedef struct { ... } CompilerAgentRequest; defines the layout and gives it the name CompilerAgentRequest. Each line inside is a field: uint8_t cmd is one byte for a command code, uint64_t arg0 to arg4 are 64-bit numbers for arguments, uintptr_t runtime_data and uintptr_t compiler_data are pointers (memory addresses), data1, data2 and unk are further 64-bit values. The comments on the right give the offset of each field from the start of the structure, so compiler_data sits at byte 0x38. CompilerAgentRequest req; creates one such structure to receive a message. while (CompilerAgent::readn(s, &req, sizeof(req)) > 0) loops as long as reading from the connection s into req returns more than zero bytes, that is, as long as messages keep arriving. uint8_t ack = 0xAA; prepares a one-byte acknowledgement, and CompilerAgent::writen(s, &ack, sizeof(ack)); sends it back. if (req.compiler_data != 0) checks that the pointer field is not null, and memcpy(req.compiler_data + 0x28, &req, sizeof(req)); copies the whole request structure to the address in compiler_data plus 0x28. memcpy is a standard C function that copies a block of bytes from one place to another.

The struct holds a pointer at offset 0x38, called compiler_data, which comes from the compiler process and is used to make a backup of the request structure. An attacker can simply send an untrusted pointer, and the compiler receiver thread will copy data from the request into its memory. That is a write-what-where primitive. The name says it exactly: the attacker chooses what is written (the contents of the request) and where it is written (the address in compiler_data). By supplying a pointer into JIT memory and placing the content to be written in the request, the compiler writes the data into JIT memory, which gives the opportunity to execute arbitrary payloads. JIT memory is memory the console has marked as executable because it holds compiled code, so bytes placed there can be run as instructions.

The researcher highlights two severe implications: an ELF loader can be written to load and execute pirated games, and kernel exploitation becomes trivial because there is no SMEP and one can simply jump to user space with a corrupted function pointer. An ELF loader is code that reads ELF files, the standard executable format on many systems, and runs them. SMEP stands for Supervisor Mode Execution Prevention, a processor feature that stops the kernel from executing code that lives in user memory; without it, a corrupted function pointer can be pointed at attacker-controlled user memory and the kernel will happily jump there.

Vulnerability 5: buffer overflow in the UDF driver

The UDF driver at https://github.com/williamdevries/UDF is used on the PS4 and PS5 and contains a buffer overflow. A driver is the piece of software that lets the system talk to a piece of hardware or a file system format. A buffer is a fixed-size area of memory set aside to hold data, and a buffer overflow happens when more data is written into it than it can hold, so the extra bytes spill into neighbouring memory.

The internal allocation assumes the data is smaller than the sector size, but inf_len can be made larger than sector_size, and the memcpy() then overflows:

C
int
udf_read_internal(struct udf_node *node, uint8_t *blob)
{
	struct file_entry *fe = node->fe;
	struct extfile_entry *efe = node->efe;
	struct udf_mount *ump;
	uint64_t inflen;
	int addr_type, icbflags;
	uint32_t sector_size;
	uint8_t *pos;

	/* get extent and do some paranoia checks */
	ump = node->ump;
	sector_size = ump->sector_size;

	if (fe != NULL) {
		inflen = le64toh(fe->inf_len);
		pos = &fe->data[0] + le32toh(fe->l_ea);
		icbflags = le16toh(fe->icbtag.flags);
	} else {
		inflen = le64toh(efe->inf_len);
		pos = &efe->data[0] + le32toh(efe->l_ea);
		icbflags = le16toh(efe->icbtag.flags);
	}
	addr_type = icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK;

	/* copy out info */
	memset(blob, 0, sector_size);
	memcpy(blob, pos, inflen);

	return (0);
}

Line by line: int udf_read_internal(struct udf_node *node, uint8_t *blob) declares a function that takes a node (a file or folder in the UDF file system) and a destination buffer called blob, and returns an integer. The next lines declare local variables: fe and efe point to two kinds of file entry structures taken from the node, ump will point to the mount information, inflen will hold the data length, addr_type and icbflags hold flags, sector_size holds the sector size, and pos will point at the data. ump = node->ump; fetches the mount information, and sector_size = ump->sector_size; reads the sector size from it. The if (fe != NULL) branch handles the case where a normal file entry exists: inflen = le64toh(fe->inf_len); reads the length field and converts it from little-endian to the machine's byte order (le64toh means "little-endian 64-bit to host"), pos = &fe->data[0] + le32toh(fe->l_ea); computes where the data starts by skipping the extended attributes, and icbflags = le16toh(fe->icbtag.flags); reads the flags. The else branch does the same with the extended file entry efe. addr_type = icbflags & UDF_ICB_TAG_FLAGS_ALLOC_MASK; extracts the allocation type bits from the flags. Then memset(blob, 0, sector_size); fills the destination with zeros for sector_size bytes, and memcpy(blob, pos, inflen); copies inflen bytes from pos into blob. The mismatch is right there: the buffer was cleared for sector_size bytes, but the copy uses inflen, which comes from the disc image and can be larger. return (0); reports success.

Exploitation

Step 1: reach privileged code from BD-J

The chain starts inside the BD-J sandbox. Weakness 1 gives code execution in a privileged AccessController.doPrivileged context by way of a crafted userprefs file, provided the firmware lacks the referenced OpenJDK fix. OpenJDK is the open-source implementation of Java that Sony's stack is based on, and the commit is a specific change to its source code. Weakness 2 widens the set of classes that can be instantiated, including restricted sun. classes, by abusing Service.newInstance and replacing the provider accessor. Weakness 3 turns any public, non-static method on a public, non-final, instantiable class into a privileged call, which is enough to enumerate the file system and read files such as those under /app0/. Enumerating means listing what is there; /app0/ is a path on the console's file system.

Step 2: obtain a write-what-where in the compiler

With the Java-side primitives in hand, the attacker talks to the compiler receiver thread. A primitive in this context is a small, reliable capability that can be reused, like a single Lego brick you can place anywhere. The request structure is fully attacker-controlled, including compiler_data at offset 0x38. Setting that field to a chosen address makes the thread execute:

C
    memcpy(req.compiler_data + 0x28, &req, sizeof(req));

This copies the 0x58-byte request to the chosen address plus 0x28. Pointing it at JIT memory places attacker-chosen bytes into executable memory.

Step 3: deliver and run the payload

The chain is shipped as the bd-jb .iso, burned with UDF 2.5. The payload is sent over TCP:

Bash
nc $PS4IP 1337 < payload.bin

TCP is the standard protocol that carries a reliable stream of bytes between two machines on a network. On firmware 9.00 this demonstrates exploitation of weaknesses 1 to 4 and the ability to run arbitrary payloads.

Step 4: trigger the UDF overflow

The supplied payload also exercises weakness 5. The file /PWN/0 has been modified to use internal allocation and has a size of 4MB filled with A, so inf_len exceeds sector_size and the memcpy() in udf_read_internal overflows the destination. In the proof-of-concept this results in a kernel panic.

Root cause

Each link is a distinct mistake:

  • Deserialisation under privilege. ReadPreferenceAction runs inside doPrivileged and calls readObject() on a file the attacker can replace, so the serialised stream is trusted with the privileges of the privileged block. The OpenJDK change referenced by the researcher is what makes this hard on newer firmware; on 5.05 it is absent.
  • Unchecked class loading. Service.newInstance resolves an arbitrary class name through Class.forName, including restricted packages, and the registration check that should gate it can be sidestepped by installing a custom ProviderAccessor through ProviderAdapter.setProviderAccessor.
  • Privileged dispatch on attacker-defined types. IxcProxy.invokeMethod invokes methods under privileged context, and the permission checks inside the target method can be routed around by subclassing the target and implementing a remote interface whose method signature throws RemoteException.
  • Trusting a pointer from the peer. The compiler receiver thread takes compiler_data from the request and uses it directly as a destination for memcpy, with no validation that it points into memory the compiler owns.
  • Missing length check. udf_read_internal zeroes sector_size bytes but copies inflen bytes, without verifying that inflen is not larger than sector_size.

On the mitigation side, the researcher notes that the PS4 lacks SMEP, which is why a corrupted function pointer can be used to jump to user space and why kernel exploitation becomes trivial once the write primitive exists.

Impact

The chain gives JIT capabilities and arbitrary payload execution. The researcher lists the concrete consequences:

  • Pirated games can be shipped on Blu-ray discs, and this is possible even without a kernel exploit because the chain provides JIT capabilities.
  • An ELF loader can be written to load and execute pirated games.
  • Kernel exploitation becomes trivial on the PS4 because there is no SMEP and one can jump to user space with a corrupted function pointer.
  • Weakness 3 alone allows leaking the file system structure and dumping files such as those under /app0/.

The proof-of-concept payload ends in a kernel panic through weakness 5.

Fix

The report does not describe any remediation applied by the vendor.

Variants to test

  • Other privileged deserialisation sinks. Look for doPrivileged blocks that read files an unprivileged party can write, and check whether the firmware carries the OpenJDK fix. A positive result is a crafted serialised file that instantiates an attacker-chosen class with elevated permissions.
  • Other reflective factories. Search for Class.forName combined with newInstance on attacker-influenced names, and for accessor or callback setters that can replace the object performing the registration check. A positive result is instantiation of a class in a restricted package such as sun..
  • Other privileged proxies. Find classes with public, non-static methods that perform permission checks and are public, non-final and instantiable. A positive result is a subclass plus remote interface that performs the protected operation, as with File.list().
  • Other pointer fields in IPC structures. Audit structures received from a less privileged process for pointer members used as memcpy destinations. IPC means inter-process communication, the way separate programs on the same machine exchange messages. A positive result is a controlled write to a chosen address, ideally into JIT memory.
  • Other file system parsers. Check length fields such as inf_len against the allocation size before copying. A positive result is a crash or corruption from an image whose length field exceeds the sector size.

Hunting notes

This kind of bug tends to hide at the boundary between a sandboxed runtime and privileged platform code: preference and configuration files that are deserialised, reflective service factories, and proxy classes that dispatch calls with elevated rights. On the compiler side, the interesting surface is any inter-process structure whose pointer fields are trusted. On the storage side, it is parsers for disc image formats, where length fields from the image are used without comparison against the buffer size.

During recon, the signals are privileged blocks that read attacker-writable files, class-loading helpers that accept arbitrary names, and IPC handlers that copy data to addresses taken from the message. The researcher delivered the chain as an .iso to be burned with UDF 2.5, demonstrating arbitrary payload execution on firmware 9.00 and sending the payload with nc to port 1337, with the UDF overflow causing a kernel panic.

Glossary

  • BD-J (Blu-ray Disc Java): a Java environment on Blu-ray discs that lets small programs run on the player, here the console.
  • Buffer: a fixed-size area of memory set aside to hold data.
  • Buffer overflow: writing more data into a buffer than it can hold, so the extra bytes spill into neighbouring memory.
  • Class: a blueprint in object-oriented programming from which objects are created.
  • ClassLoader: the part of Java that loads classes into memory.
  • Constructor: the setup routine that runs when an object is created.
  • Deserialisation: turning saved bytes back into a live object; the reverse of serialisation.
  • Driver: software that lets the system talk to a piece of hardware or read a particular file system format.
  • ELF: a standard executable file format; an ELF loader reads such files and runs them.
  • Firmware: the built-in software of a device, updated through numbered releases.
  • Hexadecimal: a base-16 way of writing numbers, common in programming because it maps neatly onto memory.
  • Interface: a contract listing method names without bodies, which a class promises to provide.
  • IPC (inter-process communication): the way separate programs on the same machine exchange messages.
  • ISO file: a single file containing a complete disc image, which can be burned or mounted.
  • JIT (just-in-time compiler): code that turns Java bytecode into fast machine code while the program runs.
  • JIT memory: memory marked executable because it holds compiled code.
  • Kernel: the core of the operating system, with the highest rights.
  • Kernel panic: the operating system's emergency stop when it detects a serious internal fault.
  • Little-endian: a byte order where the least significant byte comes first; le64toh converts it to the machine's order.
  • memcpy: a standard C function that copies a block of bytes from one place to another.
  • memset: a standard C function that fills a block of memory with a given byte value.
  • OpenJDK: the open-source implementation of Java that Sony's stack is based on.
  • Pointer: a value that holds a memory address.
  • Primitive: a small, reliable capability that can be reused in an exploit.
  • Privileged context: code running with more rights than normal.
  • Protected / public / private: Java access levels controlling which code may call a method or class.
  • readObject(): the Java method that reads a serialised object from a stream.
  • RemoteException: a Java error type used when a remote method call fails.
  • Sandbox: a restricted area in which a program can run but only do a limited set of things.
  • Security manager: Java's built-in guard that checks whether an action is allowed.
  • Serialisation: saving an object to a stream or file so it can be loaded again later.
  • SMEP (Supervisor Mode Execution Prevention): a processor feature that stops the kernel from executing code in user memory.
  • Static: a method or field that belongs to the class itself rather than to an object.
  • Structure: a fixed layout of fields in memory.
  • TCP: the standard protocol that carries a reliable stream of bytes between two machines.
  • Thread: one line of execution inside a program.
  • UDF: the file system standard used on Blu-ray discs; 2.5 is a version of it.
  • Write-what-where: a primitive where the attacker chooses both the value written and the address it is written to.

More by Andy Nguyen

View all

7 more disclosed reports, best first.

More from PlayStation

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.