SSRF
Table of Contents
- Basic SSRF against the local server
- Basic SSRF against another back-end system
- SSRF with blacklist-based input filter
- SSRF with filter bypass via open redirection vulnerability
- Blind SSRF with out-of-band detection
Basic SSRF against the local server
Reference: https://portswigger.net/web-security/ssrf/lab-basic-ssrf-against-localhost
Solution
- Browse to
/adminand observe that you can't directly access the admin page. - Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
- Change the URL in the
stockApiparameter tohttp://localhost/admin. This should display the administration interface. - Read the HTML to identify the URL to delete the target user, which is:
http://localhost/admin/delete?username=carlos
- Submit this URL in the
stockApiparameter, to deliver the SSRF attack.
Basic SSRF against another back-end system
Reference: https://portswigger.net/web-security/ssrf/lab-basic-ssrf-against-backend-system
Solution
- Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Intruder.
- Click "Clear §", change the
stockApiparameter tohttp://192.168.0.1:8080/adminthen highlight the final octet of the IP address (the number 1), click "Add §". - Switch to the Payloads tab, change the payload type to Numbers, and enter 1, 255, and 1 in the "From" and "To" and "Step" boxes respectively.
- Click "Start attack".
- Click on the "Status" column to sort it by status code ascending. You should see a single entry with a status of 200, showing an admin interface.
- Click on this request, send it to Burp Repeater, and change the path in the
stockApito:/admin/delete?username=carlos
SSRF with blacklist-based input filter
Reference: https://portswigger.net/web-security/ssrf/lab-ssrf-with-blacklist-filter
Solution
- Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
- Change the URL in the
stockApiparameter tohttp://127.0.0.1/and observe that the request is blocked. - Bypass the block by changing the URL to:
http://127.1/ - Change the URL to
http://127.1/adminand observe that the URL is blocked again. - Obfuscate the "a" by double-URL encoding it to
%2561to access the admin interface and delete the target user.
SSRF with filter bypass via open redirection vulnerability
Reference: https://portswigger.net/web-security/ssrf/lab-ssrf-filter-bypass-via-open-redirection
Solution
- Visit a product, click "Check stock", intercept the request in Burp Suite, and send it to Burp Repeater.
- Try tampering with the
stockApiparameter and observe that it isn't possible to make the server issue the request directly to a different host. - Click "next product" and observe that the
pathparameter is placed into the Location header of a redirection response, resulting in an open redirection. - Create a URL that exploits the open redirection vulnerability, and redirects to the admin interface, and feed this into the
stockApiparameter on the stock checker:
/product/nextProduct?path=http://192.168.0.12:8080/admin
- Observe that the stock checker follows the redirection and shows you the admin page.
- Amend the path to delete the target user:
/product/nextProduct?path=http://192.168.0.12:8080/admin/delete?username=carlos
Blind SSRF with out-of-band detection
Reference: https://portswigger.net/web-security/ssrf/blind/lab-out-of-band-detection
Solution
- In Burp Suite Professional, go to the Burp menu and launch the Burp Collaborator client.
- Click "Copy to clipboard" to copy a unique Burp Collaborator payload to your clipboard. Leave the Burp Collaborator client window open.
- Visit a product, intercept the request in Burp Suite, and send it to Burp Repeater.
- Change the Referer header to use the generated Burp Collaborator domain in place of the original domain. Send the request.
- Go back to the Burp Collaborator client window, and click "Poll now". If you don't see any interactions listed, wait a few seconds and try again, since the server-side command is executed asynchronously.
- You should see some DNS and HTTP interactions that were initiated by the application as the result of your payload.