Skip to content
DoS Disclosed report Intermediate CVE-2019-5482CVE-2019-5436

CVE-2019-5482: Heap buffer overflow in TFTP when using small blksize

When a TFTP server ignores a requested block size and sends data using the default 512-byte blocks without an OACK, curl incorrectly treats the transfer as complete after the first block. This results in a truncated file being saved with no error code returned to the user.

thomas_v Follow

Originally disclosed on HackerOne

Medium 5.2 View original
  • Triaged in 4 days
  • Fixed in 13 days
  • Paid in 7 days
  • Disclosed after 15 months

Summary:

With a TFTP server that does not send OACK, but instead starts anyway with first block with 512 bytes block size, the curl library fails to assume default 512 bytes blocks. Instead it detects EOF and does not return an error code. Consequence is a truncated file that is 512 bytes without any error code.

My understanding is that from the RFC, a TFTP server might ignore blksize request and anyway send the default 512 bytes block size data.

Unless an OACK is received we should assume 512 block size, whether or not a particular blocksize was requested.

This was introduced by security fix of CVE-2019-5436: 257600341 tftp: use the current blksize for recvfrom()

Potential Fix

We could revert 2576003415625d7b5f0e390902f8097830b82275 and instead malloc the receive buffer for at least 512 bytes, or for the requested blksize if it is bigger. That would address the issue being reported and also the CVE-2019-5436.

Steps To Reproduce:

  1. Use a TFTP server that does not send OACK in response of a particular blksize request, but instead sends directly the first block, of default size (512B).
  2. Run curl asking for a >512 bytes block size like: curl --tftp-blksize 8192 tftp://9.1.9.1/data.bin --output data.bin
  3. echo $? is 0 and file size is 512 bytes

Comment

Not too sure about the Weakness identification and/or Severity, reporting it here since it was introduced by a CVE fix.

Impact

File truncation without 'curl' returning any error code.

The original report as published on HackerOne, by thomas_v. 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 assumed that if a non-default block size was requested, the server would either acknowledge it or use that size, so it failed to fall back to the default 512-byte block size when no acknowledgement was received.

Impact

The downloaded file is silently truncated to 512 bytes, and curl returns a success exit code, so the user may not notice the incomplete transfer.

What the attacker needed

A TFTP server that ignores block size requests; curl built with TFTP support; user requests a block size larger than 512 bytes

The fix

The code should be changed to allocate the receive buffer for at least 512 bytes, or for the requested block size if it is larger, so that the default block size is handled correctly when no OACK is received.

How it was found

  1. Set up a TFTP server that ignores block size requests and sends data using the default 512-byte blocks without sending an OACK.
  2. Run curl with a requested block size larger than 512 bytes, pointing to a file on that server.
  3. Observe that curl exits with status 0 and the downloaded file is only 512 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.

TFTP is a simple file transfer protocol. A client can ask the server to use larger blocks of data, but the server may ignore that and use the default 512-byte blocks. In this bug, curl did not handle that situation correctly: it stopped after the first block and saved only part of the file, without telling the user that something went wrong.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by thomas_v

View all

3 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.