Skip to content
XSS Write-up Beginner

Finding keys under the door

A login page exposed default credentials, and after logging in, the author found an unrestricted file upload that allowed uploading HTML files, which were served from CloudFront and rendered by the browser, leading to stored XSS. The author could not achieve RCE because non-HTML files were returned as octet-streams.

Naveen Prakaasham K S V Follow

Published on naveenprakaasam.medium.com

Naveen Prakaasham K S V

Naveen Prakaasham K S V, on naveenprakaasam.medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Paytm runs a bug bounty programme, and this write-up covers a finding on one of the domains listed in its scope. The domain hosted an admin interface built on the Vue Element Admin framework. The framework is a production-ready front-end solution for admin interfaces, and the vendor publishes a demo instance of it. The feature at the centre of the report is a game management area: pages listing games with fields such as ID, Name and Channel, forms to create or edit games, a Game icon upload and a separate game package upload. Uploaded files are served back from CloudFront.

Setup

The researcher, Naveen Prakaasham K S V, worked only from the outside. The recon chain was subdomain enumeration, filtering for subdomains that are online, Aquatone, then reading the generated report by hand. No accounts were provisioned: the credentials needed for the dashboard were published on the login page itself. No specific tool versions are given.

Finding it

One subdomain stood out because its login page carried two usernames and passwords underneath the form, and the fields were already auto-filled with them. The page was a Vue Element Admin login screen. Logging in with those credentials reached the dashboard, which at first glance looked like the default dashboard with nothing of interest. The researcher reported what had been found so far.

Paytm's security team replied asking whether any sensitive information could be reached, or any action with security impact performed, inside the dashboard. That prompted a look at the framework itself: its GitHub repository, its documentation and its public test site at https://panjiachen.github.io/vue-element-admin/. On the test site the same pattern appeared: when the framework is not fully configured, the username and password sit on the login page. Logging into the test instance and browsing it showed a left-hand tab menu linking to the other pages of the application. That raised the question of whether the target had similar links that had been missed.

Returning to the target, two further pages existed besides the Dashboard: GameList and PvPList. Both held lists of games with ID, Name, Channel and similar fields, and offered options to create games or edit existing ones.

Exploitation

Step 1: XSS attempts in the name field

XSS payloads were inserted into the name field of the game forms. None of them worked.

Step 2: XSS attempt through the file name

A file was named after an XSS payload and uploaded through the Game icon field. No XSS fired here either. The upload did, however, reveal where files land: after the upload, a CloudFront URL for the image was displayed below the Upload button, in this shape:

Text
https://random-chars.cloudfront.net/2021/01/random-random-random.png

The path structure shows the upload year and month followed by a randomised file name.

Step 3: HTML through the icon upload

Since the icon upload accepted files and disclosed their location, the next idea was unrestricted file upload. A test HTML file was submitted as the Game Icon. It was rejected with a message along the lines of "Not an image". Before looking for bypasses to that check, a second Upload button was noticed below it.

Step 4: The game package upload

That second button uploads the game package. It applied no checks at all, so any kind of file could be uploaded, and it also displayed the CloudFront URL of the uploaded file. This was reported as an unrestricted file upload with the potential to lead to remote code execution.

Step 5: Chasing RCE

The security team asked for confirmation that RCE was possible. A PHP shell was uploaded first, but the server returned the file as an octet-stream. The CloudFront server was running the OpenResty Lua Nginx Module, so files written in Lua were tried next, with the same behaviour. Across a range of file types, everything except HTML files came back as octet streams. HTML files, by contrast, were rendered by the browser, so JavaScript was placed inside them and the XSS executed. That gave a stored XSS. More hours went into reading articles and looking for a route to RCE, without success.

Root cause

The game package upload performed no validation of file type or content, so arbitrary files were accepted and published to a CloudFront distribution. The icon upload did have a check, which rejected the HTML file as not an image, but the package upload beside it did not. Serving the uploaded objects back to browsers meant that an HTML file was rendered rather than downloaded, which turned the upload into stored XSS. Non-HTML types were returned as octet-streams, so the PHP and Lua files did not execute, even on a server running the OpenResty Lua Nginx Module. The credentials on the login page are a separate configuration failure: the framework leaves the username and password on the login page when it is not fully configured, and the target had been deployed in that state.

Impact

An attacker who could reach the game management pages could upload arbitrary files, including HTML carrying JavaScript, and have them served from the CloudFront domain. Because the HTML was rendered by the browser, the result was stored XSS. The report frames the upload as potentially leading to remote code execution, but that was not achieved: PHP and Lua files were returned as octet-streams. The published credentials on the login page gave direct access to the dashboard.

Fix

The security team took some days to fix the issue and then paid a bounty. The report does not describe the change that was made.

Variants to test

  1. Check framework demo deployments for default credentials left on the login page. A positive result is a login form pre-filled with working credentials that grant access to the dashboard.
  2. Enumerate the menu of an admin panel after login rather than judging it by the landing page. A positive result is additional pages, such as list and edit screens, that were not linked from the dashboard.
  3. Look for a second upload control next to a validated one. A positive result is an upload that accepts a file the neighbouring control rejects.
  4. Upload an HTML file through any upload that returns a public URL and open that URL in a browser. A positive result is the HTML being rendered, with any embedded JavaScript executing.
  5. Upload server-side script types (PHP, Lua and others) and fetch them back. A positive result is execution rather than the file being returned as an octet-stream.
  6. Try file types matching the server stack, as was done with Lua against the OpenResty Lua Nginx Module. A positive result is a file that the server interprets instead of serving.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

A security researcher was looking for bugs in websites that belong to Paytm, through a programme where companies invite people to report security problems in exchange for a reward (a bug bounty programme). On one of the company's websites he found a login page that had two usernames and passwords printed right on it, and the login form was already filled in with them. He logged in and found a game management area. In that area there was a button for uploading a game package, and it accepted any file at all, with no checks. Files that were uploaded could be opened in a browser through a public web address. When he uploaded a web page (an HTML file) containing JavaScript, the browser ran that JavaScript. That kind of bug is called stored cross-site scripting, or stored XSS. He also tried to get the server to run his own code (remote code execution, RCE) but did not manage it. The company fixed the problem and paid him a reward.

This article walks through the same story from the beginning, explaining each idea as it comes up, so that you can follow it with nothing more than a browser and a computer.

Some words you will meet first

Before the story, a few everyday ideas.

  • A domain is a name on the internet, like example.com. A company usually owns many of them, and each one can host a different website or service.
  • A subdomain is a name placed in front of a domain, like shop.example.com or admin.example.com. Companies often have dozens or hundreds of them, and some are forgotten or less protected than the main site.
  • Recon (short for reconnaissance) means looking around before attacking: finding out which subdomains exist, which ones are online, and what they look like. It is the internet equivalent of walking around a building and noting which doors are open.
  • A login page is the form where you type a username and a password to get into an account.
  • A dashboard is the first screen you see after logging in to an admin area. It usually shows a summary and a menu linking to the other pages.
  • A framework is a ready-made set of building blocks that programmers use to build a website faster, instead of writing everything from scratch. Vue Element Admin, the framework in this story, is one for building admin interfaces.
  • CloudFront is Amazon's content delivery network: a service that stores files and hands them out to visitors quickly from locations around the world. When a file is uploaded to a site that uses CloudFront, the file often ends up with a public web address on a CloudFront domain.
  • XSS (cross-site scripting) is a bug where an attacker manages to get their own JavaScript to run inside another person's browser, in the context of a website. JavaScript is the programming language that browsers run; it is what makes web pages interactive. If an attacker's JavaScript runs on a site you are logged in to, it can act as you.
  • Stored XSS is the variant where the malicious content is saved on the server (for example, uploaded as a file or saved in a database) and then served to anyone who opens it later. The attack is stored once and fires for every visitor.
  • RCE (remote code execution) is the most serious kind of bug: the attacker gets the server itself to run code the attacker wrote. It is the difference between leaving a note in someone's letterbox and getting the keys to the house.
  • An octet-stream is a generic label a web server puts on a file when it does not know what the file is. The browser's reaction is to download it rather than display it. It is like a parcel marked "contents unknown": you take it home and open it yourself instead of the postman reading it to you.
  • OpenResty is a web server built on top of the popular Nginx server, with extra scripting support. The Lua Nginx Module lets that server run small programs written in the Lua programming language. If a server can run Lua, an attacker who can upload a Lua file might hope the server will run it.

The starting point: a bug bounty programme

Paytm runs a bug bounty programme, and this write-up covers a finding on one of the domains listed in its scope. "In scope" means the company has said: these particular websites are fair game for testing, and if you find a real problem we will look at it. Testing outside the scope is not allowed.

The domain in question hosted an admin interface built on the Vue Element Admin framework. The framework is a production-ready front-end solution for admin interfaces, and the vendor publishes a demo instance of it. The feature at the centre of the report is a game management area: pages listing games with fields such as ID, Name and Channel, forms to create or edit games, a Game icon upload and a separate game package upload. Uploaded files are served back from CloudFront.

In plain terms: the website was a control panel for managing games. It had a list of games, forms to add or change them, a place to upload a small picture for each game (the icon), and a separate place to upload the game itself (the package). Anything uploaded was stored and then handed back to visitors through CloudFront.

How the researcher worked

The researcher, Naveen Prakaasham K S V, worked only from the outside. He had no special access and no insider knowledge. The recon chain was subdomain enumeration, filtering for subdomains that are online, Aquatone, then reading the generated report by hand. No accounts were provisioned: the credentials needed for the dashboard were published on the login page itself. No specific tool versions are given.

Let us unpack that chain, because it is the routine start of almost every web bug hunt.

  1. Subdomain enumeration. You collect as many subdomain names as you can for the target domain. There are public lists and services that record names seen in certificates and elsewhere, so this is mostly a matter of gathering.
  2. Filtering for subdomains that are online. Many of the names you collect no longer exist. You check which ones actually answer, so you do not waste time on dead ends.
  3. Aquatone. This is a tool that visits each live subdomain, takes a screenshot of what it shows, and puts the screenshots into a report. It is like sending a photographer round to photograph every door in a large building so you can flip through the pictures afterwards.
  4. Reading the report by hand. The researcher looked through the screenshots himself. Tools find candidates; a human decides which one is interesting.

Why start here? Because the main website of a company is usually well looked after, while a forgotten subdomain running an internal tool can be years behind on fixes. The keys are often not under the biggest lamp.

The first finding: credentials on the login page

One subdomain stood out because its login page carried two usernames and passwords underneath the form, and the fields were already auto-filled with them. The page was a Vue Element Admin login screen.

Think about what that means. A login page exists to keep people out. This one had the keys taped to the door: the username and password were written on the page for anyone to read, and the form had been set up to fill them in automatically. The researcher did not have to guess, crack or steal anything.

Logging in with those credentials reached the dashboard, which at first glance looked like the default dashboard with nothing of interest. The researcher reported what had been found so far.

Why report at this stage, before finding anything more dramatic? Because a bug bounty is a conversation. Telling the company early that a login page is publishing working credentials lets them start looking, and it establishes that you found the door before you go further inside.

The company pushes back, and the framework gets examined

Paytm's security team replied asking whether any sensitive information could be reached, or any action with security impact performed, inside the dashboard. In other words: you are in, but is there anything valuable in there? A login page with credentials is a problem, but the team wanted to know what the credentials actually unlocked.

That prompted a look at the framework itself: its GitHub repository, its documentation and its public test site at https://panjiachen.github.io/vue-element-admin/.

Why look at the framework? Because the target was built with it, and frameworks come with demo sites. If the demo behaves in a certain way, the target probably behaves the same way, and the demo is a safe place to learn the layout without touching the company's systems.

On the test site the same pattern appeared: when the framework is not fully configured, the username and password sit on the login page. This is an important realisation. The credentials on the target were not a one-off mistake by a careless employee; they were the framework's default behaviour when someone deploys it without finishing the configuration. The framework ships with a demo login so that people trying it out can get in, and that demo login is supposed to be removed or changed before going live.

Logging into the test instance and browsing it showed a left-hand tab menu linking to the other pages of the application. That raised the question of whether the target had similar links that had been missed.

This is a habit worth copying. The demo showed a menu down the left side with links to every page. If the target was the same software, it probably had the same menu, and the researcher had not looked at it.

Back to the target: two more pages

Returning to the target, two further pages existed besides the Dashboard: GameList and PvPList. Both held lists of games with ID, Name, Channel and similar fields, and offered options to create games or edit existing ones.

So the dashboard had looked empty, but the menu led to real functionality. GameList and PvPList are lists of games, each row carrying an ID, a name, a channel and similar details, and each list had buttons to create a new game or edit an existing one.

Trying to inject script through the name field

Step 1: XSS attempts in the name field

XSS payloads were inserted into the name field of the game forms. None of them worked.

A payload here means a short piece of text crafted to be interpreted as code rather than as plain text. The idea is: if the site takes what I type in the name field and later shows it on a page without cleaning it, my text might run as JavaScript in the browser of whoever views that page. The researcher tried this and nothing happened, which suggests the site either cleaned the input or displayed it safely.

Why try this first? Because it is the cheapest test. Typing text into a box costs nothing, and if it works you have a stored XSS with no file upload involved.

Trying to inject script through the file name

Step 2: XSS attempt through the file name

A file was named after an XSS payload and uploaded through the Game icon field. No XSS fired here either. The upload did, however, reveal where files land: after the upload, a CloudFront URL for the image was displayed below the Upload button, in this shape:

Text
https://random-chars.cloudfront.net/2021/01/random-random-random.png

Line by line, in plain words:

  • https:// is the scheme, meaning this is a normal web address fetched over an encrypted connection.
  • random-chars.cloudfront.net is the CloudFront domain that serves the uploaded files. The report shows it with placeholder characters rather than the real name.
  • /2021/01/ is a folder path made of the year and month of the upload. This tells you the files are organised by date on the storage behind CloudFront.
  • random-random-random.png is the file name, randomised so that one upload cannot easily be guessed from another.
  • .png is the file extension, here for an image.

The path structure shows the upload year and month followed by a randomised file name.

Why does this matter so much? Because the site told the researcher exactly where his file had gone, and that address was open to anyone. If you can upload a file and then fetch it back from a public address, the next question is: what kind of file will it let you upload, and what will a browser do when it opens that address?

Trying an HTML file as the icon

Step 3: HTML through the icon upload

Since the icon upload accepted files and disclosed their location, the next idea was unrestricted file upload. An unrestricted file upload is a bug where the site accepts files of any type, including types it should never accept, and then serves them back. It is like a hotel that lets you post any parcel to a guest and then hands it to them unopened.

A test HTML file was submitted as the Game Icon. It was rejected with a message along the lines of "Not an image". Before looking for bypasses to that check, a second Upload button was noticed below it.

An HTML file is the kind of file a browser displays as a web page, and it can contain JavaScript. If the site had accepted one as a game icon and then served it back, the browser would have rendered it as a page and run any script inside. The icon upload refused, which is the correct behaviour: an icon should be an image, and the site checked.

Why mention the rejection at all? Because it sets up the contrast. One upload control did its job. The interesting question is what the control next to it did.

The game package upload

Step 4: The game package upload

That second button uploads the game package. It applied no checks at all, so any kind of file could be uploaded, and it also displayed the CloudFront URL of the uploaded file. This was reported as an unrestricted file upload with the potential to lead to remote code execution.

Read that again: the icon upload checked the file and said no, and the package upload right beside it checked nothing. The same page, two upload buttons, two completely different levels of care. The package upload also told the uploader where the file had landed, just like the icon upload did.

Why report it as potentially leading to RCE? Because an upload that accepts anything is the classic first step towards getting a server to run your code. If you can place a file of your choosing on a server, and the server is willing to execute files of that type, you have code execution. At this point that was a possibility, not a demonstrated fact, and the report said so.

Chasing RCE

Step 5: Chasing RCE

The security team asked for confirmation that RCE was possible. So the researcher tried to prove it.

A PHP shell was uploaded first, but the server returned the file as an octet-stream. PHP is a programming language widely used on web servers; a PHP shell is a small script that, if the server runs it, gives the attacker a way to run commands on the machine. The server did not run it. It handed the file back as an octet-stream, meaning the browser was told "this is just some binary data, download it". No execution.

The CloudFront server was running the OpenResty Lua Nginx Module, so files written in Lua were tried next, with the same behaviour. The reasoning: if the server has Lua support built in, maybe a Lua file will be treated as a program. It was not. The file came back as an octet-stream like the PHP one.

Across a range of file types, everything except HTML files came back as octet streams. HTML files, by contrast, were rendered by the browser, so JavaScript was placed inside them and the XSS executed. That gave a stored XSS.

This is the key distinction. The server never ran anything. It simply stored files and handed them back. But a browser does not need a server's permission to run JavaScript inside an HTML page: if the browser is handed an HTML file, it renders it, and rendering means running the scripts inside. So the bug was not on the server at all. It was in the browser of anyone who opened the uploaded file's public address.

More hours went into reading articles and looking for a route to RCE, without success.

Why keep trying? Because RCE is far more severe than stored XSS, and a researcher wants to report the true severity. But the honest outcome is also part of the report: the upload was real, the stored XSS was real, and the RCE was not achieved.

Why it worked

The game package upload performed no validation of file type or content, so arbitrary files were accepted and published to a CloudFront distribution. The icon upload did have a check, which rejected the HTML file as not an image, but the package upload beside it did not.

Serving the uploaded objects back to browsers meant that an HTML file was rendered rather than downloaded, which turned the upload into stored XSS. Non-HTML types were returned as octet-streams, so the PHP and Lua files did not execute, even on a server running the OpenResty Lua Nginx Module.

The credentials on the login page are a separate configuration failure: the framework leaves the username and password on the login page when it is not fully configured, and the target had been deployed in that state.

Put simply, three things lined up. The door was open because the login page published working credentials. The room behind it had an unchecked upload. And the files that upload accepted were served back in a way that let a browser run them. Remove any one of the three and the chain breaks.

What the impact was

An attacker who could reach the game management pages could upload arbitrary files, including HTML carrying JavaScript, and have them served from the CloudFront domain. Because the HTML was rendered by the browser, the result was stored XSS.

The report frames the upload as potentially leading to remote code execution, but that was not achieved: PHP and Lua files were returned as octet-streams. The published credentials on the login page gave direct access to the dashboard.

In everyday terms: the login page gave access, and an uploaded web page could be opened through its public address. When that person opened the link, the attacker's JavaScript ran in their browser, on a CloudFront address belonging to the company. What that script could then do depends on what the visitor had access to; the report does not go into that.

The fix

The security team took some days to fix the issue and then paid a bounty. The report does not describe the change that was made.

Things worth testing on other sites

These are the same lessons turned into checks you can repeat elsewhere. Each one is a question with a clear yes or no answer.

  1. Check framework demo deployments for default credentials left on the login page. A positive result is a login form pre-filled with working credentials that grant access to the dashboard.
  2. Enumerate the menu of an admin panel after login rather than judging it by the landing page. A positive result is additional pages, such as list and edit screens, that were not linked from the dashboard.
  3. Look for a second upload control next to a validated one. A positive result is an upload that accepts a file the neighbouring control rejects.
  4. Upload an HTML file through any upload that returns a public URL and open that URL in a browser. A positive result is the HTML being rendered, with any embedded JavaScript executing.
  5. Upload server-side script types (PHP, Lua and others) and fetch them back. A positive result is execution rather than the file being returned as an octet-stream.
  6. Try file types matching the server stack, as was done with Lua against the OpenResty Lua Nginx Module. A positive result is a file that the server interprets instead of serving.

Glossary

  • Admin interface: a website or part of one used to manage content or users, usually behind a login.
  • Aquatone: a tool that visits live subdomains, screenshots them and builds a report of the screenshots.
  • Bug bounty programme: a scheme where a company invites outsiders to test its systems and pays for valid security reports.
  • CloudFront: Amazon's content delivery network, which stores and serves files from locations around the world.
  • Credentials: a username and password (or similar) used to log in.
  • Cross-site scripting (XSS): a bug where an attacker's JavaScript runs in another person's browser in the context of a website.
  • Dashboard: the first screen after logging in to an admin area, usually with a summary and a menu.
  • Domain: a name on the internet, such as example.com.
  • Framework: a ready-made set of building blocks programmers use to build a website faster.
  • HTML: the file format browsers display as a web page; it can contain JavaScript.
  • JavaScript: the programming language browsers run to make pages interactive.
  • Login page: the form where a username and password are entered to gain access.
  • Lua: a small programming language; the OpenResty Lua Nginx Module lets a server run Lua programs.
  • Octet-stream: a generic label for a file of unknown type, which makes the browser download it instead of displaying it.
  • OpenResty: a web server built on Nginx with extra scripting support.
  • Payload: a short piece of text or data crafted to be treated as code by the target.
  • PHP: a programming language commonly used on web servers; a PHP shell is a script that would give command execution if the server ran it.
  • Recon (reconnaissance): the information-gathering phase before testing, such as finding subdomains and looking at what they show.
  • Remote code execution (RCE): a bug that lets an attacker get a server to run code the attacker wrote.
  • Scope: the list of systems a bug bounty programme allows you to test.
  • Stored XSS: XSS where the malicious content is saved on the server and served to every later visitor.
  • Subdomain: a name placed in front of a domain, such as admin.example.com.
  • Unrestricted file upload: a bug where a site accepts files of any type, including types it should never accept, and serves them back.
  • Vue Element Admin: a framework for building admin interfaces, with a public demo site.

More from Paytm

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.