Skip to content
RCE Write-up Advanced

Mongoose: Preauth RCE and mTLS Bypass on Millions of Devices

Mongoose's built-in TLS and mDNS implementations contain three independent flaws: a P-384 CA certificate causes mTLS signature verification to be skipped entirely, an oversized RSA public key in a client certificate overflows a fixed heap buffer during the TLS handshake, and a single mDNS UDP packet overflows a fixed stack buffer. An unauthenticated remote attacker could bypass mTLS authentication or achieve remote code execution as root on affected embedded devices.

evilsocket.net

Published on evilsocket.net

So, Mongoose. If you’ve never heard of it, you’ve almost certainly used a device that runs it.

The author, on evilsocket.net

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

Likely three separate coding mistakes: a certificate signature check that returns success without verifying when the CA key is P-384, a public-key copy into a fixed 528-byte heap buffer with no length check, and an mDNS response builder that packs multiple records into a stack buffer sized for a single name without bounds checking.

Impact

A remote unauthenticated attacker could bypass mTLS on servers using a P-384 CA, and could achieve remote code execution as root during the TLS handshake or via a single mDNS UDP packet, though the mDNS RCE depends on the TXT buffer being configured larger than default and on target hardening such as an executable heap or stack.

What the attacker needed

Network access to the device; Mongoose 7.0 through 7.20; built-in TLS or mDNS enabled; for mTLS bypass: P-384 CA certificate

The fix

Mongoose 7.21 was released with patches for all three vulnerabilities; users unable to update should switch away from the built-in TLS, disable mDNS, and avoid P-384 CA certificates.

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 write-up has not been written yet. The Original tab links to the source.

Mongoose is a small networking library baked into many internet-connected gadgets. Mutual TLS is a way for two machines to prove who they are using certificates, like a passport check. Here, the passport check was skipped for one type of certificate authority, and two other places copied attacker-supplied data into buffers that were too small, which can let an attacker run their own code on the device.

What is RCE?

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

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.