Skip to content
Memory corruption Disclosed report Intermediate

Binary output bypass

curl's binary-output detection can be bypassed when a response is padded with enough characters before a null byte, so curl writes binary data to the terminal. An attacker-controlled server could use this to corrupt or confuse the user's terminal session.

eliasknudsen Follow

Originally disclosed on HackerOne

  • Disclosed after 35 days

Binary output check bypass

Summary:

When curl outputs content, it checks for binary output. If the output is large enough, it bypasses the check for binary output. This can mess with the terminal.

Steps To Reproduce:

  1. Setup a server of your choice.
  2. Create a function f with these arguments: char and num. Num is number of characters repeating.
  3. Before serving at a given endpoint, create an offset f(".", 16384)
  4. Create the payload with unicode 0x0 like this f("unicode 0x0", 1)
  5. Make the server serve this at a given endpoint.
  6. Run this command: curl "Accept: application/xml" -H "Content-Type: application/xml" http://localhost:8080/yourendpoint
  7. Change the offset f(".", 16384) to f(".", 16383) to check if it worked.

curlpayload.png is the code execution.png is output for when it worked failed.png is when it failed, when I changed the offset to 16383

Impact

There could be some further impact by this exploit. As of now it can make the terminal really buggy at times, but further implementations could lead to something else.

Attachments

curlpayload.png
curlpayload.png From the original on HackerOne
execution.png
execution.png
failed.png
failed.png

The original report as published on HackerOne, by eliasknudsen. 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 binary-output check only inspects a limited leading portion of the response, so padding pushes the binary content past the inspected window.

Impact

The terminal can become buggy or corrupted, and the author suggests further impact may be possible.

What the attacker needed

Victim runs curl against attacker server

How it was found

  1. Set up a server that serves a chosen endpoint.
  2. Define a helper that repeats a character a given number of times.
  3. Before serving, pad the response with a large offset of harmless characters.
  4. Append a single null byte to form the payload.
  5. Serve that response at the endpoint.
  6. Request the endpoint with curl and compare behaviour when the offset is reduced by one.

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.

curl is a command-line tool for fetching web content. It normally tries to avoid printing raw binary data to your terminal, because that can garble the display. This report shows that padding the response with many harmless characters before a special null byte tricks curl into printing the binary anyway, which can leave the terminal in a broken state.

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.