curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Proposal: Removal of CURLPROTO_GOPHER from default redir_protocols

From: Linos Giannopoulos via curl-library <>
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 [1][2].

An example ofwhatanadversarycandowithgopher://
What this
is drop all keys in a Redis instance running on localhost.

protocolsexceptSMB, fileandtheirTLScounterparts.
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
the response.
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.

of, inthe meantimeI think a
slight improvement would be to also provide a
link to this section
under Despite
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
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://,
as it
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



Received on 2019-07-04