Skip to main content

SSRF Notes


SSRF Notes

NOTE :  Wanted to have everything at one place,  these are my reference notes from various bug bounty write ups & security research, I thank all the authors of the write ups mentioned below [will update if i find anything interesting]



Description


In an SSRF attack against the server itself, the attacker induces the  application to make an HTTP request back to the server that is hosting  the application, via its loopback network interface. This will typically  involve supplying a URL with a hostname like 127.0.0.1 (a reserved IP address that points to the loopback adapter) or localhost (a commonly used name for the same adapter).         

Many server-side request forgery vulnerabilities are relatively easy to  spot, because the application's normal traffic involves request  parameters containing full URLs

Blind SSRF


Blind SSRF vulnerabilities arise when an application can be induced to  issue a back-end HTTP request to a supplied URL, but the response from  the back-end request is not returned in the application's front-end  response.         


IP Filter bypass [IP to Integer]: 



Private IP Space



Practice



Breaches


Capital One Breach : https://ejj.io/blog/capital-one


Payloads




SSRF Write Ups














Ways to find SSRF :




CapitalOne Breach Preview : https://application.security/ - Awesome



Prevention


There is no universal protection against SSRF attacks, however there are a few things to have in mind:

  • A blacklist is not a good protection because with so many different protocols, schemes, encodings and super complex URI syntax, bypasses will most certainly occur. Because of this, a whitelist is a better approach.
  • When developing REST API’s, it is better to accept other HTTP verbs than POST and GET which will make it harder for a SSRF vulnerability to make correct requests to the API service. If a SSRF vulnerability is only able to make internal GET requests it won’t be able to speak with the API. It is also important to validate both the request and response to internal services.
  • Services such as Kibana, Redis, Elasticsearch, MongoDB and Memcached do not per default require authentication, and adding that to those services may make it harder to exploit a SSRF vulnerability.  

Testing Methodlogies 


When testing for SSRF using a black list, take internal IP addresses and when encoding them, dont encode entire IP. Encode 1 octet of the IP address, or 2 or 3. For Instance: AWS Metadata - 0251.254.169.254 

Found an API endpoint used for uploading, change the upload file param to URL and test for SSRF. Many times it can lead you to full blown SSRF.

Got an SSRF? But app prevents trying to connect to localhost https://bbt.com/redirect.php? DNS Pinning for the win, create, set subdomain, point it to 127.0.0.1>use remote red>
<?php
header("Location: https://localhost.bbt.com");
die();
?>



 If you have an SSRF with file system access on an ECS instance then try extracting /proc/self/environ to get UUID and then try hitting ECS metadata 
curl http://169.254.170.2/v2/credentials/<UUID>
This way you'll extract IAM keys of the attached role


SSRF advice: 

- Test every parameter and input fetching external resources
- Once it hit's your server plan your attack
- Blind SSRF Try XSPA
- SSRF Try fetching the secret access keys


Sometimes you got to keep it simple in #bugbounty. Just got an #SSRF, steps (credits below):

1 Run getallurls for all assets & merge results
2 `cat results | grep "url="| anti-burl | tee ssrf.txt`
3 Review & cleanup list 
4 Fuzz all "url-like" params w/ Burp collab & #ffuf


Comments

Popular posts from this blog

Electron JS Security Checklist

Electron Js Security Checklist Disable nodeIntegration for untrusted origins/Do-not Enable Node-Integration Risk  If enabled, nodeIntegration allows JavaScript to leverage Node.js primitives and modules. This could lead to full remote system compromise if you are rendering untrusted content. Auditing nodeIntegration and nodeIntegrationInWorker are boolean options that can be used to determine whether node integration is enabled.  Auditing For BrowserWindow, default is true. If the option is not present, or is set to true/1, nodeIntegration is enabled as in the following examples:  mainWindow = new BrowserWindow({ "webPreferences": { "nodeIntegration": true, “nodeIntegrationInWorker": 1 } });  Or simply:  mainWindow = new BrowserWindow() For webview tag, default is false.  When this attribute is present, the guest page in webview will have node integration: When sanbox is enabled (see below), nodeintegration is disabled. Please note ...

WordPress Common Issue Notes

  WordPress: /wp-content/plugins/sfwd-lms/wpml-config.xml /wp-content/plugins/omni-secure-files/plupload/examples/upload.php /wp-content/plugins/contus-hd-flv-player/uploadVideo.php wp-json/th/v1/user_generation /wp-admin/admin-ajax.php?do_reset_wordpress=1 Wordpress xmlrpc.php -common vulnerabilites & how to exploit them https://medium.com/@the.bilal.rizwan/wordpress-xmlrpc-php-common-vulnerabilites-how-to-exploit-them-d8d3c8600b32
Cross Site Request Forgery   Cross site Request forgery leverages trust a website has in the user(or at least the user’s browser) CSRF takes advantage of active session a browser has with the target site: The attack is possible due to predictable parameters on the sensitive transactions An example money transaction user case might have two predictable parameters : Dest account & and Amount CSRF is similar to XSS , but it doesn’t require that the attacker inject code into a web application. CSRF simply leverages the fact that web servers trust the authenticated users, and is possible to pass un-authorized commands from client to there sever without users knowledge.These commands are then executed on server with clients authenticated privileges. Walkthrough   —————— Attacker determines a link to initiate a transaction that uses predictable parameters Attacker posts the link on a site he controls : The site could even be a Facebook page or similar   Or attacker to force ...