Skip to content
Crypto Write-up Advanced

From a Silent Math Error to Certificate Bypass: Uncovering an Integer Overflow in a TLS Parser

An integer overflow in a TLS library's ASN.1 DER parser allowed a crafted variable-length quantity to be silently truncated to a small value. An attacker could use this to spoof object identifiers and potentially bypass certificate validation.

HackerMD Follow

Published on medium.com

Bug hunting isn’t always about popping XSS alerts or finding chained SSRFs. Sometimes, the most critical vulnerabilities are hidden deep within the foundational cryptographic parsing logic of an application.

Hacker MD, on medium.com

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

The variable-length integer decoder shifted bits left without checking whether the 64-bit result would overflow.

Impact

An attacker could craft a rogue certificate whose truncated OID matches a trusted standard OID, potentially bypassing certificate validation and enabling certificate spoofing and man-in-the-middle attacks.

What the attacker needed

Ability to supply a crafted certificate; target uses the vulnerable library

The fix

The parser should check for overflow before shifting and throw an exception on malicious input; the text proposes this patch but does not state that it was applied.

How it was found

  1. Build a local test harness linked to the library's source files.
  2. Craft a byte array with an extended tag marker followed by an 11-byte variable-length quantity and a dummy length byte.
  3. Run the parser against the payload and observe the resulting tag value.

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.

A library that checks TLS certificates reads numbers using a variable-length encoding. The code that decodes these numbers did not check for overflow, so a very long number could wrap around to a small value. This could let an attacker make a malicious certificate look like it uses a trusted identifier.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by HackerMD

View all

7 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.