Information leakage via CSV when content is valid JavaScript
The CSV export of bounty payments includes a user-controlled report title, and because script inclusions bypass the same-origin policy, an attacker could craft a title that turns the CSV into valid JavaScript and read the victim's payment data. The researcher notes the exploitation seems unlikely and purely theoretical.
Originally disclosed on HackerOne
- Triaged in 39 days
- Fixed in 54 days
- Paid in 3 months
- Disclosed after 3 months
Summary by the researcher
Write-up: https://blog.cm2.pw/h1-xssi/
The report
Summary: The function "Download as CSV" might leak information to 3rd domains. The exploitation seems unlikely and purely theoretical but it might work in some cases.
Description (Include Impact):
Take downloading payments as CSV, for example, which is recently launched. The response to
https://hackerone.com/settings/bounties.csv
returns CSV which is indeed, a comma separated values. There is a field which is influenced by user input i.e. report_title.
And, as we all know, script inclusions are exempt from SOP. So, if the returned CSV forms valid JavaScript, it's possible that we can read information.
Steps To Reproduce
For demonstration; I created an HTML page as follows;
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<script>
var report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status;
</script>
</head>
<body>
<script src='https://hackerone.com/settings/bounties.csv'></script>
</body>
</html>
And, edited returned response (using BurpSuite) as follows;
report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status
████████
████
█████████
████████
██████
████████
So, what I did is added =` right after first word of first report. Similarly added `// right after last word of last report.
This makes it a valid JavaScript, and XSS a valid variable which now have all details in it.
Optional: Your Environment (Browser version, Device, etc)
Firefox version 45.7.0 UA: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 Safari may also work.
Context
The target is HackerOne's own platform, and the feature under examination is Download as CSV, specifically the export of payments. The researcher uses the recently launched payments export as the example. The endpoint that serves it is:
https://hackerone.com/settings/bounties.csv
The response is a genuine comma separated values file. Among its columns is report_title, a field whose value is influenced by user input. That single user-controlled field is the whole basis of the issue: if the CSV body can be made to parse as valid JavaScript, a third-party page can include it with a script tag and read the values out of it.
Setup
The researcher demonstrates the issue in Firefox version 45.7.0 with the user agent:
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Burp Suite is used to intercept and edit the returned response. The researcher notes that Safari may also work. No special account or role is described beyond having access to the payments CSV export, which is a settings page tied to the user's own bounty payments.
Finding it
The observation is that the CSV export contains a field, report_title, that the user controls. Script inclusions are exempt from the same-origin policy, so a page on any domain can load the CSV as a script. The remaining question is whether the CSV body is syntactically valid JavaScript. If it is, the values in the file become readable to the including page.
The researcher is explicit about the limits: the exploitation seems unlikely and purely theoretical, but it might work in some cases.
Exploitation
Step 1: Build a page that includes the CSV as a script
The researcher creates an HTML page that declares the CSV column names as variables and then loads the export with a script tag:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<script>
var report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status;
</script>
</head>
<body>
<script src='https://hackerone.com/settings/bounties.csv'></script>
</body>
</html>
The first script block pre-declares the column names as variables. The second block pulls the CSV in as a script from the HackerOne origin. Because script inclusions are exempt from the same-origin policy, the browser will fetch and execute the response regardless of the page's own origin.
Step 2: Make the CSV parse as JavaScript
The researcher intercepts the response in Burp Suite and edits it. The edited body is shown with the values redacted:
report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status
████████
████
█████████
████████
██████
████████
Two edits are made. A = is inserted right after the first word of the first report, and // is inserted right after the last word of the last report. The result is valid JavaScript, and XSS becomes a valid variable holding all the details.
Root cause
The export reflects a user-controlled value, report_title, into a response that is served as CSV. Nothing in the design prevents that response from also being valid JavaScript. The defence that would normally apply, the same-origin policy, does not cover script inclusions, so a third-party page can load the file cross-origin. The researcher's demonstration relies on editing the response in Burp Suite to insert the = and // characters.
Impact
If the returned CSV forms valid JavaScript, a third-party page can read the information in it. The researcher frames the practical risk as low: the exploitation seems unlikely and purely theoretical, though it might work in some cases. The data at stake is the payments export, including the report title and the other columns listed above.
Fix
The report does not describe a fix or a change made in response.
Variants to test
- Other CSV or export endpoints that include a user-controlled field, such as a title or name. A positive result is a response whose body parses as JavaScript when loaded with a
scripttag from another origin. - Exports where the first row is a header line and the first data value can be shaped into an assignment. A positive result is the header and first value forming a valid assignment expression.
- Exports where the final value can be followed by a comment sequence. A positive result is the file ending without a syntax error.
- Browsers other than Firefox 45.7.0, since the researcher notes Safari may also work. A positive result is the same cross-origin read of the declared variables.
Hunting notes
During recon, look for endpoints that return text/csv or similar and check whether any column reflects input you control. The researcher built a page that loads the export cross-origin and pre-declares the column names as variables, then edited the response to show the file can be made valid JavaScript. The report itself is candid that the real-world exploitation is unlikely and theoretical.
What happened, in plain words
HackerOne is a platform where security researchers report bugs to companies and can earn money, called a bounty, for valid reports. The platform has a settings area where a researcher can download a list of the payments they have received. That download is offered as a CSV file, which is a plain text file where each line is a row and commas separate the columns, like a simple spreadsheet saved as text.
The researcher noticed that one of the columns in that CSV file, the report title, is text that the user themselves can write. They then asked a simple question: what happens if a completely different website loads this CSV file as if it were a piece of JavaScript code? Browsers normally stop one website from reading another website's data, but there is an exception for scripts, and this exception is the key to the whole idea. If the CSV file happens to be readable as valid JavaScript, then the other website can read the payment details out of it.
The researcher was honest that this is unlikely to work in practice and mostly theoretical. To prove the idea, they built a small test page, loaded the CSV into it as a script, and then used a tool called Burp Suite to edit the server's reply so that the file became valid JavaScript. The edited file then held all the payment details in a variable, which the test page could read.
The feature and the endpoint
The feature is called Download as CSV, and the specific example is the export of payments, which the researcher says had recently launched. The address that serves the file is:
https://hackerone.com/settings/bounties.csv
This is a URL, the address you type into a browser to reach a page or a file. The .csv ending tells you the server is expected to send back a comma separated values file rather than a web page. The response really is a genuine CSV file, and one of its columns is report_title, a field whose value comes from user input. That single user-controlled field is the entire basis of the issue: if the CSV body can be made to look like valid JavaScript, a third-party page can include it with a script tag and read the values out of it.
A useful comparison: imagine a shared noticeboard where anyone can write a line of text. Normally that is harmless because everyone reads it as text. But if a visitor's brain is wired to treat anything on the board as an instruction, then whoever writes on the board can give that visitor orders. Here the browser is the visitor, and the CSV file is the noticeboard.
The setup
The researcher demonstrates the issue in Firefox version 45.7.0, with this user agent string:
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
A user agent is a short line of text that a browser sends with every request to tell the server which browser and operating system it is. It is not a secret; it is just an identifier. The researcher also notes that Safari may work too.
Burp Suite is a tool that sits between your browser and a website and lets you pause, look at and change the traffic going in both directions. The researcher uses it to intercept and edit the returned response. No special account or role is described beyond having access to the payments CSV export, which is a settings page tied to the user's own bounty payments.
Finding it
The observation is that the CSV export contains a field, report_title, that the user controls. Script inclusions are exempt from the same-origin policy, so a page on any domain can load the CSV as a script. The remaining question is whether the CSV body is syntactically valid JavaScript. If it is, the values in the file become readable to the including page.
Two ideas need unpacking here.
- The same-origin policy. This is a rule built into browsers. A web page from one site is not allowed to read data from another site, because otherwise any page you visit could quietly read your email or your bank details. Two pages count as the same origin when they share the same scheme (http or https), the same host name and the same port. Anything else is a different origin, and reading across origins is blocked.
- The script exception. The same-origin policy has a deliberate hole: a page is allowed to load a script file from any other site. That is how websites use shared libraries hosted elsewhere. The browser fetches the file and runs it, and the rule that normally stops cross-site reading does not apply to this kind of inclusion.
Put those two together and you get the idea behind the bug. If a file that contains private data can also be loaded as a script, the script exception lets another site pull it in. The only remaining obstacle is whether the file's contents make sense as JavaScript. A CSV file is just text with commas, so normally it would cause a syntax error and nothing would happen. The researcher's question was whether the user-controlled title could tip the file into being valid code.
The researcher is explicit about the limits: the exploitation seems unlikely and purely theoretical, but it might work in some cases.
Exploitation
Step 1: Build a page that includes the CSV as a script
The researcher creates an HTML page that declares the CSV column names as variables and then loads the export with a script tag:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<script>
var report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status;
</script>
</head>
<body>
<script src='https://hackerone.com/settings/bounties.csv'></script>
</body>
</html>
Line by line, in plain words:
<!DOCTYPE html>tells the browser this is a modern HTML page.<html>opens the page, and<head>is the section for information about the page rather than visible content.<meta charset='utf-8'/>says the page uses the UTF-8 character encoding, which covers most of the world's writing systems.- The first
<script>block contains a single line:var report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status;. The wordvardeclares variables, which are named storage slots in JavaScript. This line creates nine empty slots, one for each column name in the CSV. The reason for doing this first is that the CSV file, when loaded as a script, will assign values to these names. If the names did not exist beforehand, the assignment would still work in most cases, but declaring them makes the intent clear and keeps the names in one place. </script>closes that block, and</head>closes the head section.<body>opens the visible part of the page. It is empty here because the page is only a test harness, not something a person is meant to look at.<script src='https://hackerone.com/settings/bounties.csv'></script>is the important line. Thesrcattribute tells the browser to fetch a file from that address and run it as JavaScript. Because script inclusions are exempt from the same-origin policy, the browser will fetch and execute the response regardless of the page's own origin. In other words, even if this test page lives on a completely different site, the browser will still go and get the HackerOne file and run it.</body>and</html>close the page.
The reason for this step is to create the exact situation the researcher wants to test: a page from one origin loading a data file from another origin as code. If the file runs without error, the variables declared in the first block will hold the values from the file.
Step 2: Make the CSV parse as JavaScript
The researcher intercepts the response in Burp Suite and edits it. The edited body is shown with the values redacted:
report_id,report_title,program_name,total_amount,amount,bonus_amount,currency,awarded_at,status
████████
████
█████████
████████
██████
████████
The first line is the header row of the CSV: the names of the columns, separated by commas. The lines below it are the data rows, with the actual values replaced by blocks so that private payment information is not published. Each row in a real export would contain the report identifier, the report title, the program name, the total amount, the amount, any bonus amount, the currency, the date it was awarded and the status.
Two edits are made. A = is inserted right after the first word of the first report, and // is inserted right after the last word of the last report. The result is valid JavaScript, and XSS becomes a valid variable holding all the details.
Why those two characters? In JavaScript, a single = means "put the value on the right into the name on the left". So if the file begins with a name followed by =, the browser treats the rest as a value to store. The // sequence means "ignore everything after this on the line", which is how programmers leave notes in code. By putting it at the very end, the researcher makes sure the file does not end in the middle of an expression, which would be a syntax error and would stop everything.
A comparison: a CSV file is like a shopping list. On its own it is just a list. Add an equals sign in the right place and it becomes an instruction, "put this list into this box". Add a comment marker at the end and you tell the reader to stop reading there, so nothing after it can cause confusion.
Root cause
The export reflects a user-controlled value, report_title, into a response that is served as CSV. Nothing in the design prevents that response from also being valid JavaScript. The defence that would normally apply, the same-origin policy, does not cover script inclusions, so a third-party page can load the file cross-origin. The researcher's demonstration relies on editing the response in Burp Suite to insert the = and // characters.
In simpler terms: the bug is not that the site hands out a CSV file. The bug is that the site hands out a file whose contents partly come from the user, and it does not take any step to make sure that file cannot be read as code by another site. The researcher proved the concept by editing the file by hand, which shows the idea is possible, but not that an attacker could achieve the same result through the normal interface.
Impact
If the returned CSV forms valid JavaScript, a third-party page can read the information in it. The researcher frames the practical risk as low: the exploitation seems unlikely and purely theoretical, though it might work in some cases. The data at stake is the payments export, including the report title and the other columns listed above.
The researcher is clear that this chain is not demonstrated.
Fix
The report does not describe a fix or a change made in response.
Variants to test
- Other CSV or export endpoints that include a user-controlled field, such as a title or name. A positive result is a response whose body parses as JavaScript when loaded with a
scripttag from another origin. - Exports where the first row is a header line and the first data value can be shaped into an assignment. A positive result is the header and first value forming a valid assignment expression.
- Exports where the final value can be followed by a comment sequence. A positive result is the file ending without a syntax error.
- Browsers other than Firefox 45.7.0, since the researcher notes Safari may also work. A positive result is the same cross-origin read of the declared variables.
Hunting notes
During recon, look for endpoints that return text/csv or similar and check whether any column reflects input you control. The researcher built a page that loads the export cross-origin and pre-declares the column names as variables, then edited the response to show the file can be made valid JavaScript. The report itself is candid that the real-world exploitation is unlikely and theoretical.
Glossary
- API: a defined way for one piece of software to ask another for data or actions, like a waiter taking your order to the kitchen.
- Bounty: a reward, usually money, paid by a company to a researcher who reports a valid security bug.
- Browser: the program you use to visit websites, such as Firefox or Safari.
- Burp Suite: a tool that sits between your browser and a website so you can inspect and change the requests and responses.
- Column: a vertical field in a table or CSV file, such as the report title column.
- Comma separated values (CSV): a plain text file format where each line is a row and commas separate the columns.
- Cross-origin: belonging to a different scheme, host or port than the page you are on.
- Endpoint: a specific address on a server that accepts requests, such as the URL that serves the CSV export.
- Field: a single named piece of data, such as
report_title. - Firefox: a web browser made by Mozilla.
- Header row: the first line of a CSV file that names the columns.
- HTML: the language used to describe the structure of a web page.
- JavaScript: the programming language that browsers run to make web pages interactive.
- Origin: the combination of scheme, host and port that identifies where a page came from.
- Parameter: a named value sent with a request, often in the URL or the body.
- Payload: the piece of input an attacker uses to trigger a bug.
- Recon: short for reconnaissance, the early phase of looking around a target to find interesting features and endpoints.
- Response: what a server sends back after a request.
- Same-origin policy: the browser rule that stops one site from reading another site's data.
- Safari: a web browser made by Apple.
- Script: a piece of JavaScript that a page loads and runs.
- Script inclusion: loading a script file from another address with a
scripttag. - Settings page: an area of a website where a logged-in user manages their own account details.
- Syntax error: a mistake in code that stops it from being understood and run.
- User agent: a short line of text a browser sends to identify itself and its operating system.
- User input: any text a person types into a website.
- Variable: a named storage slot in a program that holds a value.
- XSS: cross-site scripting, a class of bug where an attacker gets their own code to run in another person's browser.