Vulnerability Report: Local File Disclosure via file:// Protocol in cURL
The report claims that cURL's file:// protocol handler allows reading local files without validation, and that running cURL with sudo can expose sensitive files such as /etc/shadow. The author suggests this could lead to data exposure and privilege escalation.
- Disclosed after 1 hour
Summary A security vulnerability has been identified that allows unauthorized local file system access via the file:// protocol in cURL, particularly when executed with elevated privileges (e.g., sudo). This could lead to sensitive data exposure, including password hashes stored in /etc/shadow.
Steps to Reproduce Locating Protocol Handlers First, I searched for protocol registration in cURL's source: // Found in lib/url.c static const struct Curl_handler * const protocols[] = { &Curl_handler_dict, &Curl_handler_file, // ← This is what we're interested in &Curl_handler_ftp, ... }; Key Insight: The file handler is enabled by default in the protocols array.
Examining the File Protocol Handler I traced the file handler implementation:
// lib/file.c static CURLcode file_do(struct Curl_easy *data, bool *done) { char *path = data->state.up.path; // ← Raw path from URL FILE *file = fopen(path, "rb"); // ← Direct filesystem access ... } Vulnerability Found: No validation of:
Path traversal sequences (../) Symbolic links Filesystem permissions
- Basic Local File Read
curl "file:///etc/passwd" # Reads system user info 2. Privileged File Access (with sudo)
sudo curl "file:///etc/shadow" # Exposes password hashes
echo "test" > /tmp/test_file curl "file:///tmp/test_file" sudo curl "file:///etc/shadow" # Expected Output: root:*: kali:$ [...]
References cURL Security Documentation - Official security considerations for cURL CURLOPT_PROTOCOLS man page - Protocol restriction options
Impact
Confidentiality Breach: Read access to sensitive system files Privilege Escalation: Potential root access via hash cracking Business Impact: Critical for systems processing sensitive data Often missed in containerized environments
Attachments


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 performs no validation of the path, but this is intended behaviour for a file transfer tool rather than a vulnerability.
Impact
The report claims confidentiality breach and potential privilege escalation via hash cracking, but this depends on running cURL with elevated privileges.
What the attacker needed
Ability to run cURL with sudo
How it was found
- Search the cURL source for the protocols array and note that the file handler is enabled by default.
- Examine the file handler implementation and see that it opens the path directly with fopen.
- Run cURL with a file:// URL to read a local file.
- Run cURL with sudo and a file:// URL to read a protected file such as /etc/shadow.
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 can read local files via file://. The report says running it with sudo can read protected files like /etc/shadow, which stores password hashes.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.