Skip to content
Path traversal Disclosed report Beginner CVE-2021-22901

Path Traversal in curl file:// Protocol Handler Allows Unauthorized File Access

The curl file:// protocol handler does not validate directory traversal sequences, allowing access to files outside the intended directory. An attacker could read arbitrary files by supplying a crafted file:// URL with ../ sequences.

7hackerstar Follow

Originally disclosed on HackerOne

  • Disclosed after 16 hours

Summary

During my manual review of the file path handling logic in curl's source code, I noticed the absence of proper validation for directory traversal sequences, which I then verified through practical testing. I discovered that curl allows unauthorized access to arbitrary files through the file:// protocol handler when directory traversal sequences (../) are used.

Affected version

curl 8.13.0_8 (official Windows build) Platform: Windows 10 curl version output: curl 8.13.0 (x86_64-pc-win32) libcurl/8.13.0 OpenSSL/3.0.16 (Schannel) zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.7 libpsl/0.21.5 (+libidn2/2.3.7) libssh2/1.11.1 nghttp2/1.64.0 ngtcp2/1.12.0 nghttp3/1.8.0 Release-Date: 2025-04-02 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp ws wss Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM PSL SPNEGO SSL SSPI TLS-SRP UnixSockets zstd

Vulnerable Code Location

The vulnerability exists in lib/file.c at lines 229-262 where file paths are not properly validated before opening:

C
/* Line 229: No validation of "../" sequences */
fd = curlx_open(actual_path, O_RDONLY | CURL_O_BINARY);

/* Similar issues at lines 253, 258, 262 */
fd = curlx_open(real_path + 1, O_RDONLY);  // Line 253
fd = curlx_open(real_path, O_RDONLY);     // Line 258
fd = curlx_open(real_path, O_RDONLY);     // Line 262

This code fails to check for directory traversal sequences before opening files. When I reviewed these lines, I noticed there's no validation to prevent paths containing `../` from accessing files outside the intended directory structure.

## Steps To Reproduce
1. Download the official curl Windows build from: https://curl.se/windows/dl-8.13.0_8/curl-8.13.0_8-win64-mingw.zip
2. Extract the archive and navigate to the `bin` directory
3. Create a test file at `C:\test\poc_test.txt` with content:
This is a test file for Path Traversal vulnerability
4. Execute the following command in the same directory as curl.exe:
```bash
curl "file://../../../../test/poc_test.txt"
During my testing, I observed the file contents displayed successfully, proving unauthorized access to files outside the intended directory.
Supporting Material/References
Screenshot showing successful file access (Capture.PNG) - captured during my actual testing on Windows 10
Proof of Concept script (final_poc.bat) demonstrating the vulnerability step by step
Test file used in reproduction (poc_test.txt) with the exact content I tested with
Reference to similar vulnerability: CVE-2021-22901 (shows this pattern has occurred before)

## Impact

This vulnerability allows attackers to read arbitrary files from the system when processing malicious file:// URLs. The impact includes:

Sensitive data exposure: System files (hosts, password databases), user documents, and private keys can be accessed. During my testing, I was able to read files from completely different directories, which shows how serious this is.
Information disclosure: System configuration, installed software details, and network settings can be enumerated. This could provide attackers with detailed information about the target system.
Chained attacks: Can be combined with other vulnerabilities for full system compromise. For example, reading configuration files might reveal credentials for other services.
Remote exploitation: Applications that process user-supplied URLs with curl (web scrapers, API clients, download managers) can be exploited remotely. Many developers don't realize that file:// URLs can be dangerous.
The severity is High because:

No authentication required for exploitation - any attacker can craft a malicious URL
Affects confidentiality of sensitive system data - the core security boundary is violated
Present in the latest official release - affects all Windows users of the current version
Simple to exploit with minimal technical skill - I was able to reproduce it with just a few simple commands
This isn't just a theoretical issue. In my hands-on testing on Windows 10, I successfully accessed files outside the intended directory structure, proving real-world exploitability. The vulnerability is particularly concerning because curl is used in countless applications and systems worldwide.

## Attachments

{{media:0}}

The original report as published on HackerOne, by 7hackerstar. 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 file:// handler passes user-supplied paths directly to file-open calls without checking for directory traversal sequences.

Impact

An attacker could read arbitrary files from the system when curl processes a malicious file:// URL, potentially exposing sensitive data and enabling chained attacks.

What the attacker needed

Curl processes a user-supplied file:// URL; attacker can influence the URL

How it was found

  1. Download the official curl Windows build.
  2. Extract the archive and go to the bin directory.
  3. Create a test file at C:\test\poc_test.txt with sample content.
  4. Run curl with a file:// URL containing ../ sequences.
  5. Observe that the file contents are displayed.

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.

A path traversal bug lets someone use '../' in a file path to climb out of the folder they are supposed to be in. Here, curl's file:// feature opens whatever path it is given without checking for those sequences, so a crafted URL can reach files elsewhere on the disk. The report claims this lets an attacker read files they should not see.

What is Path traversal?

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

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.