Mongoose - Improper Validation of Array Index in X.509 Certificate Validity Date Parsing

High

Synopsis

Note: This vulnerability was independently discovered by Tenable Research and other researchers.

Note: The CVSS vector differs from our own assessment (C:H/I:N/A:H). We score the 64-bit crash as an availability impact, which the vendor advisory does not.

In Mongoose, the built-in TLS stack (MG_TLS=1) parses the validity timestamps of a peer's X.509 certificate with asnt2t(), which hands the result to mg_timegm() without validating the month field. A remote, unauthenticated peer can trigger an out-of-bounds read during the TLS handshake.

The upstream DER checks only look at the ASN.1 type tag (0x17 or 0x18 and the length (13 or 15 bytes), never at the content. asnt2t() then reads the digits straight from the certificate bytes. A timestamp such as 20250015120000Z, which has a month value of 0, therefore reaches mg_timegm() unchecked.

The mg_timegm() function in src/util.c uses the dm[12] table of cumulative day counts per month and indexes it with month - 1. With a month of 0, the unsigned arithmetic wraps and produces the index 4294967295, which is far outside the bounds of the array.

The consequences depend on the architecture. On 32-bit embedded targets, the read lands at a predictable offset from the dm array, which leaks memory contents. The returned value feeds into the certificate validity check (accept or reject), so an attacker can use different month values as an oracle to infer what is in memory at those addresses. On 64-bit systems, the read crashes the process, which results in a denial of service.

Solution

Upgrade to Mongoose version 7.24 or later.

Disclosure Timeline

September 15, 2026 : Tenable submitted the report to Mongoose via GitHub Security Advisory.
September 15, 2026 : Closed as duplicate

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]