Libuv: Improper Domain Lookup that potentially leads to SSRF attacks
The uv_getaddrinfo function truncates hostnames to 256 characters before calling getaddrinfo, which can cause a crafted hostname to be interpreted as a valid IP address. An attacker could exploit this to bypass developer checks and potentially perform SSRF attacks or access internal APIs.
- Triaged in 1 hour
- Fixed in 8 days
- Paid in 8 days
- Disclosed after 8 days
Summary by the program
Improper Domain Lookup that potentially leads to SSRF attacks
Summary The uv_getaddrinfo function in src/unix/getaddrinfo.c (and its windows counterpart src/win/getaddrinfo.c), truncates hostnames to 256 characters before calling getaddrinfo. This behavior can be exploited to create addresses like 0x00007f000001, which are considered valid by getaddrinfo and could allow an attacker to craft payloads that resolve to unintended IP addresses, bypassing developer checks.
Full GHSA: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
The report
I recently encountered a challenge in a CTF competition that led me to discover a vulnerability within Node.js, present in all versions after v10. Upon further investigation and code debugging, it became apparent that the vulnerability originated from its direct dependency, libuv.
I submitted a report to the Node.js team via HackerOne, and they subsequently connected me with the libuv team. This collaboration resulted in the identification and resolution of the vulnerability, now recorded as CVE-2024-24806.
Impact
This vulnerability could allow an attacker to craft payloads that results in SSRF attacks and Internal API Access. Full explanation of vulnerability, PoC and sample scenarios are provided within the original report: https://github.com/libuv/libuv/security/advisories/GHSA-f74f-cvh7-c6q6
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, the hostname is truncated to 256 characters before being passed to getaddrinfo, which can turn a long hostname into a string that getaddrinfo interprets as a numeric IP address.
Impact
This could allow an attacker to craft payloads that result in SSRF attacks and internal API access.
What the attacker needed
Attacker can control hostname input
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 looks up a domain name, it sometimes cuts off long names to a fixed length. If an attacker sends a very long name, the cut-off version might look like a number that the system treats as an IP address, so the program connects to an unintended server. This could let an attacker make the program access internal services.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.