Skip to content
CSRF Write-up Beginner

How “Cancel” Button deletes entire business: Discovering a CSRF and Confirmation Logic Flaw

The business deletion endpoint accepted requests even when the CSRF token was removed, and the confirmation page deleted the business even when the user chose Cancel. An attacker could trick a logged-in victim into deleting their business without consent.

Ankit Rathva aka Gujarati Hacker Follow

Published on medium.com

Hackerone

Ankit Rathva aka Gujarati Hacker, 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 was a web application with business management functionality. The feature in question is the deletion of a business: a destructive action that, in the normal workflow, is triggered from the business settings and passes through a confirmation step. The legitimate deletion request was a POST to a confirmation-related endpoint and carried a CSRF token, which at first sight suggested the application was protected against Cross-Site Request Forgery.

The researcher is Ankit Rathva aka Gujarati Hacker, who describes himself as an MCA second-year student, ethical hacker and security researcher focused on logic, authorization and data-integrity flaws, working as a bug bounty hunter and red teamer.

Setup

The report does not describe any specific accounts, roles, tools or versions. The testing was done against the business settings of the application, using the normal deletion workflow as the starting point and then modifying the request.

Finding it

While testing the business settings, the researcher noticed the functionality for deleting a business. The normal deletion workflow sent a POST request to a confirmation-related endpoint, and the legitimate request included a CSRF token. Conceptually, the request looked like this:

HTTP
POST /business/confirm_delete_business

The presence of a CSRF token is good practice, but it raises the question the researcher asked: does the server actually validate the token? Including a token in a form does not provide protection if the backend does not properly verify it.

After triggering the deletion workflow, the application displayed a confirmation interface with two choices:

  • Cancel
  • Delete Business

The expected behaviour is simple:

User Action Expected Result
Cancel No deletion
Delete Business Business is deleted

During testing, the researcher observed something different: after selecting Cancel, the business was still deleted. This indicated that the confirmation mechanism might not have been correctly controlling the destructive operation. The application appeared to offer a confirmation choice, but the server-side workflow did not properly respect that choice.

Exploitation

Step 1: Capture the legitimate deletion request

The researcher triggered the normal deletion workflow from the business settings. The request was a POST to a confirmation-related endpoint and included a CSRF token:

HTTP
POST /business/confirm_delete_business

At this point the application looked protected, because the token was present in the request.

Step 2: Remove the CSRF token

By analysing the deletion workflow, the researcher found that the request could reach the deletion process even when the CSRF token was removed. In other words, the request could reach the deletion process even when the CSRF token was removed.

Step 3: Test the confirmation choices

The application then displayed the confirmation interface with the two options, Cancel and Delete Business. Selecting Cancel still resulted in the business being deleted. The destructive action happened regardless of the user's choice.

Step 4: Combine the two behaviours

With the token check ineffective and the confirmation choice not enforced server-side, the deletion workflow could be reached without effective validation. The report presents this as a CSRF and confirmation logic flaw: the deletion workflow could be reached without effective validation, and selecting Cancel still deleted the business.

Root cause

The report draws two lessons from the behaviour:

  1. The CSRF token was not validated. The token was present in the legitimate request, but the request could reach the deletion process even when it was removed. A token in a form provides no protection if the server does not check it.
  2. The confirmation was not enforced server-side. The confirmation page provided a visual interface, but selecting Cancel still deleted the business. The expected flow is:
Text
User requests deletion        ↓Server displays confirmation        ↓User explicitly confirms        ↓Server validates confirmation        ↓Deletion occurs

The destructive action should not happen before the final confirmation is validated. In this case, selecting Cancel still deleted the business, which indicated the confirmation mechanism might not have been correctly controlling the destructive operation. The expected logic should be:

Text
If user confirms:    Perform deletion
Text
If user cancels:    Do not perform deletion

Impact

If successfully exploited against an authenticated victim, this type of issue could potentially lead to unauthorised deletion of a business. Depending on the application's functionality, the consequences could include:

  • Loss of business configuration
  • Loss of associated resources
  • Operational disruption
  • Disruption of customer-facing functionality
  • Unauthorised destructive actions

The exact severity would depend on the application's environment and the amount of data or functionality affected. The report does not give a severity rating, CVSS score or bounty amount.

Fix

The lessons it draws are:

  1. Never trust the presence of a CSRF token. The backend must verify that the token is present, valid, associated with the correct session and not expired where applicable.
  2. Enforce confirmation server-side. The server should only perform the destructive action after receiving a valid and explicit confirmation, not merely after displaying a confirmation page.
  3. Make Cancel actually cancel. A cancellation option should terminate the workflow, and any destructive operation occurring after a cancellation should be carefully investigated.
  4. Test the entire workflow. Security testing should not stop after discovering a missing or bypassable token. Test the initial request, the server response, the confirmation page, the cancel action, the confirm action and the final application state, because the most significant vulnerability is sometimes hidden in the interaction between multiple steps.

Variants to test

  • Token removal on other destructive endpoints. Remove the CSRF token from other destructive requests and check whether the action still succeeds. A positive result is that the action still succeeds without a valid token.
  • Token from another session.
  • Expired or reused tokens.
  • Cancel path on other confirmation flows. Submit the cancel choice and then check the final application state. A positive result is that the destructive action happened anyway.
  • Direct call to the confirmation endpoint.
  • Method and parameter tampering.

The overarching question to ask on each target is the one the researcher closes with: what happens if I change this? Never assume a security control works just because it appears in the interface or request; always verify what the server actually enforces.

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. 13 min read.

What happened, in plain words

A security researcher was testing a website that lets people manage a business online. Think of it as a control panel for a company: you log in, and you can change settings, add people, and so on. One of the things you can do there is delete the whole business. That is a destructive action: it removes the business.

Normally, a website protects an action like that in two ways. First, it asks "are you sure?" on a confirmation screen, with a Cancel button and a Delete button. Second, it uses a hidden security code, called a CSRF token, to make sure the request really came from the site's own pages and not from some other website that the user happened to visit.

On this application, both protections looked present. The deletion request carried a token, and the confirmation screen appeared. But when the researcher tested further, two things turned out to be wrong. The request could still reach the deletion process when the token was removed. And when the researcher clicked Cancel on the confirmation screen, the business was deleted anyway.

So the confirmation screen did not stop the deletion: selecting Cancel still deleted the business. The researcher wrote this up as a CSRF and confirmation logic flaw: a combination of a missing token check and a confirmation step that the server did not enforce.

Who did the testing

The researcher is Ankit Rathva aka Gujarati Hacker. He describes himself as an MCA second-year student, an ethical hacker and security researcher who looks for logic, authorization and data-integrity flaws in web applications, and who works as a bug bounty hunter and red teamer. A bug bounty hunter is someone who tests websites, often with the owner's permission, and reports problems in exchange for a reward. A red teamer is someone who attacks a company's own systems on purpose, to find weaknesses before real attackers do.

From the original on medium.com

The image is the author's profile picture, shown next to his short introduction and his LinkedIn link.

What CSRF means, from zero

CSRF stands for Cross-Site Request Forgery. To understand it, you need to know how a website knows who you are.

When you log in to a website, the site gives your browser a small piece of data called a cookie. Your browser stores it and sends it back with every request you make to that site. The cookie is like a wristband you get at an event: the staff see the wristband and let you in without asking for your ID again. The website sees the cookie and knows the request comes from you, already logged in.

The problem is that your browser sends that wristband automatically, to the right site, even when the request was started by a different website. So if you are logged in to your business panel in one tab, and you open a malicious page in another tab, that page can quietly make your browser send a request to the business panel. Your browser attaches your cookie, and the panel thinks the request is from you.

That is CSRF: an attacker tricks your browser into sending a request you never intended, to a site where you are already logged in. The researcher lists the steps of such an attack:

  1. A victim is logged into a website.
  2. The victim visits an attacker-controlled webpage.
  3. The malicious webpage sends a request to the target application.
  4. The victim's browser may include their authentication cookies.
  5. If the application does not properly verify the request, an unwanted action may be performed.

CSRF becomes serious when the action is destructive. The researcher lists examples: changing account details, changing an email address, adding users, modifying permissions, deleting data, and deleting an account or business.

The feature under test

While testing the application's business settings, the researcher found the functionality for deleting a business. The normal workflow sent a POST request to a confirmation-related endpoint. A POST request is one of the ways a browser talks to a server: it is used when you submit a form or ask the server to change something, as opposed to simply loading a page. An endpoint is a specific address on the server that handles one kind of request, like a specific counter in a large office. The endpoint here was called confirm_delete_business, which suggests it is the step that handles the confirmation of a deletion.

The legitimate request included a CSRF token. A CSRF token is a secret, random value that the site puts into its own pages and expects back when a form is submitted. The idea is that another website cannot know this value, so a request coming from elsewhere will not have it, and the server can reject it. It is like a cloakroom ticket: only the person holding the matching ticket gets the coat back.

Conceptually, the request looked like this:

HTTP
POST /business/confirm_delete_business

Line by line:

  • POST is the method, the type of request. It tells the server "I am sending data and asking you to do something", not just "give me a page".
  • /business/confirm_delete_business is the path, the address of the specific function on the server that handles the confirmation of a business deletion.

The presence of a CSRF token is good practice. But the researcher asked an important question: does the server actually validate the token? A token in a form is only useful if the server checks it. If the server ignores it, the token is decoration. The researcher put it plainly: simply including a token in a form does not provide protection if the backend does not properly verify it. The backend is the part of the application that runs on the server and makes the real decisions, as opposed to the front end, which is what you see in the browser.

The confirmation screen that did not confirm

After triggering the deletion workflow, the application displayed a confirmation interface. The user was given two choices:

  • Cancel
  • Delete Business

The expected behaviour is simple:

User Action Expected Result
Cancel No deletion
Delete Business Business is deleted

But during testing, the researcher saw something different. After selecting Cancel, the business was still deleted. This suggested that the confirmation mechanism was not correctly controlling the destructive operation. The application showed a choice to the user, but the server-side workflow did not respect that choice.

Think of it like a shop assistant who asks "do you want the expensive item or the cheap one?", and then charges you for the expensive one whichever you say. The question was asked, but the answer was ignored.

How the researcher tested it, step by step

Step 1: Capture the legitimate deletion request

The researcher started the normal deletion workflow from the business settings. The request was a POST to the confirmation-related endpoint and included a CSRF token:

HTTP
POST /business/confirm_delete_business

Line by line:

  • POST is the method: the browser is asking the server to perform an action.
  • /business/confirm_delete_business is the endpoint that handles the confirmation of the deletion.

At this point the application looked protected, because the token was present in the request. The researcher's reason for capturing this request first is the same reason a locksmith studies a real key before trying to copy it: you need to see exactly what a normal, working request looks like before you can change one thing at a time and see what the server really checks.

Step 2: Remove the CSRF token

By analysing the deletion workflow, the researcher found that the request could reach the deletion process even when the CSRF token was removed. In other words, the request could reach the deletion process even when the CSRF token was removed.

If the action still succeeds without the token, the check is not there, and the token was only there to look reassuring.

Step 3: Test the confirmation choices

The application then displayed the confirmation interface with the two options, Cancel and Delete Business. Selecting Cancel still resulted in the business being deleted. The destructive action happened regardless of the user's choice.

The researcher tested the Cancel path because that is the path where nothing should happen; if something happens there, the confirmation is not being enforced.

Step 4: Combine the two behaviours

With the token check ineffective and the confirmation choice not enforced server-side, the deletion workflow could be reached without effective validation. The researcher presents this as a CSRF and confirmation logic flaw: an attacker who can make an authenticated victim's browser send the request can reach the deletion process, and the confirmation step does not stop it.

The missing token check means a request from another website can get through. The broken confirmation means the victim's choice on the confirmation screen does not save them. The two together could potentially lead to unauthorised deletion of a business.

Why it happened

The report draws two lessons from the behaviour:

  1. The CSRF token was not validated. The token was present in the legitimate request, but the request could reach the deletion process even when it was removed. A token in a form provides no protection if the server does not check it. A session is the period during which the site remembers you as logged in; associating the token with the session means the token belongs to you specifically, not to anyone who happens to have one.
  2. The confirmation was not enforced server-side. The confirmation page provided a visual interface, but selecting Cancel still deleted the business. The expected flow is:
Text
User requests deletion        ↓Server displays confirmation        ↓User explicitly confirms        ↓Server validates confirmation        ↓Deletion occurs

Line by line, this is the order a safe deletion should follow:

  • User requests deletion: the user clicks the delete option in the business settings.
  • Server displays confirmation: the server shows the "are you sure?" screen.
  • User explicitly confirms: the user makes a clear choice to go ahead.
  • Server validates confirmation: the server checks that the confirmation is genuine and matches the request.
  • Deletion occurs: only now is the business actually deleted.

The destructive action should not happen before the final confirmation is validated. In this case, selecting Cancel still deleted the business, which indicated the confirmation mechanism might not have been correctly controlling the destructive operation. The expected logic should be:

Text
If user confirms:    Perform deletion

Line by line:

  • If user confirms: is the condition: the user has clearly chosen to delete.
  • Perform deletion is the only action allowed in that case.
Text
If user cancels:    Do not perform deletion

Line by line:

  • If user cancels: is the other condition: the user has chosen to stop.
  • Do not perform deletion is the only correct outcome in that case.

What could go wrong if an attacker used it

If successfully exploited against an authenticated victim, this type of issue could potentially lead to unauthorised deletion of a business. Depending on the application's functionality, the consequences could include:

  • Loss of business configuration
  • Loss of associated resources
  • Operational disruption
  • Disruption of customer-facing functionality
  • Unauthorised destructive actions

The exact severity would depend on the application's environment and the amount of data or functionality affected. The report does not give a severity rating, CVSS score or bounty amount. A CVSS score is a standard number used to express how serious a vulnerability is; the report does not include one.

What to learn from it

The researcher draws four lessons.

1. Never trust the presence of a CSRF token

Seeing a CSRF token in a request does not automatically mean the application is protected. The backend must verify that the token is:

  • Present
  • Valid
  • Associated with the correct session
  • Not expired, where applicable

Each of these matters. Present means the token is actually in the request. Valid means it is the right value, not a made-up one. Associated with the correct session means it belongs to the logged-in user making the request, not to someone else. Not expired means it is still within the time the site allows it to be used. A token that fails any of these checks should cause the server to refuse the action.

2. Confirmation must be enforced server-side

A confirmation page should not merely provide a visual interface. The server should only perform the destructive action after receiving a valid and explicit confirmation. The flow shown earlier is the model: request, display, explicit confirmation, validation, then deletion.

3. Cancel must actually cancel

A cancellation option should terminate the workflow. The expected logic is the two short blocks shown above: if the user confirms, perform the deletion; if the user cancels, do not perform the deletion. Any destructive operation occurring after a cancellation should be carefully investigated.

4. Test the entire workflow

Security testing should not stop after discovering a missing or bypassable security token. It is important to test the complete flow:

  • Initial request
  • Server response
  • Confirmation page
  • Cancel action
  • Confirm action
  • Final application state

Sometimes the most significant vulnerability is hidden in the interaction between multiple steps. The reason for testing the whole flow is that each step can hide its own mistake, and a mistake in one step can make a protection in another step useless. The final application state is the check that matters most: after all the clicking, is the business still there or not?

Other things worth testing on similar features

They are all ways of asking the same question: what does the server really check?

  • Token removal on other destructive endpoints. Remove the CSRF token from other destructive requests and check whether the action still succeeds. A positive result is that the action still succeeds without a valid token.
  • Token from another session.
  • Expired or reused tokens.
  • Cancel path on other confirmation flows. Submit the cancel choice and then check the final application state. A positive result is that the destructive action happened anyway.
  • Direct call to the confirmation endpoint.
  • Method and parameter tampering. The HTTP method is the type of request, such as POST; a parameter is a named value sent with the request, such as the choice between cancel and confirm.

The overarching question to ask on each target is the one the researcher closes with: what happens if I change this? Never assume a security control works just because it appears in the interface or request; always verify what the server actually enforces.

Glossary

  • API: a set of addresses and rules a program uses to talk to another program; here, the endpoints the browser calls on the server.
  • Authenticated: logged in, with the site knowing who you are.
  • Backend: the part of the application that runs on the server and makes the real decisions.
  • Bug bounty hunter: someone who tests websites, often with the owner's permission, and reports problems in exchange for a reward.
  • Cancel: the option on a confirmation screen that should stop the action from happening.
  • Confirmation screen: the "are you sure?" page shown before a destructive action.
  • Cookie: a small piece of data a site stores in your browser and your browser sends back with each request, so the site can recognise you.
  • CSRF (Cross-Site Request Forgery): an attack where another website tricks your browser into sending a request to a site where you are logged in.
  • CSRF token: a secret random value placed in a site's own pages and expected back with a form submission, so requests from other sites can be rejected.
  • CVSS score: a standard number used to express how serious a vulnerability is.
  • Destructive action: an action that removes or changes data in a way that cannot easily be undone, such as deleting a business.
  • Endpoint: a specific address on a server that handles one kind of request.
  • Front end: the part of the application you see and interact with in the browser.
  • HTTP method: the type of request, such as POST, telling the server what kind of action is being asked for.
  • Parameter: a named value sent with a request, such as a choice between cancel and confirm.
  • POST: an HTTP method used when sending data and asking the server to do something.
  • Red teamer: someone who attacks a company's own systems on purpose, to find weaknesses before real attackers do.
  • Request: a message your browser sends to a server asking it to do something or return something.
  • Server: the computer that runs the website and answers requests.
  • Server-side: happening on the server, where the real checks should be made.
  • Session: the period during which a site remembers you as logged in.
  • Token: a value used to prove something, such as that a request came from the site's own pages.
  • Validation: checking that something is correct and allowed before acting on it.
  • Vulnerability: a weakness in an application that an attacker could use.
  • Workflow: the sequence of steps a feature goes through, from the first request to the final result.

More by Ankit Rathva aka Gujarati Hacker

View all

2 more disclosed reports, best first.

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.