Skip to content
Memory corruption Write-up Advanced

CVE−2022-3602: Punycode buffer overflow in OpenSSL

An off-by-one error in OpenSSL's punycode decoding allows a 4-byte buffer overflow when processing a malicious certificate chain. An attacker could potentially alter control flow, but exploitation is limited by compiler protections and the need for a trusted CA.

Colm MacCárthaigh Follow

Published on github.com

BranchesTags

Colm MacCárthaigh (@colmmacc), on github.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

Likely an off-by-one error in the length check within `ossl_punycode_decode`, allowing one more element to be written than the buffer size.

Impact

The overflow is only 4 bytes and often lands in padding, so remote code execution is unlikely; however, it could crash the application or potentially alter control flow if other protections are absent.

What the attacker needed

A trusted CA or intermediate certificate; the CA must sign the leaf certificate; the CA certificate must contain a name constraint with…; the leaf certificate must contain a SmtpUTF8Mailbox…

The fix

The issue was fixed in OpenSSL 3.0.7; users should update.

How it was found

  1. Generate a malicious CA certificate with a name constraint containing a punycode payload.
  2. Generate a leaf certificate with a SubjectAltName otherName field containing a SmtpUTF8Mailbox string.
  3. Run the provided script to start an OpenSSL client and server and attempt the exploit.
  4. Observe that a vulnerable OpenSSL likely crashes.

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.

OpenSSL is a widely used library for secure connections. A bug in how it reads certain encoded domain names (punycode) could let an attacker write four extra bytes of data onto the stack, a small memory area. This might crash the program or, in rare cases, let an attacker redirect execution, but most systems have protections that make this hard.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.