Skip to content
Memory corruption Disclosed report Advanced CVE-2022-29867

Remote kernel heap overflow

A kernel heap overflow exists in the PlayStation's PPPoE driver, which originates from NetBSD. An attacker on the same LAN can send crafted PADO packets to cause the console to build an oversized PADR packet, overflowing a 2048-byte mbuf cluster with attacker-controlled contents.

m00nbsd Follow

Originally disclosed on HackerOne

High 7.4 View original
  • Triaged in 6 days
  • Fixed in 4 months
  • Paid in 12 days
  • Disclosed after 8 months

Summary by the program

Summary

The PlayStation 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.

Technical Details

PPPoE Protocol

In short, the PlayStation (PS) will:

  1. Send a PADI packet.
  2. Expect to receive a PADO packet.
  3. Send a PADR packet.
  4. Expect to receive a PADS packet.

The Vulnerability

I determined that the PS' PPPoE driver originates from NetBSD. In that PPPoE driver, there is a vulnerability in the way PADR packets are allocated:

C
static int
pppoe_send_padr(struct pppoe_softc *sc)
{
	[...]

	/* Compute packet length. */
	len = sizeof(struct pppoetag);
	if (sc->sc_service_name != NULL) {
		l1 = strlen(sc->sc_service_name);
		len += l1;
	}
	if (sc->sc_ac_cookie_len > 0) {
		len += sizeof(struct pppoetag) + sc->sc_ac_cookie_len;
	}
	if (sc->sc_relay_sid_len > 0) {
		len += sizeof(struct pppoetag) + sc->sc_relay_sid_len;
	}
	len += sizeof(struct pppoetag) + sizeof(sc->sc_id);
	if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MAXMTU) {
		len += sizeof(struct pppoetag) + 2;
	}

	/* Allocate packet. */
	m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);
	if (m0 == NULL)
		return ENOBUFS;

	/* Fill in packet. */
	[...]
}

static struct mbuf *
pppoe_get_mbuf(size_t len)
{
	struct mbuf *m;

	MGETHDR(m, M_DONTWAIT, MT_DATA);
	if (m == NULL)
		return NULL;
	if (len + sizeof(struct ether_header) > MHLEN) {
		MCLGET(m, M_DONTWAIT);
		if ((m->m_flags & M_EXT) == 0) {
			m_free(m);
			return NULL;
		}
	}
	m->m_data += sizeof(struct ether_header);
	m->m_len = len;
	m->m_pkthdr.len = len;
	m_reset_rcvif(m);

	return m;
}

The flow is:

  • pppoe_send_padr():
    • It wants to send a PADR packet.
    • It computes the packet length, and calls pppoe_get_mbuf().
  • pppoe_get_mbuf():
    • If the length is larger than MHLEN, it allocates an mbuf cluster, of size MCLBYTES=2048.
    • It returns that mbuf cluster.
  • pppoe_send_padr():
    • It fills in the mbuf cluster.

The vulnerability here is that the packet length could actually be bigger than MCLBYTES, in which case the filling of the packet will overflow the mbuf cluster.

Constraints

To have a length that is larger than MCLBYTES, the sc_ac_cookie_len and sc_relay_sid_len values need to be large enough.

Both of these values are actually extracted from PADO packets that the PS previously received: they are the lengths of the ACCOOKIE and RELAYSID tags that were embedded in the PADO packets. The attacker can control these lengths.

There is a constraint on the MTU: given that the PS' maximum MTU is 1500, the attacker cannot directly send just one PADO packet with sizes larger than MCLBYTES. To work around that constraint, the attacker just has to send two PADO packets, one with a big ACCOOKIE tag, and another with a big RELAYSID tag. After the second packet, the PS will send a PADR packet combining both big tags, which will overflow the mbuf cluster with the contents of the second tag.

Attack Scenario

  1. The PS sends a PADI.
  2. The attacker sends a PADO, with a ACCOOKIE tag whose size is 1400 bytes.
  3. The PS sends a PADR. This one is fine, there is no overflow here.
  4. The PS waits for a PADS packet.
  5. The PS times out, and resends a PADI.
  6. The attacker sends a PADO, with a RELAYSID tag whose size is 1400 bytes.
  7. The PS Sends a PADR. The overflow occurs here: the PS tries to embed the two tags (1400x2=2800 bytes) into a 2048-byte mbuf cluster.

Setup / PoC / Discussion

  • Enable PPPoE on the PS:
    • Settings -> Network -> Set Up Internet Connection -> Use a LAN Cable -> Custom
    • IP Address Settings: PPPoE
    • Enter whatever in the two User/Password fields, click Next
    • DNS Settings: Automatic
    • MTU Settings: set 1500
    • Proxy Server: Do Not Use
  • Connect a Linux laptop to the PS with an Ethernet cable.
  • On the Linux laptop:
    • cc -o poc poc.c -Wall
    • sudo ifconfig eth0 mtu 8000
    • sudo ./poc eth0
  • On the PS: click Test Internet Connection. This will initiate the PPPoE connection.

To see what happens:

  • Open WireShark on the Linux laptop, and look at the packets that are being exchanged with the PS. You can see that the PS sends 2844-byte PADR packets.
  • Actual exploitation/introspection will require a debugger, which I do not have. :'(
  • ███████

Impact

Possible RCE. I did my tests only on a friend's PS4, but I suspect that the PS5 is affected as well.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The driver computes the PADR packet length from attacker-influenced tag lengths but allocates a fixed-size mbuf cluster (MCLBYTES) when the length exceeds MHLEN, without checking that the total length fits in that cluster.

Impact

Possible remote code execution on the console; the author tested only on a PS4 but suspects the PS5 is affected as well.

What the attacker needed

Attacker on the same LAN; PPPoE enabled on the console; console initiates a connection

How it was found

  1. Enable PPPoE on the PlayStation and connect a Linux laptop with an Ethernet cable.
  2. On the laptop, compile the PoC, raise the interface MTU, and run the PoC on the interface.
  3. On the PlayStation, start an internet connection test to initiate PPPoE.
  4. The console sends a PADI; the attacker replies with a PADO containing a large ACCOOKIE tag.
  5. After a timeout and a new PADI, the attacker replies with a PADO containing a large RELAYSID tag.
  6. The console sends a PADR that combines both large tags, overflowing the mbuf cluster.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

The PlayStation uses a small program in its core (kernel) to talk PPPoE, a way to connect to the internet over Ethernet. That program reserves a fixed-size memory buffer but can be tricked into writing more data than fits, which corrupts nearby memory. Someone on the same local network can trigger this by sending special network replies.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by m00nbsd

View all

3 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.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.