Mangoose - Use of Out-of-range Pointer Offset in X.509 Certificate ECDSA Signature Parsing

High

Synopsis

In Mongoose, the built-in TLS stack (MG_TLS=MG_TLS_BUILTIN) parses the ECDSA signature of a peer's X.509 certificate in mg_tls_verify_cert_signature() (src/tls_builtin.c). The function copies the signature integers (r and s) using the attacker-supplied DER length fields without validating them against the actual buffer bounds. A remote, unauthenticated peer can trigger an out-of-bounds read, and a crash, during the TLS handshake.

The ASN.1 DER encoding of the signature allows a length to be expressed in long form. A certificate whose signature declares an oversized length for the first INTEGER (r) is not rejected. For example, replacing 02 21 with 02 83 A0 00 00 declares a length of 10,485,760 bytes. mg_tls_verify_cert_signature() uses this value directly to copy data and advance its pointer. The memmove then reads far past the end of the signature buffer.

The parsing happens in mg_tls_recv_cert(), before the signature or the trust chain is verified. A self-signed, untrusted certificate is therefore enough to reach the vulnerable code. The server must be built with the built-in TLS stack and configured to parse a peer certificate (for example, mg_tls_opts.ca is set so that the server requests a client certificate).

The impact is a remote, unauthenticated denial of service. A single TLS handshake carrying the crafted certificate crashes the process with a SIGSEGV. This was reproduced both with AddressSanitizer and with a plain, non-instrumented build, where the process exits with code 139.

Solution

Upgrade to Mangoose version 7.24 or later.

Disclosure Timeline

September 15, 2026 : Tenable submitted the report to Mongoose via GitHub Security Advisory.
September 15, 2026 : Mongoose accepted the report
September 15, 2026 : The vendor shared the fix.
September 16, 2026 : Tenable verified the fix.
September 23, 2026: Tenable asking for update.
October 01, 2026: Tenable asking for update.
October 05, 2026: Mongoose indicated that the fix will be merged just before the release.
November 09, 2026: The fix has been merged in main
November 18, 2026: mongoose 7.24 was released
November 19, 2026: Tenable is asking when the advisory will be published.
November 20, 2026: The advisory was published

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]