Stored XSS on upload files leads to steal cookie
The file upload feature did not check the actual file format, so an attacker could rename an SVG file with an onload handler to a png, gif or bmp and send it in a conversation. When the victim opened the file, the script ran and could steal the victim's cookie.
- Triaged in 5 days
- Fixed in 3 months
- Disclosed after 4 months
Summary by the researcher
Attackers can trigger XSS by SVG files. Developers should attention to block SVG files or sanitize files before upload. This report has found by the following link : File Upload XSS
Thanks to Master of XSS : Rodolfo Assis
The report
Summary:
There isn't a check mechanism on file format in Inbox which an attacker can send an SVG file as other formats such as png, gif or bmp by rename and change file format leads XSS attack and steal victim cookies.
Steps To Reproduce:
You should create 2 accounts : First account for the attacker and second one for the victim.
The attacker in my scenario: [email protected] The victim in my scenario: [email protected]
- Please log in to the first account via this [link] (https://app.outpost.co/sign-in)
- From Inbox create New Conversation and attached following files (Attached on this report) and send These files are an SVG file which changes file format to png, bmp, gif If you want to see payload open file by notepad. you'll see payload like the following code :
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="2560.000000pt" height="1600.000000pt" viewBox="0 0 2560.000000 1600.000000"
preserveAspectRatio="xMidYMid meet" onload="alert(document.cookie)">
- Whenever victim clicks on each file, open a new tab and XSS attack occurs and steal the victim's cookie.
Supporting Material/References:
Browsers : Mozilla Firefox 71.0 Google Chrome 79.0.3945.88
- [attachment / reference]
For clarification, you can watch POC file (Attached on this report)
If you have any questions, let me know.
Best regards.
Impact
Attacker can send malicious files to victims and steals victim's cookie leads to account takeover.
Attachments
Context
Outpost is a product of Palo Alto Software, and the report concerns the Inbox feature of app.outpost.co. Inbox is where a user reads and sends conversations, and it lets the user attach files to a new conversation. The report shows that the file handling in Inbox did not check the real format of an uploaded file, which allowed an attacker to send an SVG document disguised as an image and have it executed as markup when the victim opened it.
The researcher credits the idea to a public write-up on file upload XSS by Brutelogic and to Rodolfo Assis.
Setup
Two accounts are needed, both on the same product:
- An attacker account, used to create the conversation and attach the malicious files.
- A victim account, used to open the attachments.
The researcher's own scenario used the attacker account [redacted] and the victim account [redacted]. The testing was done in Mozilla Firefox 71.0 and Google Chrome 79.0.3945.88.
The malicious files are SVG documents whose extension was changed to png, bmp and gif. The report attaches them, and the payload can be seen by opening any of them in Notepad.
Finding it
The researcher's summary is that Inbox has no check mechanism on file format. Because the format is not validated, an SVG file can be sent as another format such as png, gif or bmp simply by renaming it and changing the file format. When the victim opens such a file, the browser treats it as SVG markup and the script inside it runs, which lets the attacker steal the victim's cookie.
Exploitation
Step 1: log in as the attacker
Log in to the first account through the sign-in page:
https://app.outpost.co/sign-in
Step 2: create a conversation with the malicious attachments
From Inbox, create a New Conversation, attach the files and send it. The files are SVG documents whose format was changed to png, bmp and gif. Opening one in Notepad shows the payload:
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="2560.000000pt" height="1600.000000pt" viewBox="0 0 2560.000000 1600.000000"
preserveAspectRatio="xMidYMid meet" onload="alert(document.cookie)">
The onload attribute on the root <svg> element runs JavaScript as soon as the document is loaded. In the report the handler is alert(document.cookie), which displays the victim's cookies; the same position could hold code that sends them to the attacker.
Step 3: the victim opens the attachment
Whenever the victim clicks on each file, a new tab opens and the XSS attack occurs, stealing the victim's cookie. The report does not describe the response headers or the content type the server returned for the attachment.
Root cause
The design mistake is that uploaded files are not validated against their real format. A file whose name ends in png, bmp or gif is accepted, but its content is still an SVG document, and the browser renders it as such when the victim opens it in a new tab. Because SVG can carry script through attributes such as onload, the file becomes an execution vector rather than an image. The report does not describe any server-side or client-side defence that was present and failed; it states plainly that there is no check mechanism on file format in Inbox.
Impact
An attacker can send malicious files to victims and steal the victim's cookie, which the researcher says leads to account takeover. The attack requires the victim to click the attachment; the researcher tested it in the browsers listed above.
Fix
The researcher's recommendation is that developers should block SVG files or sanitise files before upload.
Variants to test
- Upload an SVG renamed to each image extension the product accepts (png, gif, bmp) and open it as the recipient. A positive result is a new tab that renders the SVG and runs the
onloadhandler. - Try other SVG script carriers, such as a
<script>element inside the SVG, and check whether they execute in the same viewer. - Test whether the same upload path is reachable from other features that accept attachments, and whether the file is served inline rather than as a download.
- Check whether the response content type follows the file extension or the actual content; a mismatch that still renders as SVG is the condition that makes this work.
Hunting notes
This kind of bug hides in features that accept attachments and then display them to another user: inboxes, messaging, support tickets and comment threads. During recon, look for upload endpoints that accept image extensions and for a viewer that opens attachments in a new tab. The signal is a file that is accepted under an image extension but whose content is markup. To show impact, the researcher used two accounts, sent the file from one to the other, and demonstrated that opening it as the recipient executes the payload and exposes document.cookie.
What happened, in plain words
Outpost is a product made by Palo Alto Software. The part of it involved here is called Inbox, at app.outpost.co. Inbox is the place where a user reads and sends conversations, and it lets the user attach files to a new conversation, much like attaching a photo to an email.
The researcher found that Inbox did not check what an uploaded file really was. It did not check the file format at all. So an attacker could take a document called an SVG, rename it so it looked like a picture (a .png, .bmp or .gif), and send it to someone. When that person clicked the attachment, the browser opened it in a new tab and ran a small piece of JavaScript hidden inside the file. That script could read the victim's cookie, which is the little piece of data a website stores in your browser to remember that you are logged in. With that cookie, an attacker can often act as the victim, which is called account takeover.
The researcher says the idea came from a public write-up on file upload XSS by Brutelogic, and credits Rodolfo Assis.
The setup: two accounts
To show the bug, you need two accounts on the same product:
- An attacker account, used to create the conversation and attach the malicious files.
- A victim account, used to open the attachments.
In the researcher's own test, the attacker account was [redacted] and the victim account was [redacted]. The testing was done in Mozilla Firefox 71.0 and Google Chrome 79.0.3945.88.
The malicious files are SVG documents whose extension was changed to png, bmp and gif. The report attaches them, and the payload can be seen by opening any of them in Notepad.
Finding it
The researcher's summary is that Inbox has no check mechanism on file format. Because the format is not validated, an SVG file can be sent as another format such as png, gif or bmp simply by renaming it and changing the file format. When the victim opens such a file, the browser treats it as SVG markup and the script inside it runs, which lets the attacker steal the victim's cookie.
Exploitation
Step 1: log in as the attacker
Log in to the first account through the sign-in page:
https://app.outpost.co/sign-in
This is just the normal login page. The attacker signs in with their own account, because the malicious conversation has to be created from a real, logged-in session, exactly as any ordinary user would send a message.
Step 2: create a conversation with the malicious attachments
From Inbox, create a New Conversation, attach the files and send it. The files are SVG documents whose format was changed to png, bmp and gif. Opening one in Notepad shows the payload:
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="2560.000000pt" height="1600.000000pt" viewBox="0 0 2560.000000 1600.000000"
preserveAspectRatio="xMidYMid meet" onload="alert(document.cookie)">
Line by line, in plain words:
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"opens an SVG document. SVG is a format for drawing pictures using text, and browsers understand it as a kind of web page, not just as an image. Thexmlnspart tells the browser which language the file is written in.width="2560.000000pt" height="1600.000000pt"sets the size of the drawing, in points.viewBox="0 0 2560.000000 1600.000000"defines the coordinate system used inside the drawing.preserveAspectRatio="xMidYMid meet"says how the drawing should be scaled to fit its box.onload="alert(document.cookie)"is the important part.onloadis an event attribute: the browser runs the code inside it as soon as the document has finished loading.alert(...)opens a pop-up box, anddocument.cookieis the browser's way of reading the cookies for the current site. So the pop-up shows the victim's cookies. In a real attack, the same position could hold code that sends the cookies to the attacker instead of showing them.
The onload attribute on the root <svg> element runs JavaScript as soon as the document is loaded. In the report the handler is alert(document.cookie), which displays the victim's cookies; the same position could hold code that sends them to the attacker.
Step 3: the victim opens the attachment
Whenever the victim clicks on each file, a new tab opens and the XSS attack occurs, stealing the victim's cookie. The report does not describe the response headers or the content type the server returned for the attachment.
Root cause
The design mistake is that uploaded files are not validated against their real format. A file whose name ends in png, bmp or gif is accepted, but its content is still an SVG document, and the browser renders it as such when the victim opens it in a new tab. Because SVG can carry script through attributes such as onload, the file becomes an execution vector rather than an image. The report does not describe any server-side or client-side defence that was present and failed; it states plainly that there is no check mechanism on file format in Inbox.
Impact
An attacker can send malicious files to victims and steal the victim's cookie, which the researcher says leads to account takeover. The attack requires the victim to click the attachment; the researcher tested it in the browsers listed above.
Fix
The researcher's recommendation is that developers should block SVG files or sanitise files before upload.
Variants to test
- Upload an SVG renamed to each image extension the product accepts (png, gif, bmp) and open it as the recipient. A positive result is a new tab that renders the SVG and runs the
onloadhandler. - Try other SVG script carriers, such as a
<script>element inside the SVG, and check whether they execute in the same viewer. - Test whether the same upload path is reachable from other features that accept attachments, and whether the file is served inline rather than as a download.
- Check whether the response content type follows the file extension or the actual content; a mismatch that still renders as SVG is the condition that makes this work.
Hunting notes
This kind of bug hides in features that accept attachments and then display them to another user: inboxes, messaging, support tickets and comment threads. During recon, look for upload endpoints that accept image extensions and for a viewer that opens attachments in a new tab. The signal is a file that is accepted under an image extension but whose content is markup. To show impact, the researcher used two accounts, sent the file from one to the other, and demonstrated that opening it as the recipient executes the payload and exposes document.cookie.
Glossary
- XSS (Cross-site Scripting): a bug where an attacker gets their own code to run inside another user's browser on a website they trust.
- Stored XSS: an XSS where the malicious content is saved on the server (for example as an uploaded file or a message) and runs later for whoever opens it.
- SVG: a picture format written as text, which browsers can render and which can contain script.
- Payload: the part of an attack that actually does the damage, here the code hidden in the file.
- Cookie: a small piece of data a website stores in your browser to remember you, often including your logged-in session.
- Session cookie: the cookie that proves you are logged in; stealing it can let an attacker act as you.
- Account takeover: when an attacker gains control of someone else's account.
- File extension: the part of a file name after the dot, such as
.png, which suggests what kind of file it is. - Content type: the label a server sends with a file to tell the browser what kind of content it is.
- Inline: displayed directly in the browser rather than downloaded as a file.
onload: an event attribute that tells the browser to run some code when a document has finished loading.document.cookie: the browser command that reads the cookies for the current page.- Notepad: a simple text editor on Windows, useful for looking at the raw text inside a file.
- Recon: the early phase of testing where you look around a product to find features worth testing.
- Endpoint: a specific address on a server that accepts requests, such as an upload or login URL.
- Sanitise: clean content so that dangerous parts, such as scripts, are removed or made harmless.
- Response headers: extra information a server sends back with a page or file, such as its content type.