curl: stack-buffer overread during punycode conversions
When converting a domain name to or from punycode using libcurl's URL API with the macidn backend, a name of exactly 256 bytes causes the conversion function to fill the buffer without null-terminating it, leading to an out-of-bounds read of stack memory. This can cause adjacent stack contents, potentially including pointer values, to be returned as part of the converted string.
- Triaged in 31 hours
- Fixed in 30 days
- Paid in 30 days
- Disclosed after 2 months
Summary by the program
libcurl's URL API function curl_url_get() offers punycode conversions, to and from IDN. Asking to convert a name that is exactly 256 bytes, libcurl ends up reading outside of a stack based buffer when built to use the macidn IDN backend. The conversion function then fills up the provided buffer exactly - but does not null terminate the string.
This flaw can lead to stack contents accidentally getting returned as part of the converted string.
Full advisory: https://curl.se/docs/CVE-2024-6874.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/2604391 CVE: CVE-2024-6874 Advisory: https://curl.se/docs/CVE-2024-6874.html Severity: Low
Impact
When converting the domain name of a URL from/to punycode with libcurl's URL API, libcurl reads past the bounds of a stack-buffer and includes adjacent stack-memory in the conversion result. This potentially leaks pointer values.
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
The macidn conversion function fills the provided buffer exactly but does not null-terminate the string, so subsequent string operations read past the buffer.
Impact
This could leak pointer values from adjacent stack memory as part of the converted string.
What the attacker needed
Libcurl built with macidn backend; use of curl_url_get() for punycode conversion; domain name exactly 256 bytes
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.
A buffer is a fixed-size area of memory used to hold text. When a name is exactly as long as the buffer, the code that fills it forgets to add the special zero byte that marks the end of a string. Later, when the program reads the string, it keeps going past the buffer and picks up whatever happens to be next in memory, which can be secret data like memory addresses.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.