Leaked account lead to RCE
A JavaScript function allowed retrieval of account credentials by ID without rate limiting, enabling account takeover. The attacker then uploaded a .shtml file to execute server-side includes, bypassed the firewall with encoding, and achieved remote code execution.
medium.com
Published on medium.com
Bug Bounty
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 write-up describes a bug bounty engagement in which a leaked account led to remote code execution. The author does not name the company, the product or the application, and states that identifying details cannot be disclosed. What the report does describe is a web application with a login, a JavaScript front end, an account lookup function that takes an ID, and a file upload feature. The upload feature is the part that turns an account takeover into code execution, because the server accepts .shtml files and processes Server-Side Includes (SSI).
The final chain, as the author summarises it, is:
Leaked credentials -> Account takeover -> file upload -> Server-Side Includes -> Remote Code Execution
Setup
The report does not list accounts, roles, tool versions or preconditions beyond the tools used for reconnaissance. The author began with two standard enumeration tools:
waybackurls, to look for archived URLs that might be interesting.subfinder, to look for subdomains.
Neither produced anything useful. The author then moved to reading the application's source and browsing the site itself, which is where the first finding appeared. No credentials, hosts or versions are given, and the target is referred to only as the application.
Finding it
While reviewing the source and the site, the author found a JavaScript file that exposed a function able to retrieve account information by ID. The JavaScript file exposed the function, and testing showed it worked. Testing showed the function had no rate limiting.
With no rate limiting in place, the author tested different IDs. Eventually one ID returned a valid account, and the response contained credentials. Logging in with those credentials succeeded.
At this point the author had an account takeover, but deliberately did not report it yet, wanting to know whether it could lead to something more serious.
Exploitation
Step 1: Enumerate account IDs through the exposed function
The JavaScript file exposed a function that retrieves account information by ID. The report does not include the function's code, the endpoint, the parameter name or a sample response. What it does say is that the function had no rate limiting, so the author could try different IDs until a valid account was found. The response for that account contained credentials, and those credentials worked at the login.
Step 2: Log in with the leaked credentials
The login succeeded, giving the author access to the account. The report does not describe the account's role or what it could reach.
Step 3: Probe the file upload
While testing the application, the author noticed a file upload feature and began testing file types and common upload restrictions. The results were:
| File type | Result |
|---|---|
| PHP | Rejected |
| JavaScript | Rejected |
| SVG | Rejected |
.shtml |
Accepted |
The server accepted .shtml files. Researching this behaviour, the author found that the server supported Server-Side Includes, which allowed server-side commands to be executed.
Step 4: Control the command through a header
For testing, the author was able to control the command input through an HTTP header. The report does not name the header, show the SSI directive used, or include the request. The important point is that the server supported SSI, which allowed server-side commands, and the command input could be controlled from a request header.
Step 5: Confirm RCE and get a reverse shell
Further testing confirmed that this could lead to Remote Code Execution. Some requests were blocked by the server's firewall, so the author tried different encoding techniques until a payload bypassed the firewall and produced a reverse shell.
Root cause
Two separate weaknesses combine here.
The first is the account lookup function exposed in client-side JavaScript. It returns account information, including credentials, for an ID supplied by the caller, and it has no rate limiting. That makes enumeration practical: an attacker can walk IDs until a valid account appears.
The second is the upload handling. The application blocks PHP, JavaScript and SVG, but not .shtml, and the server processes SSI in files of that type. The blocklist therefore covers the obvious executable extensions while leaving a server-side execution path open. The command input could be controlled through a header.
The firewall stopped some requests but not all: changing the encoding was enough to get past it.
Impact
An attacker who can reach the exposed function can enumerate IDs, obtain credentials for a valid account and log in as that user. From there, the upload feature accepts .shtml files, and the server's SSI support allowed server-side commands to be executed. The author confirmed this could lead to Remote Code Execution and obtained a reverse shell.
The firewall blocked some requests, so the bypass depended on finding an encoding the firewall did not catch.
Fix
The report says the vulnerabilities were responsibly reported, patched and rewarded, but does not describe the changes made. Based on the findings, the fixes would be to remove or properly authorise the account lookup function so it does not return credentials, add rate limiting and server-side access control to it, and stop accepting .shtml uploads (or disable SSI processing for uploaded content) rather than relying on a blocklist of PHP, JavaScript and SVG. The report does not confirm which of these were applied.
Variants to test
- Client-side JavaScript that calls account APIs. Read the bundled JavaScript for functions that take an ID and return account data. A positive result is a response containing credentials or personal data for an ID you do not own, especially when repeated requests are not throttled.
- ID enumeration without rate limiting. Where an endpoint takes a numeric or predictable ID, try a range of values. A positive result is a valid record returned for an ID you were not given.
- Upload extension blocklists. When PHP, JavaScript and SVG are rejected, try other server-processed extensions, including
.shtml,.shtmand.stm. A positive result is an upload that is accepted and then processed by the server rather than served as static content. - SSI processing in uploaded files. Upload a file containing an SSI directive and request it back. A positive result is the directive being evaluated on the server instead of appearing in the response body.
- Command input through headers. If SSI is processed, check whether request headers reach the executed command. A positive result is a command whose output changes when you change a header value.
- Firewall encoding bypasses. When a payload is blocked, try alternative encodings of the same request. A positive result is the same command executing through an encoding the firewall did not block.
What happened, in plain words
A security researcher was looking at a website as part of a bug bounty programme. A bug bounty is an arrangement where a company invites people to look for security problems in its systems and pays them for reporting what they find, instead of punishing them. The researcher does not name the company or the product, and says identifying details cannot be disclosed.
The short version of the story is this: the website had a piece of JavaScript, the code that runs inside your browser when you visit a page, which could ask the server for the details of any account if you gave it an account number. The researcher tried different IDs, the function had no rate limiting, and eventually one ID came back with a real account and its credentials. Those details worked at the login page, so the researcher was now inside someone else's account.
That alone is serious, but the researcher kept going. While testing the application, the researcher noticed a feature for uploading files. The site refused to accept PHP, JavaScript and SVG files, which are the obvious dangerous ones, but it happily accepted a file ending in .shtml. On this particular server, SSI was supported, so the server could carry out instructions inside pages before sending them to the browser. Those instructions are called Server-Side Includes, or SSI. Because of that, server-side commands could be executed.
The researcher then confirmed that this could go all the way to Remote Code Execution, usually shortened to RCE, which means running your own commands on someone else's computer. A firewall blocked some of the attempts, so the researcher kept changing how the request was encoded until one version got through and produced a reverse shell, a connection from the server back to the researcher's machine that lets the researcher type commands on the server.
The whole chain, in the author's own summary, is:
Leaked credentials -> Account takeover -> file upload -> Server-Side Includes -> Remote Code Execution
Each arrow is a step that only works because the previous step worked. That is what people mean by an attack chain: a series of small weaknesses that, joined together, become a big one.
The starting point: looking around
Before touching anything, the researcher did some reconnaissance. Reconnaissance just means gathering information about a target before attacking it, the way you might walk around a building before trying the doors.
The report mentions two tools:
waybackurls, which looks through archived copies of the web to find URLs that belonged to the site in the past. Old pages are interesting because they are often forgotten and still online.subfinder, which looks for subdomains, the names that sit in front of a domain, such asshop.example.comnext toexample.com.
Neither tool turned up anything useful. So the researcher changed approach and started reading the application's source code and browsing the site by hand. That is where the first finding appeared. The report does not give the site's address, the tools' versions or any account details, and refers to the target only as the application.
Finding the account lookup function
While reading the source and the site, the researcher found a JavaScript file that exposed a function able to retrieve account information by ID.
A few terms are worth unpacking here.
- JavaScript file: a text file that the browser downloads and runs. Modern websites ship a lot of it, and it is readable by anyone who opens the browser's developer tools or simply requests the file.
- Function: a named block of code that does one job. Here the job is "give me the account information for this ID".
- ID: a number or short code that identifies a record. Think of a customer number on a receipt: it points at exactly one customer.
- API: the part of a server that answers requests from code rather than from a person clicking links. When the JavaScript asks the server "what is account 1234?", it is calling an API. A useful comparison is a restaurant: the menu is the API, the kitchen is the server, and you never walk into the kitchen yourself, you order through the menu.
The function was reachable from the client side, meaning the browser could call it. The researcher tested it and it worked. Then came the important question: is it rate limited?
Rate limiting is a cap on how often someone can do something in a period of time. A real-world comparison is a ticket machine that only sells one ticket per minute per person. Without a cap, a script can ask thousands of questions in a minute, and that is exactly what makes guessing practical.
The function had no rate limiting. That is the first real weakness.
Guessing IDs until an account appears
With no rate limit in place, the researcher tried different IDs. This is called enumeration: walking through a list of possible values, one after another, to see which ones exist. If IDs are simple numbers, enumeration is easy, because you can just count upwards.
Eventually one ID returned a valid account, and the response contained credentials. Credentials means the username and password, or whatever the site uses to prove who you are.
The report does not include the function's code, the address it calls, the name of the parameter or a sample response. What it does say is that the function returned account information including credentials, and that the response for one ID contained credentials that worked.
Logging in with the leaked credentials
The researcher tried logging in with those credentials, and it worked. That is the account takeover: control of an account that belongs to someone else.
At this point the researcher deliberately did not report the vulnerability yet. The reason is practical: a single account takeover might be treated as a moderate issue, but if it can be chained into something bigger, the report is more valuable and the fix more urgent. So the researcher kept testing to see whether it could lead to something more serious.
Noticing the upload feature
While testing the application, the researcher noticed that files could be uploaded. Upload features are common: profile pictures, documents, attachments. They are also a classic source of trouble, because a server that accepts a file has to decide what to do with it.
The researcher started testing different file types and checking common upload restrictions. The results were:
| File type | Result |
|---|---|
| PHP | Rejected |
| JavaScript | Rejected |
| SVG | Rejected |
.shtml |
Accepted |
Why those three were tried first: PHP is a programming language that runs on web servers, so a .php file that the server executes is effectively a way to run your own code. JavaScript files can be dangerous when served back to other users' browsers. SVG is an image format, but it is written in a markup language that can contain scripts, so it is often blocked too.
The server rejected all three. But it accepted .shtml. That is the interesting part: the blocklist covered the obvious extensions and missed one.
What .shtml and SSI mean
A blocklist is a list of things that are forbidden. It only works for the things on the list. Anything not written down gets through, which is why security people generally prefer allowlists: a list of things that are permitted, with everything else refused.
.shtml is a file extension used for HTML pages that contain Server-Side Includes, or SSI. SSI is an old but still supported feature: before the server sends a page to your browser, it scans the page for special instructions and carries them out. A simple example is including another file's contents in the page, so you can reuse a header across many pages. Some SSI instructions can also run commands on the server.
A comparison: imagine a printed form where most lines are ordinary text, but a few lines are instructions to the clerk, such as "stamp this here". The visitor sees the finished form; the clerk sees and follows the instructions. SSI is the clerk reading the instructions before handing you the page.
After researching this behaviour, the researcher found that the server supported SSI, which allowed server-side commands to be executed. In other words, the server supported SSI, and SSI allowed server-side commands to be executed.
Controlling the command through a header
For testing purposes, the researcher was able to control the command input through an HTTP header.
An HTTP header is a small piece of information sent alongside every web request and response. Your browser sends headers all the time without you noticing: which browser you use, which language you prefer, which site you came from. A comparison is the label on a parcel: the parcel is the request body, the label carries the delivery details.
The key point is that the server supported SSI, which allowed server-side commands, and the command input could be influenced from a request header. That matters because the command input could be controlled from a request header.
Confirming RCE and getting a reverse shell
The researcher continued testing and confirmed that this could lead to Remote Code Execution. RCE means running commands of your choosing on a machine you do not own. It is usually the most serious outcome in web security, because from there an attacker can often read data, change it, or move to other systems.
Some requests were blocked by the server's firewall. A firewall here is a filter that inspects incoming requests and drops the ones that look malicious. The researcher kept testing different encoding techniques until one got past the firewall and produced a reverse shell.
Encoding means representing the same information in a different written form. A simple comparison is writing a word in a different alphabet or with extra symbols: a human reader still understands it, but a filter that only looks for the exact original spelling does not recognise it.
A reverse shell is a connection that the server opens back to the attacker's machine, giving the attacker a command prompt on the server. It is called reverse because the direction is the opposite of the usual one, where you connect to a server.
Why it worked
Two separate weaknesses combine here.
The first is the account lookup function exposed in client-side JavaScript. It returns account information, including credentials, for an ID supplied by the caller, and it has no rate limiting. That makes enumeration practical: an attacker can walk IDs until a valid account appears.
The second is the upload handling. The application blocks PHP, JavaScript and SVG, but not .shtml, and the server processes SSI in files of that type. The blocklist therefore covers the obvious executable extensions while leaving a server-side execution path open. The command input could be controlled through a header.
The firewall stopped some requests but not all: changing the encoding was enough to get past it.
What the impact was
An attacker who can reach the exposed function can enumerate IDs, obtain credentials for a valid account and log in as that user. From there, the upload feature accepts .shtml files, and the server's SSI support allowed server-side commands to be executed. The researcher confirmed this could lead to Remote Code Execution and obtained a reverse shell.
The firewall blocked some requests, so the bypass depended on finding an encoding the firewall did not catch.
How it was fixed
The report says the vulnerabilities were responsibly reported, patched and rewarded, but does not describe the changes made. Based on the findings, the fixes would be to remove or properly authorise the account lookup function so it does not return credentials, add rate limiting and server-side access control to it, and stop accepting .shtml uploads (or disable SSI processing for uploaded content) rather than relying on a blocklist of PHP, JavaScript and SVG. The report does not confirm which of these were applied.
Things worth trying on other sites
These are the same ideas, written so you can recognise them elsewhere. Only test systems you are allowed to test.
- Client-side JavaScript that calls account APIs. Read the bundled JavaScript for functions that take an ID and return account data. A positive result is a response containing credentials or personal data for an ID you do not own, especially when repeated requests are not throttled.
- ID enumeration without rate limiting. Where an endpoint takes a numeric or predictable ID, try a range of values. A positive result is a valid record returned for an ID you were not given.
- Upload extension blocklists. When PHP, JavaScript and SVG are rejected, try other server-processed extensions, including
.shtml,.shtmand.stm. A positive result is an upload that is accepted and then processed by the server rather than served as static content. - SSI processing in uploaded files. Upload a file containing an SSI directive and request it back. A positive result is the directive being evaluated on the server instead of appearing in the response body.
- Command input through headers. If SSI is processed, check whether request headers reach the executed command. A positive result is a command whose output changes when you change a header value.
- Firewall encoding bypasses. When a payload is blocked, try alternative encodings of the same request. A positive result is the same command executing through an encoding the firewall did not block.
Glossary
- API: the part of a server that answers requests from code, such as a browser script asking for account data.
- Attack chain: several weaknesses used one after another, where each step makes the next one possible.
- Blocklist: a list of forbidden items; anything not on the list is allowed.
- Bug bounty: a programme where a company pays people for finding and reporting security problems in its systems.
- Client side: code that runs in the visitor's browser rather than on the server.
- Credentials: the details used to prove who you are, typically a username and password.
- Encoding: writing the same information in a different form, often to get past a filter that looks for one specific spelling.
- Enumeration: trying a series of possible values, such as IDs, to find the ones that exist.
- Firewall: a filter that inspects incoming requests and drops the ones it considers malicious.
- Function: a named block of code that performs one job.
- HTTP header: a small piece of information sent with a web request or response, such as the browser type or preferred language.
- ID: a number or code that identifies one record, like a customer number.
- JavaScript: the programming language that runs in web browsers and powers most interactive pages.
- PHP: a programming language commonly used on web servers; a
.phpfile that the server executes can run code. - Rate limiting: a cap on how many requests can be made in a period of time.
- RCE (Remote Code Execution): running commands of your choosing on a machine you do not own.
- Reconnaissance: gathering information about a target before testing it.
- Reverse shell: a connection from the server back to the attacker's machine that gives the attacker a command prompt on the server.
- Server side: code that runs on the server, invisible to the visitor.
.shtml: a file extension for HTML pages that may contain Server-Side Includes.- SSI (Server-Side Includes): instructions inside a page that the server carries out before sending the page to the browser; some can run commands.
- Subdomain: a name in front of a domain, such as
shop.example.comnext toexample.com. - SVG: an image format written in markup that can contain scripts, which is why uploads of it are often blocked.
subfinder: a tool that searches for subdomains.waybackurls: a tool that finds URLs archived from a site's past.