Proposal: Removal of CURLPROTO_GOPHER from default redir_protocols
Date: Thu, 4 Jul 2019 17:33:54 +0300
As stated in the subject, I suggest that gopher:// gets removed from the
default list ofallowedprotocolsforredirects.
For context, Gopher is a legacy protocol from the early days of WWW that
sees very little usage these days.
In case of vulnerabilities such as Server-Side Request Forgery - SSRF,
where the backend of a webserviceisforcedtomakerequestto
arbitrary hosts (usually internal services) when user-provided URLs are
passed to libcurl-based clients, gopher://greatlybroadenstheattack
surface because of its generic nature. It simply opens a TCP connection
and sends a payload that is fully contained in the gopher URI.
For more information about these issues, please refer to .
An example ofwhatanadversarycandowithgopher://
is drop all keys in a Redis instance running on localhost.
SMB and file are excluded because an adversary could overwrite files on
the filesystem or leak their contents if the adversary are able to read
On the other hand,CURPROTO_GOPHERisincludedintheredir_protocolsbydefault.
As briefly described above, it is trivial to encode text-based protocols
(e.g. Redis protocol, SMTP) oraccess MySQL services through gopher://.
An adversary can even bypass the "safety" of REST APIs by forging
POST/PUT/PATCH/DELETE HTTP requests and smugglethemingopher:// URIs.
ofhttps://curl.haxx.se/libcurl/security.html, inthe meantimeI think a
slight improvement would be to also provide a
link to this section
that, in practice people tend to
use CURLOPT_FOLLOWLOCATION to save time and some code, rather than
implement their own redirect logic (which wouldn't necessarily be more
In addition, higher level bindings may not expose all functionality
needed to manipulateCURLOPT_REDIR_PROTOCOLS/CURLOPT_PROTOCOLS.
See for instance curb, a popular set oflibcurl bindings for Ruby.
Although this is not curl's issue per se and it should be fixed in curb
removing Gopher from the default list, can greatly help minimize the
exploitation surface there and in other occurrences of this issue.
Overall, the tradeoff between the inconvenience caused by removing
it's seeing very little usage nowadays) versus the importance it holds
for exploitation is in my eyesin favor of the latter.
Therefore, I would propose to remove CURLPROTO_GOPHERfrom the default
value of CURLOPT_REDIR_PROTOCOLS in the same vein as file:// and smb://,
can greatly assist adversaries in exploitation, and in thiscase,
I would be happy to preparea pull request if we agree on this.
P.S: The same holds for other protocols such as CURLPROTO_DICT
-- :https://www.acunetix.com/blog/articles/server-side-request-forgery-vulnerability/ :https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Request%20Forgery#gopher
Received on 2019-07-04