Protocol Smuggling / CRLF Injection via Gopher Protocol allows Arbitrary Command Injection
The Gopher protocol handler in curl does not sanitise newline characters in the selector path, so a crafted gopher URL can carry encoded carriage-return and line-feed bytes that reach the target server as raw line breaks. An attacker could use this to send extra commands to internal text-based services such as Redis, Memcached or SMTP.
Originally disclosed on HackerOne
- Disclosed after 45 hours
Summary: I have discovered that the Gopher protocol implementation in curl fails to properly sanitize newline characters (%0d%0) in the selector path. This allows an attacker to inject arbitrary TCP commands when curl connects to a target server via gopher://. This vulnerability enables Protocol Smuggling attacks, turning a curl request into a weapon to interact with internal services like Redis, Memcached, or SMTP.
Affected version: Master branch (Compiled from source on Dec 24, 2025).
Steps To Reproduce:
-
Setup a dummy listener (simulating a victim service like Redis or SMTP): $ nc -lvnp 11211
-
Execute the attack using a crafted Gopher URL containing URL-encoded CRLF characters: $ ./src/curl "gopher://127.0.0.1:11211/_Dummy%0d%0aHELLO_SERVER%0d%0"
-
Observe the output on the listener side. Instead of receiving a single line (safe behavior), the server receives three distinct lines (vulnerable behavior):
[Listener Output] Dummy HELLO_SERVER QUIT
This confirms that the %0d%0 sequence was decoded and transmitted as raw bytes, breaking the protocol structure.
Impact
This vulnerability allows Protocol Smuggling. By exploiting this CRLF injection, an attacker can:
- Interact with internal text-based protocols (Redis, Memcached, SMTP) that assume commands are separated by newlines.
- Achieve Remote Code Execution (RCE) on internal networks by injecting Redis commands (e.g., writing a webshell via 'CONFIG SET' / 'SAVE' or overwriting 'authorized_keys').
- Perform SMTP Injection to send forged emails from trusted internal IPs.
- Bypass SSRF protections that rely on protocol allow-listing, as Gopher is often allowed but can simulate other protocols.
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 Gopher handler decodes percent-encoded bytes in the selector and forwards them without rejecting or stripping carriage-return and line-feed characters, so they act as command separators on the target.
Impact
An attacker could smuggle extra commands into internal services, potentially leading to remote code execution on internal networks, forged email, or bypass of SSRF protections that allow-list Gopher; the report demonstrates only the line-splitting behaviour, not the follow-on attacks.
What the attacker needed
Attacker can make curl fetch a gopher URL; target is a line-based internal service
How it was found
- Start a simple listener to stand in for an internal text-based service.
- Run curl against that listener using a gopher URL whose selector contains encoded line breaks.
- Watch the listener output and note that several separate lines arrive instead of one.
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.
Many internet services read commands line by line, treating each new line as a separate instruction. curl can talk to such services through a scheme called Gopher, and the report says it passes along hidden line-break characters instead of blocking them. That means one request could secretly contain several commands, letting someone make an internal service do things the sender was never meant to ask for.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.