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 Mongoose version 7.24 or later.
Additional References
https://github.com/cesanta/mongoosehttps://github.com/cesanta/mongoose/security/advisories/GHSA-7p7r-23fj-q9rf
Disclosure Timeline
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]
Tenable One
Request a demo
The world’s leading AI-powered exposure management platform.
Thank You
Thank you for your interest in Tenable One.
A representative will be in touch soon.
Form ID: 7469
Form Name: one-eval
Form Class: c-form form-panel__global-form c-form--mkto js-mkto-no-css js-form-hanging-label c-form--hide-comments
Form Wrapper ID: one-eval-form-wrapper
Confirmation Class: one-eval-confirmform-modal
Simulate Success