Skip to content
Memory corruption Disclosed report Advanced

Heap buffer overflow in Curl_ipv4_resolve_r due to incorrect buffer alignment and size calculation on AmigaOS

The AmigaOS-specific DNS resolution function in curl uses a fixed-size heap buffer and miscalculates the data offset and size, ignoring structure alignment and padding. An attacker who can influence DNS responses or cause resolution of attacker-controlled hostnames may trigger heap memory corruption, leading to a crash or possible code execution.

badrodin22 Follow

Originally disclosed on HackerOne

  • Disclosed after 8 hours

Summary:

A heap-based buffer overflow exists in the AmigaOS-specific DNS resolution function Curl_ipv4_resolve_r located in lib/amigaos.c.

The function uses gethostbyname_r() with a fixed-size heap buffer (CURL_HOSTENT_SIZE) and performs incorrect pointer arithmetic when calculating the data buffer offset and size. This fails to account for structure alignment and padding requirements, which can result in the resolver writing past the allocated heap buffer.

The issue is specific to AmigaOS builds using the bsdsocket.library backend.

Impact

Impact Summary:

An attacker who can influence DNS responses or cause resolution of attacker- controlled hostnames may trigger heap memory corruption in curl or libcurl processes on AmigaOS.

Potential impacts include:

  • Process crash (denial of service)
  • Heap memory corruption
  • Possible code execution depending on heap layout and mitigations

The impact is limited to AmigaOS platforms.

The original report as published on HackerOne, by badrodin22. 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 the code calculates the data buffer offset and size without accounting for structure alignment and padding requirements, so the resolver can write beyond the allocated heap buffer.

Impact

An attacker who can influence DNS responses or cause resolution of attacker-controlled hostnames may trigger heap memory corruption, causing a crash or possibly code execution, though only on AmigaOS platforms.

What the attacker needed

Curl built for AmigaOS with bsdsocket.library; attacker can influence DNS responses

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 hostname, it asks a DNS server and stores the answer in a memory buffer. This code reserved a fixed amount of memory but worked out where to put the answer incorrectly, so the answer could be written past the end of the buffer. Writing past a buffer can crash the program or, in the worst case, let an attacker run their own code.

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 from curl

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.