The Tale Of SSRF To RCE on .GOV Domain
A proxy endpoint on a .gov domain accepted a URL parameter and fetched it without proper filtering, allowing an attacker to access internal services, cloud metadata, and local files. By combining this with a Shellshock vulnerability on an internal host, the attacker achieved remote code execution.
Published on medium.com
Welcome back, I hope everyone is well. Without further hesitation let’s dive into it!
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.
Context
This is a write-up of a chain that started as a Server Side Request Forgery (SSRF) on a .GOV domain and ended in Remote Code Execution (RCE) against an internal host. The author describes SSRF as a high or critical vulnerability when it can be demonstrated with impact: if the server makes the requests, an attacker may be able to request and access internal pages.
The report does not name the government body, the application or the specific feature behind the vulnerable endpoint. What it does describe is an endpoint called /proxy, which returned a blank page when loaded directly. Inspecting the page source revealed a var parameter that could be added to the request and that was used for requesting a URL. That parameter is the feature under test: a server-side URL fetcher exposed to the outside.
The author notes that SSRF often requires bypasses such as IP address blacklists, URL encoding and DNS tampering, but in this case the exploitation was straightforward.
Setup
The report does not describe any accounts, roles or authentication. The tooling used was:
- Waybackurls and GAU for collecting historical and known URLs.
- gospider for crawling.
- Burp Suite, including Collaborator, Repeater and Intruder, for testing and scanning.
No versions are given.
Finding it
The recon flow was:
Waybackurls
GAU
waybackurls >> GAU >> combined.txt
gospider | tee gospider.txt
gospider.txt >> combined.txt
In other words, the output of waybackurls and GAU was combined into combined.txt, gospider was run and its output saved with tee to gospider.txt, and that file was appended to combined.txt. The author then manually looked through the combined file for interesting endpoints and came across /proxy.
Loading /proxy gave a blank page. Inspecting the source revealed a var parameter that could be added to the request; this parameter was used for requesting a URL. That hidden parameter is what made the endpoint interesting: a blank page with a URL-fetching parameter behind it is a classic SSRF candidate.
Exploitation
Step 1: Confirm the server makes the request
Adding the var parameter to the endpoint and pointing it at a Burp Collaborator link produced an HTTP request back from the server's IP. That confirms server-side request forgery: the application, not the browser, fetched the URL.
Step 2: Probe loopback and observe the filtering
Replacing the Collaborator link with https://[redacted] and sending the request produced no response. Changing the address to https://127.1 returned a 200 OK with the internal page rendered on screen. That page only showed a redirect URL, so the content was not very interesting, but the result demonstrated limited filtering on URLs: the full loopback address was blocked or failed, while the shortened form was accepted.
Step 3: Reach the cloud metadata service
Next the author requested the AWS internal IP with the metadata path:
[redacted]/metadata
The metadata was displayed. According to the author, this gave full access to AWS for the company, allowing keys and other information to be gathered.
Step 4: Read local files
The request was then changed to a file path:
file:///etc/passwd
That loaded as well. From there the author could request the host file to understand the internal IP ranges.
Step 5: Scan the internal network
The request was sent to Burp Repeater and used to scan across the internal address space for interesting pages on port 8080 or with the URL /admin.
Step 6: Shellshock against an internal host
The author had learned about Shellshock from a PortSwigger lab: an RCE vulnerability that can be exploited via the User-Agent header. The payload itself is not reproduced in the report; the author says that googling will show it. The payload was added to the Intruder request and the scan across the internal range was repeated. A ping back confirmed that an internal host was vulnerable. At that point the author had full internal access and Remote Code Execution internally, reached from the outside.
Root cause
The /proxy endpoint accepted a user-supplied URL through the var parameter and fetched it server-side without adequate restriction. The filtering that existed was weak: https://[redacted] did not return a response, but https://127.1 did, and the link-local metadata address and the file:// scheme were both accepted. Requests to loopback, the cloud metadata service and the local filesystem all succeeded, and the request could be pointed at internal hosts on other ports and paths. A ping back confirmed that an internal host was vulnerable to Shellshock, which turned the SSRF into code execution.
Impact
Under the conditions shown, an attacker who can reach /proxy could:
- Make the server issue requests to arbitrary destinations, confirmed with a Collaborator callback.
- Reach loopback through the shortened
127.1form and render internal pages. - Read AWS instance metadata at
[redacted]/metadata, which the author says gave full access to AWS for the company and allowed gathering keys and other information. - Read local files such as
/etc/passwdviafile://, and use the host file to map internal IP ranges. - Scan internal address space on port 8080 and for
/admin. - Achieve Remote Code Execution on an internal host vulnerable to Shellshock, giving full internal access from the outside.
Fix
Based on the behaviour shown, the fetcher should restrict the schemes it accepts (no file://), resolve and validate the destination host against an allowlist rather than a blocklist, reject loopback and link-local addresses including shortened forms such as 127.1, and block the cloud metadata address. Internal services should also not pass client-controlled headers such as User-Agent into a shell.
Variants to test
- Hidden URL parameters on blank pages. Crawl with waybackurls, GAU and gospider, then inspect the source of endpoints that render nothing. A positive result is a parameter that, when pointed at a Collaborator link, produces an inbound request from the server's IP.
- Loopback bypasses. Try
https://[redacted], thenhttps://127.1and other shortened or alternative representations. A positive result is a200 OKwith internal content rendered. - Cloud metadata. Request
[redacted]/metadatathrough the parameter. A positive result is metadata displayed in the response. - Local file read. Try
file:///etc/passwd. A positive result is the file contents in the response, and the host file can then be used to map internal ranges. - Internal scanning. Send the request to Repeater or Intruder and sweep internal addresses on port 8080 and paths such as
/admin. A positive result is any interesting internal page. - Shellshock via User-Agent. Add the Shellshock payload to the User-Agent in an Intruder request against internal hosts. A positive result is a callback confirming an internal host is vulnerable, which turns the SSRF into RCE.
What happened, in plain words
A security researcher was looking at a website belonging to a government organisation (the report calls it a .GOV domain, meaning the address ends in .gov). While poking around, he found a page that could be told to fetch any web address he liked, and the fetching was done by the website's own server rather than by his browser. That kind of flaw is called Server Side Request Forgery, or SSRF. Because the server sits inside the organisation's private network, being able to make it fetch things meant he could reach machines and files that outsiders normally cannot see. He used that access to reach the cloud metadata service, read a system file, scan the internal network, and finally run commands on an internal machine through an old bug called Shellshock. That last step is Remote Code Execution, or RCE: running your own commands on someone else's computer.
The report does not name the government body, the application or the specific feature behind the vulnerable page. It also does not state a bounty, a severity score or what was fixed afterwards.
Before we go further, a few words that will come up constantly:
- A server is the computer that holds a website and answers requests from visitors' browsers.
- A request is the message your browser sends to a server when you open a page or submit a form. It contains a method (such as GET, meaning "give me this"), a path (such as
/proxy), and often extra pieces of data called parameters. - A parameter is a named value attached to a request, like a label on a form field. In a URL it appears after a
?, for example?name=value. Parameters are how a website receives input from you. - An endpoint is a specific address on a server that does a specific job, such as
/proxy. - Loopback (also written
[redacted]orlocalhost) is the address a computer uses to talk to itself. It is not reachable from the internet, which is exactly why it is interesting to an attacker. - Cloud metadata is a small internal service that cloud providers such as Amazon Web Services (AWS) expose to their own machines. It hands out information about the machine, including temporary credentials. It lives at a fixed internal address,
[redacted], and is only meant to be reachable from inside the cloud. - Credentials are the keys or passwords that prove who you are. If an attacker gets cloud credentials, they can act as that organisation inside the cloud.
Context
This is a write-up of a chain: a series of steps where each one opens the door to the next. It started as an SSRF on a .GOV domain and ended in RCE against an internal host. The author describes SSRF as a high or critical vulnerability when it can be demonstrated with impact: if the server makes the requests, an attacker may be able to request and access internal pages.
Why is that serious? Normally your browser can only reach what the internet exposes. A server, however, sits behind the firewall, next to databases, admin panels and other internal machines. If you can make the server fetch a URL of your choosing, you are borrowing its position inside the network. It is a bit like being able to post a letter from inside a building you are not allowed to enter: you cannot walk the corridors, but you can ask the mail room to fetch things for you.
The report does not name the government body, the application or the specific feature behind the vulnerable endpoint. What it does describe is an endpoint called /proxy, which returned a blank page when loaded directly. Inspecting the page source revealed a var parameter that could be added to the request and that was used for requesting a URL. That parameter is the feature under test: a server-side URL fetcher exposed to the outside.
"Inspecting the page source" means using the browser's View Source or developer tools to read the raw HTML that the server sent. Developers sometimes leave hints there, such as a form field or a script that references a parameter the page itself does not visibly use. A blank page with a hidden URL-fetching parameter behind it is a classic SSRF candidate: the page looks empty, but the machinery behind it will go and fetch whatever address you give it.
The author notes that SSRF often requires bypasses such as IP address blacklists, URL encoding and DNS tampering, but in this case the exploitation was straightforward. To unpack that: a blacklist is a list of things a program refuses to accept. URL encoding is the way special characters are written in a URL, for example a space becomes %20; attackers sometimes encode characters to slip past filters. DNS is the system that turns names like example.com into numeric IP addresses, and DNS tampering means abusing that translation so a blocked name resolves to an allowed address. None of that was needed here.
Setup
The tooling used was:
- Waybackurls and GAU for collecting historical and known URLs.
- gospider for crawling.
- Burp Suite, including Collaborator, Repeater and Intruder, for testing and scanning.
No versions are given. Here is what each tool does, in plain terms:
- Waybackurls fetches lists of URLs that used to exist on a domain, from public web archives. Old pages are often forgotten and still live on the server.
- GAU (Get All URLs) does something similar, gathering URLs from several public sources.
- gospider is a crawler: it starts from a page and follows links automatically, like a very fast reader clicking everything.
- Burp Suite is a toolkit that sits between your browser and the website so you can see and edit every request. Collaborator gives you a unique address you can put in a request; if anything contacts that address, Burp tells you, which proves who made the request. Repeater lets you send the same request over and over with small edits. Intruder sends a request many times with different values in chosen positions, which is how you scan a range of addresses.
Finding it
The recon flow was:
Waybackurls
GAU
waybackurls >> GAU >> combined.txt
gospider | tee gospider.txt
gospider.txt >> combined.txt
Line by line:
WaybackurlsandGAUare named as the two sources of URLs. The blank lines are just spacing in the report.waybackurls >> GAU >> combined.txtdescribes the output of waybackurls and GAU being combined into a file calledcombined.txt. The>>symbol means "append to this file", so each tool's results are added to the same list rather than overwriting it.gospider | tee gospider.txtruns the crawler. The|symbol (a pipe) passes its output along, andteeboth shows it on screen and saves a copy togospider.txt.gospider.txt >> combined.txtappends the crawler's results to the same combined list.
The author then manually looked through the combined file for interesting endpoints and came across /proxy. The word "proxy" is a strong hint: a proxy is something that fetches things on your behalf, which is exactly the behaviour that can go wrong.
Loading /proxy gave a blank page. Inspecting the source revealed a var parameter that could be added to the request; this parameter was used for requesting a URL. That hidden parameter is what made the endpoint interesting: a blank page with a URL-fetching parameter behind it is a classic SSRF candidate.
Exploitation
Step 1: Confirm the server makes the request
Adding the var parameter to the endpoint and pointing it at a Burp Collaborator link produced an HTTP request back from the server's IP. That confirms server-side request forgery: the application, not the browser, fetched the URL.
Why this matters: if you put a Collaborator address into a page and your own browser fetches it, that proves nothing, because your browser was always going to. If the request arrives from the server's IP address instead, the server did the fetching. That is the whole vulnerability in one observation.
Step 2: Probe loopback and observe the filtering
Replacing the Collaborator link with https://[redacted] and sending the request produced no response. Changing the address to https://127.1 returned a 200 OK with the internal page rendered on screen. That page only showed a redirect URL, so the content was not very interesting, but the result demonstrated limited filtering on URLs: the full loopback address was blocked or failed, while the shortened form was accepted.
200 OK is the standard success code a web server sends when a page loads normally. The lesson here is that the filtering was limited: the full loopback address did not work, but the shortened form did. 127.1 is simply a shorter way of writing the same loopback address, and the filter did not recognise it. This is a common pattern: filters that match strings are easy to step around, because there are many ways to write the same thing.
Step 3: Reach the cloud metadata service
Next the author requested the AWS internal IP with the metadata path:
[redacted]/metadata
This is the fixed internal address that AWS machines use to ask the cloud platform about themselves. The /metadata part is the path that returns that information. The metadata was displayed. According to the author, this gave full access to AWS for the company, allowing keys and other information to be gathered.
Think of the metadata service as a staff noticeboard inside the building: it holds temporary badges and details about the machine. It is only supposed to be readable from inside. By making the server read it, the author could see the metadata, which he describes as full access to the company's AWS environment.
Step 4: Read local files
file:///etc/passwd
This is a URL with the file:// scheme, which means "read a file from this computer's disk" rather than "fetch a web page". /etc/passwd is a standard file on Linux systems that lists user accounts. That loaded as well. From there the author could request the host file to understand the internal IP ranges.
The "host file" is the system's list of names mapped to IP addresses, which reveals which internal machines exist and what they are called. That is useful reconnaissance before scanning.
Step 5: Scan the internal network
The request was sent to Burp Repeater and used to scan across the internal address space for interesting pages on port 8080 or with the URL /admin.
A port is a numbered door on a computer; different services listen on different doors. Port 8080 is commonly used by web applications running alongside the main site. /admin is a common path for administration pages. Scanning here means sending the same request many times with different internal addresses to see which ones answer.
Step 6: Shellshock against an internal host
The author had learned about Shellshock from a PortSwigger lab: an RCE vulnerability that can be exploited via the User-Agent header. The payload itself is not reproduced in the report; the author says that googling will show it.
Two terms to explain. The User-Agent header is a line your browser sends with every request saying what browser and version it is; servers often log it or use it to tailor responses. Shellshock is an old flaw in a program called Bash, a command interpreter on Linux. In certain versions, Bash would execute crafted function definitions placed in environment variables, including values derived from headers like User-Agent. So a server that passed the User-Agent into a shell could be made to execute whatever the attacker wrote there. That is why it turns an SSRF into RCE.
The payload was added to the Intruder request and the scan across the internal range was repeated. A ping back confirmed that an internal host was vulnerable. At that point the author had full internal access and Remote Code Execution internally, reached from the outside.
Root cause
The /proxy endpoint accepted a user-supplied URL through the var parameter and fetched it server-side without adequate restriction. The filtering that existed was weak: https://[redacted] did not return a response, but https://127.1 did, and the link-local metadata address and the file:// scheme were both accepted. Because the fetcher followed whatever scheme and host it was given, it could reach loopback, the cloud metadata service and the local filesystem, and it could be pointed at internal hosts on other ports and paths. The internal host that answered the Shellshock probe was running a service that passed the User-Agent header into a shell, which turned the SSRF into code execution.
In everyday terms: the proxy was a helpful assistant that would go anywhere you asked, and the only guard was a list of words it refused to hear. Say the address differently and the assistant went anyway.
Impact
Under the conditions shown, an unauthenticated attacker who can reach /proxy could:
- Make the server issue requests to arbitrary destinations, confirmed with a Collaborator callback.
- Reach loopback through the shortened
127.1form and render internal pages. - Read AWS instance metadata at
[redacted]/metadata, which the author says gave full access to AWS for the company and allowed gathering keys and other information. - Read local files such as
/etc/passwdviafile://, and use the host file to map internal IP ranges. - Scan internal address space on port 8080 and for
/admin. - Achieve Remote Code Execution on an internal host vulnerable to Shellshock, giving full internal access from the outside.
Fix
Based on the behaviour shown, the fetcher should restrict the schemes it accepts (no file://), resolve and validate the destination host against an allowlist rather than a blocklist, reject loopback and link-local addresses including shortened forms such as 127.1, and block the cloud metadata address. Internal services should also not pass client-controlled headers such as User-Agent into a shell.
An allowlist is the opposite of a blacklist: instead of naming what is forbidden, you name exactly what is permitted, and everything else is refused. That is far harder to bypass, because there are endless ways to write a forbidden address but only a few legitimate destinations.
Variants to test
- Hidden URL parameters on blank pages. Crawl with waybackurls, GAU and gospider, then inspect the source of endpoints that render nothing. A positive result is a parameter that, when pointed at a Collaborator link, produces an inbound request from the server's IP.
- Loopback bypasses. Try
https://[redacted], thenhttps://127.1and other shortened or alternative representations. A positive result is a200 OKwith internal content rendered. - Cloud metadata. Request
[redacted]/metadatathrough the parameter. A positive result is metadata displayed in the response. - Local file read. Try
file:///etc/passwd. A positive result is the file contents in the response, and the host file can then be used to map internal ranges. - Internal scanning. Send the request to Repeater or Intruder and sweep internal addresses on port 8080 and paths such as
/admin. A positive result is any interesting internal page. - Shellshock via User-Agent. Add the Shellshock payload to the User-Agent in an Intruder request against internal hosts. A positive result is a callback confirming an internal host is vulnerable, which turns the SSRF into RCE.
Glossary
- Server: the computer that hosts a website and answers requests from visitors.
- Request: the message a browser sends to a server asking for a page or action.
- Parameter: a named value attached to a request, such as
varin?var=.... - Endpoint: a specific address on a server that performs a specific job, such as
/proxy. - Page source: the raw HTML a server sends, readable through the browser's View Source or developer tools.
- SSRF (Server Side Request Forgery): a flaw where an attacker can make a server fetch a URL of their choosing.
- RCE (Remote Code Execution): running your own commands on someone else's computer.
- Loopback: the address a computer uses to talk to itself,
[redacted]orlocalhost. - Link-local address: an address only reachable on the local network segment, such as
[redacted]. - Cloud metadata: an internal service in a cloud platform that hands out information and credentials about a machine.
- Credentials: keys or passwords that prove identity, here to a cloud platform.
- Blacklist: a list of things a program refuses to accept.
- Allowlist: a list of things a program accepts, with everything else refused.
- URL encoding: writing special characters in a URL in a coded form, such as
%20for a space. - DNS: the system that translates names like
example.cominto numeric IP addresses. - DNS tampering: abusing that translation so a blocked name points to an allowed address.
- Waybackurls: a tool that lists historical URLs from public web archives.
- GAU (Get All URLs): a tool that gathers known URLs from several public sources.
- gospider: a crawler that follows links automatically.
- Burp Suite: a toolkit for intercepting, editing and replaying web requests.
- Burp Collaborator: a Burp feature that gives you a unique address and reports any contact made to it.
- Burp Repeater: a Burp tool for resending a request repeatedly with edits.
- Burp Intruder: a Burp tool for sending a request many times with different values in chosen positions.
- 200 OK: the standard success code a web server returns when a page loads normally.
- Port: a numbered door on a computer that a particular service listens on, such as 8080.
file://scheme: a URL form meaning "read a file from this computer's disk"./etc/passwd: a standard Linux file listing user accounts.- Host file: a system file mapping names to IP addresses, useful for mapping internal machines.
- User-Agent header: a line sent with every request identifying the browser and version.
- Shellshock: an old flaw in the Bash shell where crafted text in environment variables could be executed as commands.
- PortSwigger lab: an online practice exercise for web security techniques.
- Unauthenticated: reachable without logging in.
- CVSS: a standard scoring system for the severity of a vulnerability.
- Bounty: a payment made to a researcher for reporting a valid vulnerability.