Skip to content
Memory corruption Disclosed report Advanced CVE-2006-4304

Remote vulnerabilities in spp

The PS4/PS5 kernel's PPPoE implementation contains heap buffer overwrite and overread flaws in LCP/IPCP option handling, and an integer underflow in PAP input. A malicious PPPoE server could cause denial-of-service or potentially remote code execution in kernel context.

Andy Nguyen Follow

Originally disclosed on HackerOne

Bounty$12,500 High View original
  • Triaged in 34 days
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 7 months

Summary by the program

Summary

A malicious PPPoE server can cause denial-of-service or potentially remote code execution in kernel context on the PS4/PS5.

Heap buffer overwrite and overread in sppp_lcp_RCR and sppp_ipcp_RCR

For some reason, the PS4/PS5 is vulnerable to CVE-2006-4304. By having invalid options, it is possible to cause a heap buffer overwrite and overread.

C
static int
sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len)
{
	u_char *buf, *r, *p;
	struct ifnet *ifp = &sp->pp_if;
	int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
	u_int32_t hisaddr, desiredaddr;

	len -= 4;
	origlen = len;
	// ...
	buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT);
	if (! buf)
		return (0);
	// ...
	p = (void *)(h + 1);
	for (rlen=0; len>1 && p[1]; len-=p[1], p+=p[1]) { // [1]
		if (debug)
			addlog(" %s", sppp_ipcp_opt_name(*p));
		switch (*p) {
        // ...
		default:
			/* Others not supported. */
			if (debug)
				addlog(" [rej]");
			break;
		}
		/* Add the option to rejected list. */
		bcopy (p, r, p[1]); // [2]
		r += p[1];
		rlen += p[1]; // [3]
	}
	if (rlen) {
		if (debug)
			addlog(" send conf-rej\n");
		sppp_cp_send(sp, PPP_IPCP, CONF_REJ, h->ident, rlen, buf); // [4]
		goto end;
	} else if (debug)
		addlog("\n");

	// ...
}

Namely, at [1] the length of p[1] is not validated to be smaller or equal to len. As such, at [2] the call bcopy() will copy with a size potentially larger than both the source and the destination.

Furthermore, at [3] the return length is incremented by the malicious length. Hence, the data that is overread from the mbuf is copied into buf (with overflow) and returned to the malicious PPPoE server with sppp_cp_send().

For example this is some data that got sent back containing pointers:

C
00000000  54 ab 3a 9a ab ad 00 d9  d1 bc 83 e4 88 64 11 00  |T.:..........d..|
00000010  00 14 00 90 80 21 04 02  00 8e 2a ff 41 41 41 41  |.....!....*.AAAA|
00000020  41 41 41 41 41 41 41 41  41 41 41 41 00 00 00 00  |AAAAAAAAAAAA....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 38 00 2b c5  |............8.+.|
00000040  72 9a cf 01 03 00 08 00  38 61 07 eb bd ff ff bd  |r.......8a......|
00000050  ff ff bd ff ff d9 d1 bc  83 e4 29 00 00 00 b4 07  |..........).....|
00000060  00 00 03 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000000a0  00 00 00 00                                       |....            |
000000a4

Regarding exploitability of the overwrite, note that the allocation size for malloc() can be influenced via the LCP header:

C
static void
sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
{
	// ...
	struct lcp_header *h;
	// ...
	h = mtod(m, struct lcp_header *);
	// ...
	if (len > ntohs(h->len))
		len = ntohs(h->len);
	p = (u_char *)(h + 1);
	switch (h->type) {
	case CONF_REQ:
		// ...
		rv = (cp->RCR)(sp, h, len);
		// ...
	}
}

By doing so, it is possible to trigger a copy from a bigger mbuf to a smaller buf, thus allowing to overwrite adjacent allocations with controllable data.

See attachment for a proof-of-concept that leaks data and can eventually panic the device.

Integer underflow in sppp_pap_input leading to heap-buffer overread

C
void
sppp_pap_input(struct sppp *sp, struct mbuf *m)
{
	// ...
	int len, x;
	// ...
	int name_len, passwd_len;
	// ...
	h = mtod (m, struct lcp_header*);
	if (len > ntohs (h->len))
		len = ntohs (h->len); // [1]
	switch (h->type) {
	/* PAP request is my authproto */
	case PAP_REQ:
		name = 1 + (u_char*)(h+1);
		name_len = name[-1];
		passwd = name + name_len + 1;
		if (name_len > len - 6 || // [2]
		    (passwd_len = passwd[-1]) > len - 6 - name_len) {
			if (debug) {
				log(LOG_DEBUG, SPP_FMT "pap corrupted input "
				    "<%s id=0x%x len=%d",
				    SPP_ARGS(ifp),
				    sppp_auth_type_name(PPP_PAP, h->type),
				    h->ident, ntohs(h->len));
				if (len > 4)
					sppp_print_bytes((u_char*)(h+1), len-4);
				addlog(">\n");
			}
			break;
		}
		// ...
		if (name_len > AUTHMAXLEN ||
		    passwd_len > AUTHMAXLEN ||
		    bcmp(name, sp->hisauth.name, name_len) != 0 ||
		    bcmp(passwd, sp->hisauth.secret, passwd_len) != 0) {
			/* action scn, tld */
			mlen = sizeof(FAILMSG) - 1;
			sppp_auth_send(&pap, sp, PAP_NAK, h->ident,
				       sizeof mlen, (const char *)&mlen,
				       sizeof(FAILMSG) - 1, (u_char *)FAILMSG,
				       0);
			pap.tld(sp);
			break;
		}
		// ...
		if (name_len == sp->hisauth.name_len &&
		    memcmp(name, sp->hisauth.name, name_len) == 0 && // [3]
		    secret_len == sp->hisauth.secret_len &&
		    memcmp(secret, sp->hisauth.secret, secret_len) == 0) {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_ACK;
		} else {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_NAK;
		}
	// ...
	}
}

At [1], it is possible to set len to a length between 0 and 5. Thus, at [2] len - 6 can have a negative length between -6 and -1. As such, the checks for name_len and passwd_len can be bypassed, and it is possible to have lengths up to 255 bytes. As a consequence, at [3] it is possible to read out-of-bounds from the mbuf when comparing the name and password with memcmp(). Since different responses are returned back based on the comparison, an attacker might be able to use this as a an oracle to leak the out-of-bounds data (by setting the name and secret beforehand). This could be used to leak pointers and defeat KASLR remotely.

Note that this vulnerability is still affecting NetBSD and OpenBSD. FreeBSD seemed to have deprecated this whole protocol.

Impact

A malicious PPPoE server can cause denial-of-service or potentially remote code execution in kernel context on the PS4/PS5.

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. 8 min read.

Context

The target is the PlayStation 4 (and, as the report notes, the PS5), and the affected component is the kernel's PPP implementation, specifically the sppp (serial PPP) code that handles the Link Control Protocol (LCP), IP Control Protocol (IPCP) and Password Authentication Protocol (PAP). PPPoE is the transport that carries PPP frames over Ethernet, and the PS4/PS5 speaks it. In normal operation a PPP peer negotiates options through Configure-Request messages (LCP/IPCP), and authenticates with PAP. The kernel parses those frames and replies with Configure-Reject, Configure-Ack, Configure-Nak or authentication responses.

The report describes two distinct memory-safety bugs in that parsing code. The first is a heap buffer overwrite and overread in sppp_lcp_RCR and sppp_ipcp_RCR. The second is an integer underflow in sppp_pap_input that leads to a heap buffer overread. Both are reachable from the network by a malicious PPPoE server, and both run in kernel context.

The report opens by noting that, for some reason, the PS4/PS5 is vulnerable to CVE-2006-4304, a FreeBSD PPP advisory from 2006. The same class of bug is described as still affecting NetBSD and OpenBSD, while FreeBSD appears to have deprecated the whole protocol.

Setup

The precondition is simply that the console connects to an attacker-controlled PPPoE server. No account, role or special tooling is described in the report. The attacker needs to be in a position to act as the PPPoE peer: the console initiates the connection, and the malicious server drives the negotiation and authentication exchange. The proof of concept is referenced as an attachment that leaks data and can eventually panic the device; its contents are not reproduced in the text.

Finding it

The researcher recognised that the console's PPP stack carried a known-vulnerable pattern: option lengths inside Configure-Request frames were trusted without being checked against the remaining buffer length. That is the shape of CVE-2006-4304, and the code paths in sppp_ipcp_RCR (and the analogous sppp_lcp_RCR) still contained it. Separately, the PAP input handler performed its length checks with a subtraction that can go negative, which makes the checks ineffective.

Exploitation

Step 1: Heap overwrite and overread through IPCP Configure-Request options

The vulnerable handler is sppp_ipcp_RCR. The relevant parts, with the report's annotations:

C
static int
sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len)
{
	u_char *buf, *r, *p;
	struct ifnet *ifp = &sp->pp_if;
	int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
	u_int32_t hisaddr, desiredaddr;

	len -= 4;
	origlen = len;
	// ...
	buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT);
	if (! buf)
		return (0);
	// ...
	p = (void *)(h + 1);
	for (rlen=0; len>1 && p[1]; len-=p[1], p+=p[1]) { // [1]
		if (debug)
			addlog(" %s", sppp_ipcp_opt_name(*p));
		switch (*p) {
        // ...
		default:
			/* Others not supported. */
			if (debug)
				addlog(" [rej]");
			break;
		}
		/* Add the option to rejected list. */
		bcopy (p, r, p[1]); // [2]
		r += p[1];
		rlen += p[1]; // [3]
	}
	if (rlen) {
		if (debug)
			addlog(" send conf-rej\n");
		sppp_cp_send(sp, PPP_IPCP, CONF_REJ, h->ident, rlen, buf); // [4]
		goto end;
	} else if (debug)
		addlog("\n");

	// ...
}

At [1] the loop walks the option list, advancing by p[1] (the option length byte) each iteration. The length p[1] is never validated to be smaller than or equal to len. As a result, at [2] the bcopy() copies p[1] bytes, a size potentially larger than both the source and the destination buffer. At [3] the return length rlen is incremented by that same malicious length, so the overread data from the mbuf is copied into buf (with overflow) and then returned to the malicious PPPoE server through sppp_cp_send() at [4].

The report shows an example of data that was sent back containing pointers:

C
00000000  54 ab 3a 9a ab ad 00 d9  d1 bc 83 e4 88 64 11 00  |T.:..........d..|
00000010  00 14 00 90 80 21 04 02  00 8e 2a ff 41 41 41 41  |.....!....*.AAAA|
00000020  41 41 41 41 41 41 41 41  41 41 41 41 00 00 00 00  |AAAAAAAAAAAA....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 38 00 2b c5  |............8.+.|
00000040  72 9a cf 01 03 00 08 00  38 61 07 eb bd ff ff bd  |r.......8a......|
00000050  ff ff bd ff ff d9 d1 bc  83 e4 29 00 00 00 b4 07  |..........).....|
00000060  00 00 03 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000000a0  00 00 00 00                                       |....            |
000000a4

The report presents this as an example of data sent back that contained pointers.

Step 2: Influencing the allocation size to turn the overread into a controlled overwrite

For exploitability of the overwrite, the report points out that the malloc() size can be influenced through the LCP header. The relevant code is in sppp_cp_input:

C
static void
sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
{
	// ...
	struct lcp_header *h;
	// ...
	h = mtod(m, struct lcp_header *);
	// ...
	if (len > ntohs(h->len))
		len = ntohs(h->len);
	p = (u_char *)(h + 1);
	switch (h->type) {
	case CONF_REQ:
		// ...
		rv = (cp->RCR)(sp, h, len);
		// ...
	}
}

Because len is clamped to the header's own length field, the attacker controls the value passed into the handler and therefore the malloc() size. By doing so, it is possible to trigger a copy from a bigger mbuf to a smaller buf, which allows overwriting adjacent allocations with controllable data. The report refers to an attachment for a proof of concept that leaks data and can eventually panic the device.

Step 3: Integer underflow in PAP input leading to heap overread

The second bug is in sppp_pap_input:

C
void
sppp_pap_input(struct sppp *sp, struct mbuf *m)
{
	// ...
	int len, x;
	// ...
	int name_len, passwd_len;
	// ...
	h = mtod (m, struct lcp_header*);
	if (len > ntohs (h->len))
		len = ntohs (h->len); // [1]
	switch (h->type) {
	/* PAP request is my authproto */
	case PAP_REQ:
		name = 1 + (u_char*)(h+1);
		name_len = name[-1];
		passwd = name + name_len + 1;
		if (name_len > len - 6 || // [2]
		    (passwd_len = passwd[-1]) > len - 6 - name_len) {
			if (debug) {
				log(LOG_DEBUG, SPP_FMT "pap corrupted input "
				    "<%s id=0x%x len=%d",
				    SPP_ARGS(ifp),
				    sppp_auth_type_name(PPP_PAP, h->type),
				    h->ident, ntohs(h->len));
				if (len > 4)
					sppp_print_bytes((u_char*)(h+1), len-4);
				addlog(">\n");
			}
			break;
		}
		// ...
		if (name_len > AUTHMAXLEN ||
		    passwd_len > AUTHMAXLEN ||
		    bcmp(name, sp->hisauth.name, name_len) != 0 ||
		    bcmp(passwd, sp->hisauth.secret, passwd_len) != 0) {
			/* action scn, tld */
			mlen = sizeof(FAILMSG) - 1;
			sppp_auth_send(&pap, sp, PAP_NAK, h->ident,
				       sizeof mlen, (const char *)&mlen,
				       sizeof(FAILMSG) - 1, (u_char *)FAILMSG,
				       0);
			pap.tld(sp);
			break;
		}
		// ...
		if (name_len == sp->hisauth.name_len &&
		    memcmp(name, sp->hisauth.name, name_len) == 0 && // [3]
		    secret_len == sp->hisauth.secret_len &&
		    memcmp(secret, sp->hisauth.secret, secret_len) == 0) {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_ACK;
		} else {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_NAK;
		}
	// ...
	}
}

At [1] the attacker can set len to a value between 0 and 5. At [2] the expression len - 6 then becomes a negative length between -6 and -1. The checks on name_len and passwd_len are therefore bypassed, and lengths up to 255 bytes are accepted. At [3] the memcmp() against the configured name and secret then reads out of bounds from the mbuf. Because the response differs depending on the comparison result, an attacker might be able to use this as an oracle to leak the out-of-bounds data, by setting the name and secret beforehand. That leaked data could include pointers and be used to defeat KASLR remotely.

Root cause

Both bugs come from trusting length fields in attacker-controlled frames. In the IPCP/LCP Configure-Request handler, the per-option length byte p[1] is used to advance the loop and as the bcopy() size without ever being checked against the remaining len, so a single oversized option length produces both an overread from the mbuf and an overwrite of the heap allocation. The allocation size itself is derived from the header length field, which the attacker also controls, so the relationship between source and destination sizes can be steered.

In the PAP handler, the bounds check is written as name_len > len - 6 and passwd_len > len - 6 - name_len. With len clamped to a value below 6, the subtraction underflows into a negative number, and the comparisons no longer constrain the lengths. The subsequent memcmp() calls then operate on lengths up to 255 bytes against a buffer that is shorter than that.

The report notes that the PAP vulnerability is still affecting NetBSD and OpenBSD.

Impact

A malicious PPPoE server can cause denial of service, or potentially remote code execution in kernel context, on the PS4/PS5. The overwrite path allows adjacent heap allocations to be overwritten with controllable data. The overread paths leak kernel memory back to the server, either directly in the Configure-Reject reply or through the PAP comparison oracle, which could be used to leak pointers and defeat KASLR remotely. The proof of concept referenced in the report leaks data and can eventually panic the device.

Fix

The report does not describe a specific patch. FreeBSD is noted as having deprecated the whole protocol, which removes the attack surface there; NetBSD and OpenBSD are described as still affected.

Variants to test

  1. Other PPP control protocols that share the option-walking pattern. Send Configure-Request frames with an option length byte larger than the remaining payload and watch for a Configure-Reject that echoes back more bytes than were sent. A positive result is a reply containing data the attacker did not supply.
  2. Allocation-size steering. Vary the LCP header length field while keeping an oversized option length, and observe whether the reply length and contents change in a way that indicates a copy from a larger source into a smaller destination. A positive result is corruption or a crash that depends on the chosen header length.
  3. PAP length underflow. Send PAP authentication requests with the header length field set between 0 and 5 and name/password length bytes up to 255. A positive result is a response that differs depending on the configured credentials, which turns the comparison into an oracle.
  4. Other authentication protocols with similar length arithmetic. Look for checks of the form field_len > len - constant where len can be smaller than the constant, and test whether the check can be bypassed.

Hunting notes

This class of bug hides in protocol parsers that walk variable-length option lists, especially legacy or embedded network stacks that were forked from old BSD code. During recon, the signals are a PPPoE implementation on the device, kernel-side handling of LCP/IPCP/PAP, and code that resembles old advisories. Comparing the target's stack against historical CVEs for the same codebase is a productive starting point: the report itself begins from CVE-2006-4304.

The impact case here rests on two things: the overread is returned to the attacker in a protocol response, and the allocation size can be influenced so the overwrite is controllable. The report ties the PAP leak to defeating KASLR remotely and references a proof of concept that leaks data and can panic the device. When reporting similar bugs, showing the echoed bytes and the controllable allocation size is the evidence that matters.

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. 19 min read.

What happened, in plain words

A security researcher found a way to attack a PlayStation 4 (and, according to the report, a PlayStation 5) by pretending to be a particular kind of network server that the console talks to. When the console connects to this fake server, it sends it small messages asking to agree on settings and to log in. The console's software that reads those messages has two mistakes in it. Both mistakes let the fake server make the console read memory it should not read, and one of them lets it write over memory it should not write. Because this code runs deep inside the console's operating system, in the part called the kernel, the consequences are serious: the console can be crashed, and in principle an attacker could run their own code on it.

The report was filed through a bug bounty programme, which is a scheme where companies pay people for finding and reporting security problems.

Before going further, a few words that will come up constantly:

  • Kernel: the core of an operating system. It sits between the hardware and the programs you run, and it has total control over the machine. A bug in the kernel is much more dangerous than a bug in an app, because the kernel is not supposed to be constrained by anything.
  • Memory: the working space where a running program keeps its data. Think of it as a very long row of numbered boxes, each holding a small value. Programs are only supposed to touch the boxes that belong to them.
  • Buffer: a reserved stretch of those boxes, set aside to hold something like a message. A buffer has a fixed size, decided in advance.
  • Buffer overflow: writing more data into a buffer than it can hold. The extra data spills into the neighbouring boxes, which belong to something else. It is like pouring a litre of water into a half-litre glass: the surplus goes everywhere.
  • Overread: the opposite problem. Reading past the end of a buffer, so the program picks up whatever happens to sit next to it. That neighbouring data might be something private, like a password or an internal address.
  • Heap: the general-purpose pool of memory a program borrows from at runtime when it needs a buffer of a size it did not know in advance. "Heap buffer" just means a buffer taken from that pool.
  • Pointer: a value that is really an address, telling the program where in memory something lives. Pointers are sensitive: if an attacker learns them, they learn the layout of the program's memory.

Context

The target is the PlayStation 4, and the report notes the PS5 is affected too. The vulnerable part is the console's implementation of PPP, the Point-to-Point Protocol. PPP is a way for two machines connected directly to each other to agree on how to talk and to prove who they are. It is the protocol your home internet connection often uses behind the scenes when your router logs in to your broadband provider.

PPP has several sub-protocols, and the report names three of them:

  • LCP (Link Control Protocol): the first conversation, where the two sides agree on the ground rules of the connection.
  • IPCP (Internet Protocol Control Protocol): a follow-up conversation where they agree on the settings needed to carry internet traffic, such as addresses.
  • PAP (Password Authentication Protocol): a very simple login step where one side sends a username and a password in plain form.

The transport used here is PPPoE, which means "PPP over Ethernet". Ethernet is the ordinary wired networking technology; PPPoE simply wraps the PPP conversation inside Ethernet frames so it can travel over a normal network cable. The console speaks PPPoE, which is the doorway an attacker uses.

In normal operation, the two sides exchange Configure-Request messages during LCP and IPCP. Each such message carries a list of options, and each option is a small bundle of bytes whose first byte says what kind of option it is and whose second byte says how long that option is. The receiver answers with one of several replies: Configure-Reject (I do not accept these options), Configure-Ack (I accept them) or Configure-Nak (I would prefer something else). During PAP, the sides exchange authentication requests and responses.

The report describes two separate memory-safety bugs in the code that parses these messages. The first is a heap buffer overwrite and overread in two functions, sppp_lcp_RCR and sppp_ipcp_RCR. The second is an integer underflow in sppp_pap_input that leads to a heap buffer overread. Both can be triggered over the network by a malicious PPPoE server, and both run in kernel context.

The report opens by noting that, for some reason, the PS4 and PS5 are vulnerable to CVE-2006-4304. A CVE is a publicly catalogued security flaw, and the number tells you it was recorded in 2006. This particular one is a FreeBSD PPP advisory from that year. FreeBSD is an operating system whose PPP code this advisory concerns. The same class of bug is described as still affecting NetBSD and OpenBSD, two other operating systems, while FreeBSD appears to have deprecated the whole protocol, meaning it removed or retired it.

Setup

The only precondition is that the console connects to a PPPoE server controlled by the attacker. The report describes no account, no special role and no special tooling. The attacker simply needs to be in a position to act as the PPPoE peer: the console starts the connection, and the malicious server then drives the negotiation and authentication exchange, sending whatever messages it likes.

The proof of concept is mentioned as an attachment that leaks data and can eventually panic the device. Panic here means the kernel deliberately stops the whole machine when it detects that something has gone badly wrong, which shows up as a crash. The contents of that attachment are not reproduced in the report text.

Finding it

The researcher recognised that the console's PPP stack carried a known-vulnerable pattern: the length of each option inside a Configure-Request frame was trusted without being checked against how much data actually remained in the buffer. That is exactly the shape of CVE-2006-4304, and the code paths in sppp_ipcp_RCR (and the analogous sppp_lcp_RCR) still contained it. Separately, the PAP input handler performed its length checks with a subtraction that can go negative, which makes the checks ineffective.

Exploitation

Step 1: Heap overwrite and overread through IPCP Configure-Request options

The vulnerable handler is sppp_ipcp_RCR. This is the function that processes an incoming IPCP Configure-Request. The relevant parts, with the report's annotations, are:

C
static int
sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len)
{
	u_char *buf, *r, *p;
	struct ifnet *ifp = &sp->pp_if;
	int rlen, origlen, debug = ifp->if_flags & IFF_DEBUG;
	u_int32_t hisaddr, desiredaddr;

	len -= 4;
	origlen = len;
	// ...
	buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT);
	if (! buf)
		return (0);
	// ...
	p = (void *)(h + 1);
	for (rlen=0; len>1 && p[1]; len-=p[1], p+=p[1]) { // [1]
		if (debug)
			addlog(" %s", sppp_ipcp_opt_name(*p));
		switch (*p) {
        // ...
		default:
			/* Others not supported. */
			if (debug)
				addlog(" [rej]");
			break;
		}
		/* Add the option to rejected list. */
		bcopy (p, r, p[1]); // [2]
		r += p[1];
		rlen += p[1]; // [3]
	}
	if (rlen) {
		if (debug)
			addlog(" send conf-rej\n");
		sppp_cp_send(sp, PPP_IPCP, CONF_REJ, h->ident, rlen, buf); // [4]
		goto end;
	} else if (debug)
		addlog("\n");

	// ...
}

Line by line, in plain words:

  • The function receives the connection state (sp), a pointer to the message header (h) and the length of the data (len).
  • len -= 4; subtracts the size of the fixed header, leaving the length of the option list that follows.
  • buf = r = malloc ((len < 6? 6: len), M_TEMP, M_NOWAIT); borrows a buffer from the heap. Its size is the option-list length, but never less than 6 bytes. r is a moving cursor into that buffer, and buf keeps the start so the buffer can be sent later.
  • p = (void *)(h + 1); points p at the first byte of the option list, just after the header.
  • The for loop at marker [1] walks the option list. Each iteration looks at the option's length byte p[1], then moves p forward by that many bytes and shrinks len by the same amount. The loop condition len>1 && p[1] keeps going while there is data left and the length byte is non-zero.
  • Inside the loop, the switch decides what kind of option this is. Options that are not supported fall into default, which just logs a note in debug mode.
  • At marker [2], bcopy (p, r, p[1]); copies p[1] bytes from the message into the buffer. bcopy is an old C function that copies a given number of bytes from one place to another.
  • r += p[1]; moves the cursor forward, and at marker [3] rlen += p[1]; adds the same amount to the running total of bytes collected.
  • After the loop, if anything was collected, marker [4] calls sppp_cp_send() to send a Configure-Reject back to the peer, containing rlen bytes from buf.

The flaw is at marker [1]: the length p[1] is never validated to be smaller than or equal to len, the amount of data actually remaining. The loop trusts a number supplied by the attacker. As a result, at marker [2] the bcopy() copies p[1] bytes, a size potentially larger than both the source and the destination buffer. At marker [3] the return length rlen is incremented by that same malicious length, so the overread data from the message buffer is copied into buf (with overflow) and then returned to the malicious PPPoE server through sppp_cp_send() at marker [4].

In everyday terms: imagine a form where each line starts with a number saying how many characters that line has. The program trusts that number blindly. If you write "500" on a line that only has ten characters, the program reads 500 characters, running far past the end of the page and copying whatever it finds into its reply to you.

The report shows an example of data that was sent back containing pointers:

C
00000000  54 ab 3a 9a ab ad 00 d9  d1 bc 83 e4 88 64 11 00  |T.:..........d..|
00000010  00 14 00 90 80 21 04 02  00 8e 2a ff 41 41 41 41  |.....!....*.AAAA|
00000020  41 41 41 41 41 41 41 41  41 41 41 41 00 00 00 00  |AAAAAAAAAAAA....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 38 00 2b c5  |............8.+.|
00000040  72 9a cf 01 03 00 08 00  38 61 07 eb bd ff ff bd  |r.......8a......|
00000050  ff ff bd ff ff d9 d1 bc  83 e4 29 00 00 00 b4 07  |..........).....|
00000060  00 00 03 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000000a0  00 00 00 00                                       |....            |
000000a4

This is a classic hex dump: the left column is the position in the data, the middle is the bytes written in hexadecimal (base 16, where each pair of characters is one byte), and the right column shows the same bytes as readable characters where possible. The report presents this as an example of data sent back that contained pointers. The surrounding bytes are kernel memory that was overread and echoed back in the Configure-Reject. The reply contained data overread from the message buffer, including pointers.

Step 2: Influencing the allocation size to turn the overread into a controlled overwrite

For exploitability of the overwrite, the report points out that the malloc() size can be influenced through the LCP header. The relevant code is in sppp_cp_input, the general function that receives control-protocol messages and dispatches them to the right handler:

C
static void
sppp_cp_input(const struct cp *cp, struct sppp *sp, struct mbuf *m)
{
	// ...
	struct lcp_header *h;
	// ...
	h = mtod(m, struct lcp_header *);
	// ...
	if (len > ntohs(h->len))
		len = ntohs(h->len);
	p = (u_char *)(h + 1);
	switch (h->type) {
	case CONF_REQ:
		// ...
		rv = (cp->RCR)(sp, h, len);
		// ...
	}
}

Line by line:

  • h = mtod(m, struct lcp_header *); takes the incoming message buffer m and points h at its header. mtod is a helper that turns a message buffer into a typed pointer.
  • if (len > ntohs(h->len)) len = ntohs(h->len); clamps the length. ntohs converts a number from network byte order to the machine's own byte order, because different computers store multi-byte numbers in different orders. The effect is that len is reduced to the length stated in the header if the actual data is longer.
  • switch (h->type) looks at the message type. When it is CONF_REQ, a Configure-Request, the code calls the handler through a function pointer, (cp->RCR)(sp, h, len), passing along the clamped length.

Because len is clamped to the header's own length field, and that field comes from the attacker, the attacker controls the value passed into the handler and therefore the malloc() size in Step 1. By doing so, it is possible to trigger a copy from a bigger message buffer to a smaller buf, which allows overwriting adjacent allocations with controllable data. "Adjacent allocations" means the other buffers sitting next to this one in the heap; spilling out of one lands in the next. The report refers to an attachment for a proof of concept that leaks data and can eventually panic the device.

An overread leaks information, while an overwrite lets the attacker change adjacent heap data with controllable content.

Step 3: Integer underflow in PAP input leading to heap overread

The second bug is in sppp_pap_input, the function that handles incoming PAP login messages:

C
void
sppp_pap_input(struct sppp *sp, struct mbuf *m)
{
	// ...
	int len, x;
	// ...
	int name_len, passwd_len;
	// ...
	h = mtod (m, struct lcp_header*);
	if (len > ntohs (h->len))
		len = ntohs (h->len); // [1]
	switch (h->type) {
	/* PAP request is my authproto */
	case PAP_REQ:
		name = 1 + (u_char*)(h+1);
		name_len = name[-1];
		passwd = name + name_len + 1;
		if (name_len > len - 6 || // [2]
		    (passwd_len = passwd[-1]) > len - 6 - name_len) {
			if (debug) {
				log(LOG_DEBUG, SPP_FMT "pap corrupted input "
				    "<%s id=0x%x len=%d",
				    SPP_ARGS(ifp),
				    sppp_auth_type_name(PPP_PAP, h->type),
				    h->ident, ntohs(h->len));
				if (len > 4)
					sppp_print_bytes((u_char*)(h+1), len-4);
				addlog(">\n");
			}
			break;
		}
		// ...
		if (name_len > AUTHMAXLEN ||
		    passwd_len > AUTHMAXLEN ||
		    bcmp(name, sp->hisauth.name, name_len) != 0 ||
		    bcmp(passwd, sp->hisauth.secret, passwd_len) != 0) {
			/* action scn, tld */
			mlen = sizeof(FAILMSG) - 1;
			sppp_auth_send(&pap, sp, PAP_NAK, h->ident,
				       sizeof mlen, (const char *)&mlen,
				       sizeof(FAILMSG) - 1, (u_char *)FAILMSG,
				       0);
			pap.tld(sp);
			break;
		}
		// ...
		if (name_len == sp->hisauth.name_len &&
		    memcmp(name, sp->hisauth.name, name_len) == 0 && // [3]
		    secret_len == sp->hisauth.secret_len &&
		    memcmp(secret, sp->hisauth.secret, secret_len) == 0) {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_ACK;
		} else {
			sp->scp[IDX_PAP].rcr_type = CP_RCR_NAK;
		}
	// ...
	}
}

Line by line:

  • h = mtod (m, struct lcp_header*); points h at the message header, as before.
  • At marker [1], if (len > ntohs (h->len)) len = ntohs (h->len); clamps len to the header's length field, again attacker-controlled.
  • In the PAP_REQ case, name = 1 + (u_char*)(h+1); points at the username, which starts one byte after the header. name_len = name[-1]; reads the byte just before the username, which holds its length. passwd = name + name_len + 1; points at the password, which follows the username and its length byte.
  • At marker [2], the check name_len > len - 6 compares the username length against the remaining length minus 6. The second half, (passwd_len = passwd[-1]) > len - 6 - name_len, reads the password length and compares it against what is left after subtracting the username length. If either check fails, the code logs a debug message and breaks out, treating the input as corrupt.
  • If the checks pass, the code compares the supplied username and password against the configured ones using bcmp, an old byte-comparison function. If they do not match, it sends a PAP_NAK rejection back.
  • At marker [3], if the lengths match the configured ones, memcmp(name, sp->hisauth.name, name_len) == 0 compares the username byte by byte. memcmp returns zero when the two stretches of memory are identical. The same is done for the secret, and the result decides whether the reply is CP_RCR_ACK (accepted) or CP_RCR_NAK (rejected).

At marker [1], the attacker can set len to a value between 0 and 5. At marker [2], the expression len - 6 then becomes a negative length between -6 and -1. This is an integer underflow: with len below 6, len - 6 becomes a negative length between -6 and -1, so the checks no longer constrain the lengths. The checks on name_len and passwd_len are therefore bypassed, and lengths up to 255 bytes are accepted. At marker [3], the memcmp() against the configured name and secret then reads out of bounds from the message buffer.

Because the response differs depending on the comparison result, an attacker might be able to use this as an oracle. An oracle is any behaviour that answers a yes or no question about secret data. Here, the attacker can set the name and secret beforehand, then send guesses and watch whether the reply is an acceptance or a rejection. That leaked data could include pointers and be used to defeat KASLR. KASLR stands for Kernel Address Space Layout Randomisation: the operating system deliberately places its code and data at unpredictable addresses each time it boots, so that an attacker who finds a memory bug cannot know where to jump. Leaking a pointer reveals part of that layout, which is the first step to defeating the randomisation.

Root cause

Both bugs come from trusting length fields in frames the attacker controls. In the IPCP and LCP Configure-Request handler, the per-option length byte p[1] is used to advance the loop and as the bcopy() size without ever being checked against the remaining len, so a single oversized option length produces both an overread from the message buffer and an overwrite of the heap allocation. The allocation size itself is derived from the header length field, which the attacker also controls, so the relationship between source and destination sizes can be steered.

In the PAP handler, the bounds check is written as name_len > len - 6 and passwd_len > len - 6 - name_len. With len clamped to a value below 6, the subtraction underflows into a negative number, and the comparisons no longer constrain the lengths. The subsequent memcmp() calls then operate on lengths up to 255 bytes against a buffer that is shorter than that.

The report notes that the PAP vulnerability is still affecting NetBSD and OpenBSD.

Impact

A malicious PPPoE server can cause denial of service, or potentially remote code execution in kernel context, on the PS4 and PS5. Denial of service means making the device unusable, here by crashing it. Remote code execution means getting the device to run code the attacker supplied, without physical access. The overwrite path allows adjacent heap allocations to be overwritten with controllable data. The overread paths leak kernel memory back to the server, either directly in the Configure-Reject reply or through the PAP comparison oracle, which could be used to leak pointers and defeat KASLR remotely. The proof of concept referenced in the report leaks data and can eventually panic the device.

Fix

The report does not describe a specific patch. FreeBSD is noted as having deprecated the whole protocol, which removes the attack surface there; NetBSD and OpenBSD are described as still affected.

Variants to test

These are follow-up experiments in the same spirit as the report's findings:

  1. Other PPP control protocols that share the option-walking pattern. Send Configure-Request frames with an option length byte larger than the remaining payload and watch for a Configure-Reject that echoes back more bytes than were sent. A positive result is a reply containing data the attacker did not supply.
  2. Allocation-size steering. Vary the LCP header length field while keeping an oversized option length, and observe whether the reply length and contents change in a way that indicates a copy from a larger source into a smaller destination. A positive result is corruption or a crash that depends on the chosen header length.
  3. PAP length underflow. Send PAP authentication requests with the header length field set between 0 and 5 and name and password length bytes up to 255. A positive result is a response that differs depending on the configured credentials, which turns the comparison into an oracle.
  4. Other authentication protocols with similar length arithmetic. Look for checks of the form field_len > len - constant where len can be smaller than the constant, and test whether the check can be bypassed.

Hunting notes

This class of bug hides in protocol parsers that walk variable-length option lists, especially legacy or embedded network stacks that were forked from old BSD code. "Forked" means copied from an existing codebase and then developed separately, which is how old mistakes travel into new products. During recon, the signals are a PPPoE implementation on the device, kernel-side handling of LCP, IPCP and PAP, and code that resembles old advisories. Comparing the target's stack against historical CVEs for the same codebase is a productive starting point: the report itself begins from CVE-2006-4304.

The impact case here rests on two things: the overread is returned to the attacker in a protocol response, and the allocation size can be influenced so the overwrite is controllable. The report ties the PAP leak to defeating KASLR remotely and references a proof of concept that leaks data and can panic the device. When reporting similar bugs, showing the echoed bytes and the controllable allocation size is the evidence that matters.

Glossary

  • Bug bounty programme: a scheme where an organisation pays researchers for finding and reporting security flaws in its products.
  • Kernel: the core of an operating system, with full control over the hardware and over every running program.
  • Memory: the working storage where a running program keeps its data, organised as numbered boxes.
  • Buffer: a stretch of memory reserved to hold data such as a message, with a fixed size.
  • Buffer overflow: writing more data into a buffer than it can hold, so the surplus spills into neighbouring memory.
  • Overread: reading past the end of a buffer, picking up whatever data happens to sit next to it.
  • Heap: the pool of memory a program borrows from at runtime for buffers whose size is not known in advance.
  • Pointer: a value that is a memory address, telling the program where something lives.
  • PPP (Point-to-Point Protocol): a protocol for two directly connected machines to agree on how to communicate and to authenticate.
  • LCP (Link Control Protocol): the PPP sub-protocol where the two sides agree on the ground rules of the link.
  • IPCP (Internet Protocol Control Protocol): the PPP sub-protocol where the two sides agree on settings needed to carry internet traffic.
  • PAP (Password Authentication Protocol): a simple PPP login step where a username and password are sent in plain form.
  • PPPoE (PPP over Ethernet): a way of carrying a PPP conversation inside ordinary Ethernet frames.
  • Ethernet: the standard wired networking technology used for local networks.
  • Configure-Request: a message asking the other side to accept a list of options.
  • Configure-Reject: a reply saying the listed options are not accepted.
  • Configure-Ack: a reply saying the listed options are accepted.
  • Configure-Nak: a reply saying the other side would prefer different settings.
  • CVE: a publicly catalogued security flaw, identified by a number such as CVE-2006-4304.
  • FreeBSD, NetBSD, OpenBSD: three operating systems whose networking code has been widely reused.
  • Deprecated: retired or removed from active use.
  • Panic: the kernel deliberately stopping the whole machine when it detects a serious fault, which appears as a crash.
  • malloc: the function that borrows a buffer of a requested size from the heap.
  • bcopy: an old C function that copies a given number of bytes from one place to another.
  • memcmp and bcmp: functions that compare two stretches of memory byte by byte and report whether they are equal.
  • ntohs: a function that converts a multi-byte number from network byte order to the machine's own byte order.
  • Hex dump: a display of raw bytes in hexadecimal, with a readable-character column on the right.
  • Integer underflow: subtracting a larger number from a smaller one in a fixed-width integer, so the result wraps around instead of going negative as ordinary arithmetic would.
  • Oracle: any behaviour that answers a yes or no question about secret data, letting an attacker learn it bit by bit.
  • KASLR (Kernel Address Space Layout Randomisation): a defence that places kernel code and data at unpredictable addresses each boot.
  • Denial of service: making a device or service unusable, for example by crashing it.
  • Remote code execution: getting a device to run code supplied by an attacker, without physical access.
  • Kernel context: running inside the kernel, with the kernel's full privileges.
  • Forked: copied from an existing codebase and then developed separately.

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.

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.