Infinite loop in the Mongoose PPP/PPPoE IPCP and IPV6CP option parser

A network-adjacent PPP or PPPoE peer can hang the Mongoose event loop with a single IPCP or IPV6CP configuration packet containing an option whose length byte is zero. Only builds using the built-in TCP/IP stack with a PPP or PPPoE driver are affected, and no tagged release shipped the vulnerable code.

CVE
CVE-2026-52054
Weakness
CWE-835
Vendor
Cesanta
Product
Mongoose (built-in TCP/IP stack, PPP/PPPoE driver)
Affected
master from commit 70650fedcfc508ac70c033ab3877cee26802d03f
through commit 07a49a7a2d7707e6257a0434c8b102c2056eb80e
No tagged release affected
Fixed in
7.22
commit a9df523f76f43a38bd53b4232b9cfd4c16869e71

Overview

Mongoose's built-in TCP/IP stack includes a PPP/PPPoE Layer-2 driver. Its IPCP/IPV6CP configuration-option parser walks the peer's option list using each option's self-declared length byte, and does not reject a length of zero. A network-adjacent PPP or PPPoE peer, with no authentication, can send one crafted IPCP or IPV6CP configuration packet that puts the parser into an infinite loop and hangs the Mongoose event loop.

The issue is in src/l2_ppp.c (amalgamated into mongoose.c). It affects Mongoose master from commit 70650fedcfc508ac70c033ab3877cee26802d03f through 07a49a7a2d7707e6257a0434c8b102c2056eb80e (the parent of the fix). It was fixed in commit a9df523f76f43a38bd53b4232b9cfd4c16869e71 and released in 7.22.

Affected configurations

The vulnerable code is reached only when all of the following are true:

  • Mongoose is built with the built-in TCP/IP stack (MG_ENABLE_TCPIP).
  • The Layer-2 driver is PPP or PPPoE.
  • The stack processes an inbound IPCP or IPV6CP configuration packet from the peer.

Builds that use Mongoose only as an application-level library (HTTP/MQTT/WebSocket over a host OS socket, the default for most users) are not affected, because they do not compile the built-in L2 PPP driver.

No tagged release ships the vulnerable parser: the affected find_opt helper was introduced on master after the 7.21 tag and was fixed before the next release.

Details

The PPP/PPPoE driver parses peer-supplied configuration options with a helper that walks the option list using each option's self-declared length byte:

static bool find_opt(const uint8_t opt, const uint8_t optlen,
                     const uint8_t *opts, size_t optslen, uint8_t *dest) {
  uint8_t *p = (uint8_t *) opts;
  while (optslen >= 2) {                 // parse options for requested one
    if (p[1] > optslen) return false;    // truncated / malformed
    if (p[0] == opt && p[1] == optlen) {
      memcpy(dest, p + 2, optlen - 2);
      return true;
    }
    optslen -= p[1];                     // advance by the declared length
    p += p[1];
  }
  return false;
}

A PPP option is encoded as type, length, value..., and the length byte (p[1]) is fully attacker-controlled. The loop advances p and decrements optslen by that length each iteration. The only guard rejects an option that is too long (p[1] > optslen); it does not reject an option that declares a length below the 2-byte minimum.

When a peer supplies an option whose length byte is 0, the loop makes no forward progress: optslen -= 0 leaves the counter unchanged and p += 0 leaves the cursor in place, so the optslen >= 2 condition never becomes false. The parser spins forever on the same byte.

Impact

Mongoose is single-threaded around its event loop, so the hang takes down the entire stack: no further connections, timers or I/O are serviced. A single crafted IPCP or IPV6CP packet is sufficient, and no authentication is required.

Proof of concept

The condition is reachable from a rogue PPP/PPPoE peer with no authentication. A reproducer was demonstrated to the maintainer using a two-process network setup: one process drives a built-in-TCP/IP Mongoose instance with a PPP L2, and the other sends a single IPCP configuration packet containing an option with a zero length byte. The target enters a busy loop and stops servicing its event loop.

A single IPCP packet with a zero-length option hangs the Mongoose event loop

The reproducer artifacts are held privately and were shared with the vendor; they are not included in this write-up.

Remediation

Update to Mongoose 7.22 or later. The fix (commit a9df523f76f43a38bd53b4232b9cfd4c16869e71) adds a lower bound to the length check so that any option declaring a length below the 2-byte minimum is rejected, guaranteeing forward progress:

if (p[1] > optslen || p[1] < 2) return false;  // truncated / malformed

There is no configuration-only mitigation other than disabling the built-in PPP/PPPoE L2.

References

Revision history

  1. Initial publication

Machine-readable: LVL0X00-2026-0003.json