Skip to content
Memory corruption Disclosed report Advanced CVE-2024-6197

libcurl: freeing stack buffer during x509 certificate parsing

libcurl's ASN.1 UTF-8 string parser calls free() on a four-byte stack buffer when it detects an invalid field. A malicious TLS server can trigger this, likely causing a crash and potentially overwriting nearby stack memory.

z2_ Follow

Originally disclosed on HackerOne

  • Triaged in 31 hours
  • Fixed in 30 days
  • Paid in 30 days
  • Disclosed after 31 days

Summary by the program

libcurl's ASN1 parser has this utf8asn1str() function used for parsing an ASN.1 UTF-8 string. It can detect an invalid field and return error. Unfortunately, when doing so it also invokes free() on a 4 byte local stack buffer.

Most modern malloc implementations detect this error and immediately abort. Some however accept the input pointer and add that memory to its list of available chunks. This leads to the overwriting of nearby stack memory. The content of the overwrite is decided by the free() implementation; likely to be memory pointers and a set of flags.

The most likely outcome of exploiting this flaw is a crash, although it cannot be ruled out that more serious results can be had in special circumstances.

Full advisory: https://curl.se/docs/CVE-2024-6197.html

The report

Hello, I would like to report a vulnerability here, initially reported by me to the curl project.

HackerOne Report: https://hackerone.com/reports/2559516 CVE: CVE-2024-6197 Advisory: https://curl.se/docs/CVE-2024-6197.html Severity: Medium

Impact

By serving a specifically crafted TLS certificate, a malicious server can trigger a free() of a buffer located on the stack. This can lead to a crash or to further memory corruptions.

The original report as published on HackerOne, by z2_. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely an error path in utf8asn1str() frees a pointer to a local stack buffer instead of only returning an error.

Impact

A malicious server could cause a crash, and more serious memory corruption cannot be ruled out in special circumstances.

What the attacker needed

Malicious TLS server; client parses certificate

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 report has not been written yet. The Original tab links to the source.

When a program reads a certificate, it uses a small temporary space on the stack (a fast memory area) to hold text. If the text is malformed, the code mistakenly tells the system to release that temporary space as if it were heap memory. This can crash the program or, in rare cases, corrupt memory.

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.

More by z2_

View all

11 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

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.