XSS, RCE & HTML File Upload in same endpoint
The report describes a partner portal where an SVG logo upload led to cross-site scripting, and later a PHP file upload bypass allowed remote code execution. An attacker could execute scripts in other users' browsers and run code on the server.
Published on sa1tama0.medium.com
Hello, I’m Tarikul Islam, an acknowledging member of Sec Miner’s Bangladesh.
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
The target was a private company, and the asset in scope was the sub-domain partners.site.com, which the researcher describes as being used for partners' communication. The feature of interest was the partner profile: a partner can set details such as a name, an email and an avatar, and later, from a hidden user panel at partners.site.com/admin, change those details and upload a logo.
The researcher, Tarikul Islam (@sa1tama0), an acknowledging member of Sec Miner's Bangladesh, spent four days on the target before finding anything, and the write-up covers three separate issues found on the same upload endpoint over roughly a month: an XSS via SVG upload, an RCE via PHP file upload, and an HTML file upload found by a friend.
Setup
No special accounts, tools or versions are described beyond the partner account on partners.site.com and Burp Suite for capturing and modifying the upload request. The error response included an email address at [redacted] and a Gravatar URL in the avatar field. The hidden admin panel at partners.site.com/admin was found two days into the work.
Finding it
The initial goal was XSS on the partner-facing sub-domain. Four days of testing produced only an information disclosure: the name field was limited to 64 characters, and submitting a name of more than 100 characters caused the application to return a database error that leaked the failing SQL statement and its parameters.

The error shown was:
206 An exception occurred while executing 'INSERT INTO partners.user (id, site_id, name, email, avatar) VALUES (?, ?, ?, ?, ?)' with params [283, 411571, "\"****aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccdddddddddd…****", "[redacted]", "https:\/\/secure.gravatar.com\/avatar\/e5fbf987aa8c9f4b1ee0f05ad.jpg?d=mm"]: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(64)
The message exposes the table and column list (partners.user with id, site_id, name, email, avatar), the parameter values, and the database error for a character varying(64) column. The researcher considered whether the reflected error could be turned into XSS, but notes that this would only be Self XSS, and an attempt to find CSRF in the name field to upgrade it to Stored XSS failed.
Two days later the hidden user panel at partners.site.com/admin was found, where details could be changed. It also offered a logo upload, which is where the real issues were.
Exploitation
Step 1: SVG upload for XSS
The first idea on seeing the logo upload was to upload an SVG file. The SVG uploaded successfully, and the researcher obtained XSS from a non-privileged user to anyone by uploading the SVG file.

This earned a $200 reward. The researcher then built an SVG payload aimed at Blind XSS to raise the severity.

Step 2: Extensionless image upload
About a week later the site was rechecked. Uploading the SVG again, and attempts at bypasses, no longer worked. The researcher then uploaded an image without any extension. It was accepted, displayed as a normal image in the frontend, and when the full image was opened it was served as raw code with content-type: text/html.

Step 3: PHP upload for RCE
Uploading files with a PHP extension failed. The researcher then applied the JPG shell uploading technique, referred to in the write-up as the Ninja Method:
- Select an image (bind with PHP code) and click to upload.
- Capture the request with Burp Suite.
- Change the file name to
rce.php.
rce.php
The write-up records the result as "BOOM!!!". This earned a $1000 reward for RCE by PHP file upload.
Step 4: HTML file upload
About a month later a friend of the researcher found that HTML files could be uploaded to the same endpoint, and was rewarded $400 for it.
Root cause
The upload endpoint validated the file poorly. The SVG was accepted and served in a way that let its script run, so the upload was not restricted to safe image types and the stored file was rendered as active content. Later, the same endpoint accepted a file with no extension and served it as content-type: text/html, showing that the content type returned to the browser was not tied to a safe, fixed value. Finally, renaming the uploaded file to rce.php was enough to get PHP code executed, which means the server executed files from the upload directory based on the extension in the client-supplied file name.
The name field error is a separate weakness: an over-long value produced a full SQL exception with parameters in the response.
Impact
The SVG upload gave XSS from a non-privileged user to anyone who viewed the file. The extensionless upload showed that an uploaded file could be served as content-type: text/html. The PHP upload was rewarded as RCE by PHP file upload. The HTML upload found by the friend is a further variant on the same endpoint. The name field error disclosed the SQL statement, table and column names and the submitted values.
Fix
The write-up does not describe any fix applied by the company. Based on what was found, the upload endpoint should accept only an explicit allowlist of image types, verify content rather than trusting the client-supplied name, store uploads outside the web root or in a location where script execution is disabled, and serve them with a fixed, safe Content-Type and Content-Disposition. The name length should be validated in the application before the insert, and database errors should not be returned to the client.
Variants to test
- Upload an SVG containing a script element to any logo or avatar field. A positive result is the script running when the file is viewed, either directly or by another user.
- Upload an image with no extension and open the full image. A positive result is the file being served as
content-type: text/htmlwith the raw content rendered. - Upload an image whose content contains PHP code, capture the request, and rename the file to
rce.php. A positive result is the upload being accepted and the code executing when the file is requested. - Upload an HTML file to the same endpoint. A positive result is the file being stored and served as HTML.
- Submit a name longer than the column limit in profile fields. A positive result is a database exception in the response that includes the SQL statement and parameters.
What happened, in plain words
A security researcher spent a few days testing a website that belonged to a private company. The part of the site he focused on was a sub-domain called partners.site.com, which the company used so that its business partners could talk to it and manage their own details. Think of it as a members' area: each partner has a profile with a name, an email address and a small picture (an avatar).
Over about a month he found three separate problems on the same feature, the place where a partner uploads a logo. First, he uploaded a picture file in a format called SVG, and that file was able to run code in the browser of anyone who looked at it. That kind of problem is called XSS. Second, he uploaded a file that the server then treated as a program and ran, which is called RCE, the most serious kind of web bug. Third, a friend of his found that the same upload box would accept an HTML file, which is a web page rather than a picture. Along the way he also found a smaller issue: typing a very long name into the profile made the site show a database error message that revealed internal details.
The company paid $200 for the first XSS, $1000 for the RCE, and $400 to his friend for the HTML upload. This article walks through each step slowly, assuming you can use a browser and a computer but have never done security testing before.
The target and the feature
The asset in scope was the sub-domain partners.site.com. A sub-domain is simply a section of a larger website: if site.com is the main building, partners.site.com is a separate wing with its own door. This wing was used for partners' communication.
The feature of interest was the partner profile. A partner can set a name, an email and an avatar. Later, from a hidden user panel at partners.site.com/admin, a partner could change those details and upload a logo. A hidden panel here just means a page that is not linked from the normal menu; if you know the address, you can open it.
The researcher, Tarikul Islam (@sa1tama0), is an acknowledging member of Sec Miner's Bangladesh. He spent four days on the target before finding anything worth reporting.
Setting up
The write-up does not describe any special accounts, tools or software versions beyond two things: a partner account on partners.site.com, and Burp Suite, a program that sits between your browser and a website so you can see and edit every request before it is sent. The error response included an email address at [redacted] and a Gravatar URL (Gravatar is a service that shows a picture next to an email address). The hidden admin panel at partners.site.com/admin was found two days into the work.
Finding it
The initial goal was XSS on the partner-facing sub-domain. XSS, short for cross-site scripting, means getting your own code to run inside someone else's web page in a victim's browser. A simple comparison: imagine a noticeboard where visitors can pin notes. If the board also lets a visitor pin a note that says "whoever reads this, hand me your wallet", and the board faithfully reads every note aloud to the next visitor, that is roughly XSS: untrusted text being treated as instructions.
Four days of testing produced only an information disclosure. Information disclosure means the site reveals something it should keep to itself, such as an internal error message. The name field was limited to 64 characters, and submitting a name of more than 100 characters caused the application to return a database error that leaked the failing SQL statement and its parameters. SQL is the language used to talk to a database, the organised store where a website keeps its users, posts and so on.

The error shown was:
206 An exception occurred while executing 'INSERT INTO partners.user (id, site_id, name, email, avatar) VALUES (?, ?, ?, ?, ?)' with params [283, 411571, "\"****aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccdddddddddd…****", "[redacted]", "https:\/\/secure.gravatar.com\/avatar\/e5fbf987aa8c9f4b1ee0f05ad.jpg?d=mm"]: SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(64)
Line by line, in plain words:
206 An exception occurred while executingmeans the program hit an error while running a database command. The number 206 is the site's own error code.'INSERT INTO partners.user (id, site_id, name, email, avatar) VALUES (?, ?, ?, ?, ?)'is the database command itself.INSERT INTOmeans "add a new row".partners.useris the table (think of a spreadsheet) that holds partner accounts. The names in brackets are the columns: the row's identifier, the site it belongs to, the name, the email and the avatar. The question marks are placeholders where the actual values get filled in.with params [283, 411571, ...]shows those values. The third one is the long name the researcher typed, full of repeated letters. The fourth is the account email, and the fifth is the Gravatar picture address.SQLSTATE[22001]: String data, right truncatedis the database's own error code for "the text you gave me is too long for this column".value too long for type character varying(64)says the column only accepts up to 64 characters.
The message exposes the table and column list (partners.user with id, site_id, name, email, avatar), the parameter values, and the database error for a character varying(64) column. PostgreSQL is a popular database program; character varying(64) is its way of saying "text, maximum 64 characters".
The researcher considered whether the reflected error could be turned into XSS. Reflected means the value you sent comes straight back in the page. But he notes that this would only be Self XSS: the code would run only in your own browser, because you are the one who typed it. It is like writing a prank note to yourself. To make it dangerous to other people, the malicious text has to be stored on the server and shown to them later, which is called Stored XSS. He tried to find CSRF in the name field to upgrade it to Stored XSS, and failed. CSRF, cross-site request forgery, is a trick where another website makes your browser send a request to the target site without you meaning to, using the fact that your browser is already logged in.
Two days later the hidden user panel at partners.site.com/admin was found, where details could be changed. It also offered a logo upload, which is where the real issues were.
Exploitation
Step 1: SVG upload for XSS
The first idea on seeing the logo upload was to upload an SVG file. SVG stands for Scalable Vector Graphics: a picture format written as text, a bit like a page of instructions describing shapes. Because it is text and can contain a <script> element, a browser that opens an SVG may run the script inside it. A comparison: a normal photo is a printed picture, while an SVG is a recipe for drawing the picture, and this particular recipe can include a step that says "now run this program".
The SVG uploaded successfully, and the researcher obtained XSS from a non-privileged user to anyone by uploading the SVG file. Non-privileged means the account was an ordinary partner account, not an administrator. So an ordinary user could upload an SVG that produced XSS.

This earned a $200 reward. The researcher then built an SVG payload aimed at Blind XSS to raise the severity. Blind XSS is XSS where you cannot see the result yourself: the payload fires later, in someone else's session, for example when a staff member opens an admin page that displays your uploaded file. You only learn it worked when your payload reports back to you.

Step 2: Extensionless image upload
About a week later the site was rechecked. Uploading the SVG again, and attempts at bypasses, no longer worked. A bypass here means a trick to get past a filter, such as changing the file name or its contents slightly so the check does not recognise it.
The researcher then uploaded an image without any extension. An extension is the part of a file name after the dot, like .jpg or .png, which tells the computer what kind of file it is. It was accepted, displayed as a normal image in the frontend, and when the full image was opened it was served as raw code with content-type: text/html.
Content-Type is a label the server attaches to every file it sends, telling the browser how to treat it. text/html means "this is a web page, render it and run any scripts in it". So a file that looked like a picture in the page was, when opened directly, treated by the browser as a web page.

Step 3: PHP upload for RCE
Uploading files with a PHP extension failed. PHP is a programming language commonly used to build websites; a file ending in .php is meant to be run by the server as a program, not shown to the visitor as text.
The researcher then applied the JPG shell uploading technique, referred to in the write-up as the Ninja Method. A "shell" in this context is a small program that lets an attacker run commands on the server. The trick is to hide that program inside an ordinary-looking image, then change the file name at the last moment so the server treats it as a program.
- Select an image (bind with PHP code) and click to upload.
- Capture the request with Burp Suite.
- Change the file name to
rce.php.
rce.php
Line by line:
- Step 1: you pick a normal image file, but its contents also include PHP code. The picture still looks like a picture, so a check that only glances at the start of the file may be satisfied.
- Step 2: Burp Suite holds the upload request before it reaches the server. A request is the message your browser sends when you submit a form; capturing it means pausing it so you can edit it.
- Step 3: in that paused request, the file name is changed from something like
photo.jpgtorce.php. The server now sees a file whose name says "run me as a program".
The write-up records the result as "BOOM!!!". This earned a $1000 reward for RCE by PHP file upload. RCE, remote code execution, means the attacker can make the server run their own code. It is the most severe class of web bug, because from there an attacker can often read files, change data or take over the machine.
Step 4: HTML file upload
About a month later a friend of the researcher found that HTML files could be uploaded to the same endpoint, and was rewarded $400 for it. An endpoint is a specific address on a server that accepts requests, in this case the upload handler. An HTML file is a web page; if the server stores it and serves it from its own address, that page can contain scripts and forms that look like they belong to the company.
Root cause
The upload endpoint validated the file poorly. The SVG was accepted and served in a way that let its script run, so the upload was not restricted to safe image types and the stored file was rendered as active content. Later, the same endpoint accepted a file with no extension and served it as content-type: text/html, showing that the content type returned to the browser was not tied to a safe, fixed value. Finally, renaming the uploaded file to rce.php was enough to get PHP code executed, which means the server executed files from the upload directory based on the extension in the client-supplied file name. Client-supplied means the name came from the person uploading, so it can be anything they choose.
The name field error is a separate weakness: an over-long value produced a full SQL exception with parameters in the response.
Impact
The SVG upload gave XSS from a non-privileged user to anyone who viewed the file. The extensionless upload showed that an uploaded file could be served as content-type: text/html. Phishing means tricking someone with a fake page that looks genuine. The PHP upload was rewarded as RCE by PHP file upload. The HTML upload found by the friend is a further variant on the same endpoint. The name field error disclosed the SQL statement, table and column names and the submitted values.
Fix
The write-up does not describe any fix applied by the company. Based on what was found, the upload endpoint should accept only an explicit allowlist of image types, verify content rather than trusting the client-supplied name, store uploads outside the web root or in a location where script execution is disabled, and serve them with a fixed, safe Content-Type and Content-Disposition. An allowlist is a list of things that are permitted, with everything else refused. The web root is the folder the web server serves pages from. Content-Disposition is a header that tells the browser whether to display a file or download it. The name length should be validated in the application before the insert, and database errors should not be returned to the client.
Variants to test
- Upload an SVG containing a script element to any logo or avatar field. A positive result is the script running when the file is viewed, either directly or by another user.
- Upload an image with no extension and open the full image. A positive result is the file being served as
content-type: text/htmlwith the raw content rendered. - Upload an image whose content contains PHP code, capture the request, and rename the file to
rce.php. A positive result is the upload being accepted and the code executing when the file is requested. - Upload an HTML file to the same endpoint. A positive result is the file being stored and served as HTML.
- Submit a name longer than the column limit in profile fields. A positive result is a database exception in the response that includes the SQL statement and parameters.
Glossary
- XSS (cross-site scripting): getting your own code to run inside someone else's web page in a victim's browser.
- Self XSS: XSS that only affects the person who typed the payload, because it runs in their own browser.
- Stored XSS: XSS where the malicious text is saved on the server and shown to other people later.
- Blind XSS: XSS where you cannot see the result yourself; the payload fires later in someone else's session and reports back to you.
- CSRF (cross-site request forgery): a trick where another website makes your browser send a request to the target site without you meaning to, using your existing login.
- RCE (remote code execution): making a server run code of your choosing; the most severe class of web bug.
- Information disclosure: a site revealing something it should keep private, such as an internal error message.
- Sub-domain: a section of a larger website with its own address, like
partners.site.comundersite.com. - Endpoint: a specific address on a server that accepts requests, such as an upload handler.
- Request: the message a browser sends to a server when you submit a form or open a page.
- Burp Suite: a program that sits between your browser and a website so you can see and edit requests before they are sent.
- SQL: the language used to talk to a database.
- Database: the organised store where a website keeps its data, such as users and posts.
- Table and column: a table is like a spreadsheet of records; a column is one field in it, such as
name. - PostgreSQL: a popular database program.
character varying(64): PostgreSQL's way of saying "text, maximum 64 characters".INSERT INTO: the database command that adds a new row to a table.- Parameter: a value filled into a placeholder in a database command.
- SVG (Scalable Vector Graphics): a picture format written as text, which can contain a script element.
- Extension: the part of a file name after the dot, like
.jpg, which hints at the file type. - PHP: a programming language commonly used to build websites;
.phpfiles are meant to be run by the server. - Shell: a small program that lets an attacker run commands on a server.
Content-Type: a label the server attaches to a file telling the browser how to treat it, such astext/htmlfor a web page.Content-Disposition: a header telling the browser whether to display a file or download it.- HTML: the language web pages are written in.
- Client-supplied: a value that comes from the person using the site, so it can be anything they choose.
- Allowlist: a list of things that are permitted, with everything else refused.
- Web root: the folder a web server serves pages from.
- Bypass: a trick to get past a filter, such as changing a file name or its contents slightly.
- Payload: the piece of code or data you send to trigger a bug.
- Phishing: tricking someone with a fake page that looks genuine.
- Gravatar: a service that shows a picture next to an email address.
- Non-privileged: an ordinary account, not an administrator.