Exploiting an SSRF Vulnerability to Retrieve the Server Hostname-
The application had an SSRF vulnerability in a URL parameter that allowed fetching local files. An attacker could read sensitive system files such as /etc/passwd and /etc/hostname, retrieving the server's hostname.
Published on medium.com
Server-Side Request Forgery (SSRF) is a common and dangerous web vulnerability that allows an attacker to make the server perform unintended requests. These requests can often access internal services, local files, or protected resources that are not normally exposed to external users.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application passed user-supplied input directly to a file-fetching function without validating or restricting the protocol and path, allowing local file access.
Impact
An attacker could read local files on the server, including sensitive system files, and retrieve the server's hostname.
What the attacker needed
Access to the web application; ability to intercept and modify requests
The fix
The application should validate and restrict user-supplied URLs, for example by using an allowlist of permitted domains and protocols, and disallow file:// and path traversal.
How it was found
- Open the application and inspect network requests in the browser's Developer Tools.
- Notice requests to /fetch.php with a url parameter fetching images.
- Intercept one such request in Burp Suite and send it to Repeater.
- Modify the url parameter to attempt reading /etc/passwd and observe the file contents returned.
- Try reading /etc/hosts and note the entries, but they are not the correct hostname.
- Modify the url parameter to file:///etc/hostname and retrieve the server's hostname.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The web app had a feature that fetched images from a web address you provide. Because it did not check what address you gave, you could ask it to read files on its own computer instead of fetching an image. This let an attacker see private files like the list of users or the machine's name.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.