Penetrating Pornhub XSS vulns
Two reflected cross-site scripting vulnerabilities were found on the PornHub Premium website: one in the redeem code input and one in a URL parameter shown to new users. An attacker could execute arbitrary scripts in a victim's browser, potentially accessing cookies and session tokens.
Published on jonbottarini.com
When the adult website PornHub launched their public bug bounty program, I was pretty sure that most of the low hanging fruits of vulnerabilities would be taken care of and already reported. When I first started poking around, I found my first vulnerability in less than 15 minutes.
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 launched a public bug bounty program, and this write-up covers two reflected cross-site scripting (XSS) vulnerabilities found on the PornHub Premium website. The first sits in the "redeem code" section, where a user enters a code into a text input. The second sits in a URL parameter that is added when a new visitor passes through the site's age and content compliance pop-up.
XSS, as the report describes it, lets an attacker run scripts on a website. The report quotes OWASP's summary:
An attacker can use XSS to send a malicious script to an unsuspecting user. The end user's browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page.
Both bugs were reflected XSS. Both were reported to PornHub, triaged within 24 hours, and have since been fixed. The researcher received two payments of $250 and a T-shirt with stickers.
Setup
The report does not describe any special tooling, accounts or paid access. The researcher browsed the PornHub Premium site, which is mostly off-limits unless you pay to access it. The key precondition for the second bug was a fresh session: the researcher used incognito windows so the site treated each visit as a first-time visitor. No versions, headers or authentication details are given.
Finding it
The researcher expected most of the low-hanging fruit to be gone once a public program launched, but found the first vulnerability in less than 15 minutes and the second a few minutes later, both within about 20 minutes of browsing the Premium site.
The first looked wrong because the redeem code input did not check whether the value entered was an actual payload before reflecting it on the page. The second was tied to the compliance pop-up: before a visitor can pay, a pop-up tells them they are about to view pornography and offers buttons to enter or exit. After clicking "enter", part of the URL changed and a parameter was added. That parameter, &compliancePop=no_gateway, was the injection point. The researcher's reasoning is that this parameter only appears once, to new users, which is likely why it had not been found: most hunters explore a site before trying to break it, whereas the researcher deliberately used incognito windows to look like a first-time visitor.
Exploitation
Step 1: Redeem code reflected XSS
The redeem code input reflected the entered value without validating it as a payload. The following payload reflected the script on the page:
PAYLOAD+STACK++%3E%27" /Autof<K>ocus /O<K>nfocus=confirm`1`//&error=1
The leading "PAYLOAD STACK" text is there to get the rest of the payload through. Entering the payload without that prefix was rejected by the application and nothing appeared on the page:
++%3E%27" /Autof<K>ocus /O<K>nfocus=confirm`1`//&error=1
Starting with something non-malicious tricked the validator, which in turn allowed the payload to execute. The <K> characters inside the attribute names are part of the payload as written; the report does not explain them further.
Step 2: Compliance pop-up parameter reflected XSS
The second bug was simpler. After clicking "enter" on the compliance pop-up, the URL gained the &compliancePop=no_gateway parameter. Entering the following into that parameter produced a "1" on the screen, evidence of cross-site scripting:
&compliancePop=no_gateway%22-confirm`1`-%22
The %22 sequences are encoded double quotes, and the confirm call is what renders the "1" dialog.
Root cause
Both issues are reflected XSS: user input is echoed back into the page without being treated as untrusted. In the redeem code case, the input was reflected without checking whether it was an actual payload, and a validator that rejected the bare payload could be bypassed by prefixing harmless text. In the compliance pop-up case, the value of the compliancePop parameter was reflected into the page.
Impact
The report frames the impact in the general terms of the OWASP quote: an attacker can send a malicious script to an unsuspecting user, the browser executes it because it believes it came from a trusted source, and the script can access cookies, session tokens and other sensitive information retained by the browser, and can rewrite the page content. The vulnerable parameter appears only once, to new users.
Fix
The report states only that both vulnerabilities have now been fixed.
Variants to test
- Redeem or coupon inputs. Submit a harmless prefix followed by an attribute-breaking payload, as in the first payload above. A positive result is a reflected script or a
confirmdialog firing from the input value. - First-visit-only parameters. Open the target in a fresh incognito window, pass through any age or compliance gate, and note parameters added to the URL. Inject into each one. A positive result is a reflected dialog or script that only appears on a first visit.
- Validator bypass by prefixing. Where a bare payload is rejected, prepend benign text and resend. A positive result is the same payload now being reflected and executed.
- Gate and pop-up flows. Walk through consent, age and region gates and test every parameter they add to the URL. A positive result is reflected input in the gate's response page.
What happened, in plain words
A security researcher found two cross-site scripting (XSS) bugs on the PornHub Premium website within about 20 minutes of looking. He reported both to PornHub, which fixed them and paid him $250 for each, plus a T-shirt and stickers. The first bug was in the "redeem code" box. The second was in a web address parameter that only appears the first time someone visits the site, after they click through an age and content warning pop-up.
This article explains what that means from scratch, so you can follow along even if you have never done security testing. It covers the same steps, payloads and reasoning as the original write-up, but in plain language.
Background: what is a bug bounty, and what is XSS?
A bug bounty program is a deal a company makes with independent researchers: if you find a security problem in our systems and report it responsibly, we will pay you a reward (a "bounty") and fix it. PornHub launched a public bug bounty program, and the researcher decided to look at their Premium site, which is mostly off-limits unless you pay to access it.
Cross-site scripting (XSS) is a type of vulnerability where a website takes something a user typed (or something in the web address) and puts it back into the page without making it safe. The browser then treats that text as part of the website's own code and runs it. The report quotes OWASP's summary:
An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page.
In everyday terms: imagine a noticeboard where anyone can pin a note. If the board owner copies whatever you write onto official letterhead without checking it, you could write "Give this person the keys to the building" and it would look official. XSS is the digital version: the website repeats your input as if it were its own trusted instructions, and the browser obeys.
Both bugs here are reflected XSS. That means the malicious input is not stored on the server; it is "reflected" back immediately in the response to the same request. Think of a mirror: you say something, and it comes right back at you. If you can trick someone else into making that request (for example, by sending them a link), the script runs in their browser.
Setup: what you need
The report does not describe any special tools, accounts or paid access. The researcher simply browsed the PornHub Premium site. The key precondition for the second bug was a fresh session: he used incognito windows so the site treated each visit as a first-time visitor. No versions, headers or login details are given.
Incognito window: a private browsing mode that starts with no cookies or history from your normal browsing, so the website sees you as a brand-new visitor. Cookie: a small piece of data a website stores in your browser to remember you between pages, like a coat-check ticket. Session token: a secret value, often stored in a cookie, that proves you are logged in; if someone steals it, they can act as you.
Finding it
The researcher expected that most of the easy bugs ("low-hanging fruit") would already be taken once a public program launched. Instead, he found the first vulnerability in less than 15 minutes and the second a few minutes later, both within about 20 minutes of browsing the Premium site.
The first looked wrong because the redeem code input did not check whether the value entered was an actual payload before reflecting it on the page. In other words, the box accepted whatever you typed and echoed it back into the page's HTML without sanitising it.
The second was tied to the compliance pop-up. Before a visitor can pay, a pop-up tells them they are about to view pornography and offers buttons to enter or exit. After clicking "enter", part of the URL changed and a parameter was added. That parameter, &compliancePop=no_gateway, was the injection point. The researcher's reasoning is that this parameter only appears once, to new users, which is likely why it had not been found: most bug hunters explore a site before trying to break it, whereas the researcher deliberately used incognito windows to look like a first-time visitor.
URL parameter: the part of a web address after a question mark, made of name=value pairs, like ?colour=blue&size=large. Websites often use them to pass information between pages. Injection point: any place where user-supplied input goes into the page or a system, and where an attacker might sneak in code.
Exploitation
Step 1: Redeem code reflected XSS
The redeem code input reflected the entered value without validating it as a payload. The following payload reflected the script on the page:
PAYLOAD+STACK++%3E%27" /Autof<K>ocus /O<K>nfocus=confirm`1`//&error=1
Let us break this down piece by piece. The string is written in a form that would be sent in a web request, so some characters are percent-encoded (for example, %3E is >, %27 is ', and %22 is "). The + signs often represent spaces in this context. The leading PAYLOAD+STACK is not part of the attack itself; it is a harmless prefix. The rest, after decoding, contains characters like >, ', ", and an HTML attribute Autofocus (written with a <K> inserted, which the report does not explain further) and Onfocus=confirm1. `confirm`1 is a JavaScript command that shows a pop-up dialog with the number 1; if you see that dialog, you know your script ran.
The leading "PAYLOAD STACK" text is there to get the rest of the payload through. Entering the payload without that prefix was rejected by the application and nothing appeared on the page:
++%3E%27" /Autof<K>ocus /O<K>nfocus=confirm`1`//&error=1
Starting with something non-malicious tricked the validator, which in turn allowed the payload to execute. Validator: a check the website runs on input, for example to reject characters it thinks are dangerous. The application rejected the bare payload but accepted it when it began with harmless text.
Step 2: Compliance pop-up parameter reflected XSS
The second bug was simpler. After clicking "enter" on the compliance pop-up, the URL gained the &compliancePop=no_gateway parameter. Entering the following into that parameter produced a "1" on the screen, evidence of cross-site scripting:
&compliancePop=no_gateway%22-confirm`1`-%22
Here, %22 is an encoded double quote (").
Root cause
Both issues are reflected XSS: user input is echoed back into the page without being treated as untrusted. In the redeem code case, the input was reflected without checking whether it was an actual payload, and a validator that rejected the bare payload could be bypassed by prefixing harmless text. In the compliance pop-up case, the value of the compliancePop parameter was reflected into the page.
Impact
The report frames the impact in the general terms of the OWASP quote: an attacker can send a malicious script to an unsuspecting user, the browser executes it because it believes it came from a trusted source, and the script can access cookies, session tokens and other sensitive information retained by the browser, and can rewrite the page content. The vulnerable parameter appears only once, to new users.
Fix
The report states only that both vulnerabilities have now been fixed.
Variants to test
If you want to look for similar bugs yourself, here are the patterns to try, based on what the researcher did:
- Redeem or coupon inputs. Submit a harmless prefix followed by an attribute-breaking payload, as in the first payload above. A positive result is a reflected script or a
confirmdialog firing from the input value. - First-visit-only parameters. Open the target in a fresh incognito window, pass through any age or compliance gate, and note parameters added to the URL. Inject into each one. A positive result is a reflected dialog or script that only appears on a first visit.
- Validator bypass by prefixing. Where a bare payload is rejected, prepend benign text and resend. A positive result is the same payload now being reflected and executed.
- Gate and pop-up flows. Walk through consent, age and region gates and test every parameter they add to the URL. A positive result is reflected input in the gate's response page.
Glossary
- Bug bounty program: a scheme where a company pays independent researchers for finding and reporting security vulnerabilities.
- Cross-site scripting (XSS): a vulnerability where a website inserts user input into a page without making it safe, so the browser runs it as code.
- Reflected XSS: an XSS where the malicious input is immediately returned in the response to the same request, rather than stored on the server.
- Payload: the piece of code or input designed to exploit a vulnerability.
- URL parameter: a name=value pair in a web address after the question mark, used to pass data to the site.
- Injection point: any place where user input enters a system and could be abused to insert code.
- Validator: a check that inspects input and may reject certain characters or patterns.
- Incognito window: a private browsing mode that starts without existing cookies or history, making the site see you as a new visitor.
- Cookie: a small piece of data stored by the browser for a website, often used to remember you or keep you logged in.
- Session token: a secret value, often in a cookie, that proves your identity to the site; stealing it can let an attacker impersonate you.
- Percent-encoding: a way to represent special characters in a URL using % followed by two hex digits (e.g. %22 for a double quote).
- HTML attribute: extra information inside an HTML tag, such as
autofocusoronfocus, which can trigger behaviour. - Event handler: code that runs in response to a browser event, like an element gaining focus (
onfocus). confirm: a JavaScript function that shows a pop-up dialog with a message and OK/Cancel buttons; here used to prove script execution.- OWASP: a non-profit organisation that publishes information about web application security, including the quote used in the report.
- Triage: the process of reviewing a reported vulnerability to confirm it is valid and assess its severity.