Skip to content
CSRF Write-up Intermediate

CSRF + Open Redirect To Account Takeover

The application did not properly validate anti-CSRF tokens when adding a secondary email, and it sent a confirmation link even when the token was missing, but only if the email had been previously added and removed. An attacker could exploit this to add their own email to a victim's account by sending a crafted request and then a confirmation link with an open redirect parameter to hide the success pop-up, leading to account takeover via password reset.

Demon Follow

Published on r29k.com

An atypical CSRF, found by luck, chained with an open redirect to silently plant an attacker's email on a victim's account.

Sheraz Khalid, on r29k.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. 7 min read.

Context

The target was a public VDP program on Bugcrowd. The scope was tiny, so the researcher skipped recon entirely and went straight to the main application, created an account and explored the features. The feature of interest was the secondary email setting: an account can have a second email address attached to it, used to receive updates, password reset tokens and similar messages, just like the primary address.

Adding a secondary email produces a confirmation link. The link has to be opened in the same browser where the user is already logged in; otherwise the application asks the user to log in first. Confirming the address redirects the user to the account settings page and shows a pop-up reading "Successfully Added Secondary Email Address".

The bug is a chain: a CSRF in the add-secondary-email flow, combined with an open redirect in the confirmation link, leading to full account takeover. The CSRF is unusual in the conditions under which it works, which is the core of the write-up.

Setup

  • A public VDP program on Bugcrowd, with a small scope.
  • No recon was performed.
  • A normal account on the main application, plus a second account created later to confirm the behaviour.
  • Burp Suite to intercept and modify the add-secondary-email request.
  • The researcher's own email addresses, used as the secondary addresses under test.

The researcher usually starts from the account settings page because that is where the easy bugs live: CSRF, IDOR, XSS, CSTI/SSTI. The first thing tried here was CSRF on the add-secondary-email feature.

Finding it

The first test was a straightforward CSRF check. A second email was added and the request intercepted in Burp to look for anti-CSRF tokens. Tokens were present. The request was forwarded unmodified, the confirmation link arrived, it was opened in the same browser, and the email was added as intended.

The next question was whether the server actually validated those tokens. The secondary email was removed and added again, but this time the anti-CSRF token value was stripped, leaving the parameter empty. On forwarding, the server returned a "No CSRF TOKENS" error, and then the researcher's phone beeped: a confirmation link had arrived.

That is the anomaly. The server rejected the request for missing anti-CSRF tokens and still sent the confirmation link for adding a secondary email. The researcher expected this to be a duplicate but assumed it would still earn reputation, so it was worth submitting.

Exploitation

Step 1: try to reproduce with a fresh email

A second account was created to confirm the behaviour, and a CSRF exploit was built using a brand-new email address, not the one used during the earlier testing. The exploit was run, the missing-token error came back, and the confirmation link was awaited. Nothing arrived. The exploit was run again and again on both accounts, still nothing. The researcher suspected an anti-CSRF header had been missed, but checking the request showed there was none.

Step 2: reuse an email that had already been added

The first account was used again, and the same email that had been used during the earlier CSRF testing was added, with the token removed. The error came back, and so did the confirmation link. That suggested using the already-added email inside the exploit. It was dropped in, the exploit was run against the second account, and the confirmation link came through.

The condition is precise: adding a brand-new email without CSRF tokens gives only an error, but adding an email that has already been tied to an account as a secondary address, without tokens, gives the error and a working confirmation link.

Step 3: deal with the pop-up

A confirmation link alone is not enough, because the attacker cannot open it while logged into the victim's account. What the attacker can do is send the link to the victim; when the victim opens it, the attacker's email is added to the victim's account. The problem is that the victim would see the "Secondary Account Added Successfully" pop-up and realise a new email had been attached. At this point the researcher could not see a way around it, assumed the issue had already been reported and would be a duplicate, and submitted the report with reproduction steps and the CSRF exploit rather than spending more time on it.

Step 4: the report is closed, then reopened months later

The program's expected response time was 30 days. After 23 days the program replied that it could not reproduce the issue. The researcher was busy on another program and did not respond, not knowing that failing to reply within 15 days closes the report as N/A. The report was closed as N/A and the PoC was not redone.

Four months later, going through old reports, the researcher found this one and tried again. The CSRF was still there. A comment was left saying it still worked, and the program asked for a working PoC. It worked for the researcher but not for the program. A fresh account was spun up to test, it worked again, and this time something previously missed was noticed: a redirect parameter in the confirmation link, set to /profile/settings, the page where the pop-up fires.

Step 5: bypass the pop-up with the open redirect

The question was what happens if the user is redirected somewhere else, such as /home, and whether the notification still appears. The redirect parameter was changed to /home, the link was opened, the home page loaded, and the notification never popped. Checking the account settings showed the secondary email sitting there. That was the bypass for the "Successfully Added Secondary Email Address" pop-up.

Step 6: the full attack scenario

With the attacker controlling [redacted] and wanting it added to the victim's account via CSRF:

  1. Add [redacted] to the attacker's own account the normal way and confirm it.
  2. Remove the email. It is now "primed" for use in the CSRF exploit.
  3. Build a CSRF exploit using [redacted] and send it to the victim.
  4. When the victim runs the exploit, the attacker receives a confirmation link on their own email.
  5. The attacker changes the redirect parameter to /home and sends that link to the victim.
  6. When the victim opens it, the attacker's email is added to the victim's account with no pop-up, because the victim lands on the home page instead of profile settings.

With a secondary email silently attached to the victim's account, the attacker can request password reset tokens to that address and take the account over.

Root cause

The server does not properly enforce anti-CSRF token validation on the add-secondary-email action. When the token is missing it returns a "No CSRF TOKENS" error, but it still processes the request far enough to generate and send a confirmation link, at least under one condition: the email address being added has previously been attached to an account as a secondary address and then removed. For a brand-new address, the same tokenless request produces only the error and no link.

The second flaw is the redirect parameter in the confirmation link. It is attacker-controllable, so the confirmation can land the user on another path such as /home. Because the success notification is tied to the settings page, redirecting elsewhere suppresses the visible sign that a secondary email was added. The report does not describe any server-side validation of the redirect value beyond the observed behaviour.

Impact

An attacker can add an email address they control to a victim's account without the victim seeing the success pop-up, provided the victim opens the crafted confirmation link while logged in. The attacker's address then receives the same kinds of messages as the primary address, including password reset tokens, which allows account takeover. The attack requires user interaction: the victim must open the link. That interaction is why the triager initially rated it P3.

Fix

The report does not state what the program changed. Based on the described behaviour, the server should reject tokenless requests before any confirmation link is generated, so that a missing or invalid anti-CSRF token never results in an email being sent. The redirect parameter should be restricted to a fixed allowlist of internal paths, or removed in favour of a hard-coded destination, so the success notification cannot be suppressed by redirecting the user elsewhere.

Variants to test

  • Strip the anti-CSRF token from other account-changing requests (email change, password change, MFA enrolment) and watch for side effects such as emails or notifications arriving despite an error response. A positive result is any state change or outbound message triggered by a request the server reports as rejected.
  • Reuse previously removed values in tokenless requests: an email address, a phone number, a recovery question. A positive result is a working confirmation or verification link for a value that is no longer attached to any account.
  • Look for a redirect, next, return or callback parameter in confirmation and verification links and point it at another in-scope path. A positive result is landing on the alternate page while the underlying action still completes, with no visible success message.
  • Chain a suppressed notification with a sensitive action (secondary email, password reset destination, recovery phone) and check whether the resulting channel can receive reset tokens. A positive result is a reset token delivered to an address or number the attacker controls.
  • Test the same tokenless request against a fresh value and a previously used value side by side. A difference in behaviour between the two, as seen here, points at server-side state that the CSRF defence does not cover.

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 found a way to quietly attach an email address they controlled to someone else's account on a website, without that person noticing. Once the attacker's email is attached as a "secondary" address, the attacker can ask the site to send a password reset to it, and take the account over.

Two separate weaknesses had to be joined together to make this work. The first is a CSRF, which is a way of making a logged-in user's browser send a request the user did not intend. The second is an open redirect, which is a link parameter that lets someone choose where the user lands after clicking. On their own, neither would be enough. Together, they let the attacker add their email silently.

The CSRF here is unusual: it only works when the email address being added has already been attached to some account once and then removed. That odd condition is the heart of the story, and it is why the researcher first thought the bug would be a duplicate and nearly gave up on it.

The setup

What a VDP is

A VDP, or vulnerability disclosure program, is a scheme a company runs so that security researchers can report bugs to it. Some programs pay money (bug bounties); a VDP usually does not pay, but it gives researchers a legitimate place to report problems and often some reputation in return. Bugcrowd is a platform that hosts many of these programs.

The researcher picked a public VDP on Bugcrowd. The scope (the list of what is allowed to be tested) was tiny, so they skipped recon. Recon, short for reconnaissance, is the early phase where a researcher maps out a target: finding subdomains, hidden pages, old versions of the site and so on. With a small scope there was little to map, so they went straight to the main application, created an account and started exploring the features.

Why account settings first

The researcher usually starts from the account settings page, because that is where the easy bugs live. The technical write-up lists them by their short names: CSRF, IDOR, XSS, CSTI/SSTI. Here is what each means in everyday terms:

  • CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request to a site, using the login the browser already has. Think of it as someone using your signed permission slip without asking you.
  • IDOR (Insecure Direct Object Reference): a page that shows you a record by its number, where changing the number lets you see someone else's record. Like a hotel key card that opens any room if you change the room number on it.
  • XSS (Cross-Site Scripting): getting your own code to run inside someone else's web page, so it acts with that page's permissions.
  • CSTI/SSTI (Client/Server-Side Template Injection): feeding input into a template engine so that the input is treated as instructions rather than plain text. The researcher adds a smiley, "not actually easy :p", because these are often harder than they sound.

The first thing tried on this target was CSRF on the add-secondary-email feature.

What the secondary email feature does

An account can have a second email address attached to it. That address receives updates, password reset tokens and similar messages, just like the primary address. A password reset token is a short, secret code a site emails you so you can prove you own the address and set a new password. If an attacker's address is attached as a secondary, the attacker receives those codes too.

Adding a secondary email produces a confirmation link. The link has to be opened in the same browser where the user is already logged in; otherwise the application asks the user to log in first. This is the site's way of checking that the person confirming really is the account holder. Confirming the address redirects the user to the account settings page and shows a pop-up reading "Successfully Added Secondary Email Address".

The tools

The researcher used Burp Suite, a tool that sits between the browser and the website and lets you pause, read and change requests before they are sent. A request is simply the message your browser sends to a server when you click something or load a page. Intercepting it means catching that message mid-flight. The researcher also used their own email addresses as the secondary addresses under test, and later created a second account to confirm the behaviour.

Finding it

The first, ordinary CSRF test

The first test was a straightforward CSRF check. A second email was added and the request was intercepted in Burp to look for anti-CSRF tokens. An anti-CSRF token is a random value the site puts into each form, which the server checks on arrival. Because an attacker's page cannot know the victim's token, a request without the correct token should be rejected. It is like a wax seal on a letter: the receiver checks the seal before acting on the contents.

Tokens were present. The request was forwarded unmodified, the confirmation link arrived, it was opened in the same browser, and the email was added as intended. So far, everything behaved correctly.

Removing the token

The next question was whether the server actually validated those tokens, or merely expected them to be there. The secondary email was removed and added again, but this time the anti-CSRF token value was stripped, leaving the parameter empty. A parameter is one named field in a request, for example email=... or token=...; emptying it means sending the field with no value.

On forwarding, the server returned a "No CSRF TOKENS" error, and then the researcher's phone beeped: a confirmation link had arrived.

That is the anomaly. The server rejected the request for missing anti-CSRF tokens and still sent the confirmation link for adding a secondary email. In plain terms: the guard said "no entry" and the letter went out anyway. The researcher expected this to be a duplicate (a bug someone else had already reported) but assumed it would still earn reputation, so it was worth submitting.

Exploitation

Step 1: try to reproduce with a fresh email

A second account was created to confirm the behaviour, and a CSRF exploit was built using a brand-new email address, not the one used during the earlier testing. A CSRF exploit here is a page the attacker hosts that makes the victim's browser send the add-secondary-email request automatically, for example by submitting a hidden form as soon as the page loads.

The exploit was run, the missing-token error came back, and the confirmation link was awaited. Nothing arrived. The exploit was run again and again on both accounts, still nothing. The researcher suspected an anti-CSRF header had been missed. A header is extra information attached to a request, separate from the visible fields, and some sites put their token there instead of in a form field. Checking the request showed there was none.

Step 2: reuse an email that had already been added

The first account was used again, and the same email that had been used during the earlier CSRF testing was added, with the token removed. The error came back, and so did the confirmation link. That suggested using the already-added email inside the exploit. It was dropped in, the exploit was run against the second account, and the confirmation link came through.

The condition is precise: adding a brand-new email without CSRF tokens gives only an error, but adding an email that has already been tied to an account as a secondary address, without tokens, gives the error and a working confirmation link. In other words, the same tokenless request behaves differently depending on whether the address was previously attached and removed.

Step 3: deal with the pop-up

A confirmation link alone is not enough, because the attacker cannot open it while logged into the victim's account. What the attacker can do is send the link to the victim; when the victim opens it, the attacker's email is added to the victim's account. The problem is that the victim would see the "Secondary Account Added Successfully" pop-up and realise a new email had been attached.

At this point the researcher could not see a way around it, assumed the issue had already been reported and would be a duplicate, and submitted the report with reproduction steps and the CSRF exploit rather than spending more time on it.

Step 4: the report is closed, then reopened months later

The program's expected response time was 30 days. After 23 days the program replied that it could not reproduce the issue. The researcher was busy on another program and did not respond, not knowing that failing to reply within 15 days closes the report as N/A. N/A means not applicable: the platform treats the report as not a valid finding and closes it. The report was closed as N/A and the proof of concept (PoC, the working demonstration of the bug) was not redone.

Four months later, going through old reports, the researcher found this one and tried again. The CSRF was still there. A comment was left saying it still worked, and the program asked for a working PoC. It worked for the researcher but not for the program. A fresh account was spun up to test, it worked again, and this time something previously missed was noticed: a redirect parameter in the confirmation link, set to /profile/settings, the page where the pop-up fires.

A redirect parameter is a field in a link that tells the site where to send the user after the action finishes. Here it pointed at the settings page, which is exactly the page that shows the success pop-up.

Step 5: bypass the pop-up with the open redirect

The question was what happens if the user is redirected somewhere else, such as /home, and whether the notification still appears. The redirect parameter was changed to /home, the link was opened, the home page loaded, and the notification never popped. Checking the account settings showed the secondary email sitting there. That was the bypass for the "Successfully Added Secondary Email Address" pop-up.

This is the open redirect part of the chain. An open redirect is a link parameter that accepts any destination the attacker chooses, instead of only the site's own intended pages. The pop-up was tied to the settings page, so sending the user to the home page meant the pop-up never had a chance to appear, while the email was added all the same.

Step 6: the full attack scenario

With the attacker controlling [redacted] and wanting it added to the victim's account via CSRF:

  1. Add [redacted] to the attacker's own account the normal way and confirm it.
  2. Remove the email. It is now "primed" for use in the CSRF exploit.
  3. Build a CSRF exploit using [redacted] and send it to the victim.
  4. When the victim runs the exploit, the attacker receives a confirmation link on their own email.
  5. The attacker changes the redirect parameter to /home and sends that link to the victim.
  6. When the victim opens it, the attacker's email is added to the victim's account with no pop-up, because the victim lands on the home page instead of profile settings.

With a secondary email silently attached to the victim's account, the attacker can request password reset tokens to that address and take the account over. Account takeover means the attacker ends up in control of the victim's account.

Root cause

The server does not properly enforce anti-CSRF token validation on the add-secondary-email action. When the token is missing it returns a "No CSRF TOKENS" error, but it still processes the request far enough to generate and send a confirmation link, at least under one condition: the email address being added has previously been attached to an account as a secondary address and then removed. For a brand-new address, the same tokenless request produces only the error and no link.

The second flaw is the redirect parameter in the confirmation link. It is attacker-controllable, so the confirmation can land the user on another path such as /home. Because the success notification is tied to the settings page, redirecting elsewhere suppresses the visible sign that a secondary email was added. The report does not describe any server-side validation of the redirect value beyond the observed behaviour.

Impact

An attacker can add an email address they control to a victim's account without the victim seeing the success pop-up, provided the victim opens the crafted confirmation link while logged in. The attacker's address then receives the same kinds of messages as the primary address, including password reset tokens, which allows account takeover. The attack requires user interaction: the victim must open the link. That interaction is why the triager initially rated it P3. A triager is the person at the program who reviews reports and assigns a priority; P3 is a lower priority than P1 or P2.

Fix

The report does not state what the program changed. Based on the described behaviour, the server should reject tokenless requests before any confirmation link is generated, so that a missing or invalid anti-CSRF token never results in an email being sent. The redirect parameter should be restricted to a fixed allowlist of internal paths, or removed in favour of a hard-coded destination, so the success notification cannot be suppressed by redirecting the user elsewhere. An allowlist is a list of permitted values; anything not on the list is refused.

Variants to test

  • Strip the anti-CSRF token from other account-changing requests (email change, password change, MFA enrolment) and watch for side effects such as emails or notifications arriving despite an error response. A positive result is any state change or outbound message triggered by a request the server reports as rejected. MFA is multi-factor authentication, a second proof of identity beyond the password.
  • Reuse previously removed values in tokenless requests: an email address, a phone number, a recovery question. A positive result is a working confirmation or verification link for a value that is no longer attached to any account.
  • Look for a redirect, next, return or callback parameter in confirmation and verification links and point it at another in-scope path. A positive result is landing on the alternate page while the underlying action still completes, with no visible success message.
  • Chain a suppressed notification with a sensitive action (secondary email, password reset destination, recovery phone) and check whether the resulting channel can receive reset tokens. A positive result is a reset token delivered to an address or number the attacker controls.
  • Test the same tokenless request against a fresh value and a previously used value side by side. A difference in behaviour between the two, as seen here, points at server-side state that the CSRF defence does not cover.

Glossary

  • Account takeover: an attacker gaining control of someone else's account, for example by receiving that person's password reset codes.
  • Allowlist: a list of values that are explicitly permitted; anything not on the list is refused.
  • Anti-CSRF token: a random value placed in a form or request that the server checks, so that requests forged by another site are rejected.
  • Bug bounty: a program that pays researchers for reporting security bugs.
  • Burp Suite: a tool that sits between the browser and a website, letting you pause, read and change requests.
  • Confirmation link: a link emailed to an address so the owner can prove they control it and complete an action.
  • CSTI/SSTI (Client/Server-Side Template Injection): feeding input into a template engine so the input is treated as instructions rather than plain text.
  • Duplicate: a bug that has already been reported by someone else.
  • Header: extra information attached to a request, separate from its visible fields.
  • IDOR (Insecure Direct Object Reference): a page that shows a record by its number, where changing the number exposes someone else's record.
  • MFA (multi-factor authentication): a second proof of identity beyond the password.
  • N/A (not applicable): a status meaning the platform treats the report as not a valid finding and closes it.
  • Open redirect: a link parameter that accepts any destination the attacker chooses instead of only the site's intended pages.
  • Parameter: one named field in a request or link, such as email=... or redirect=....
  • Password reset token: a short secret code emailed to an address so its owner can set a new password.
  • PoC (proof of concept): a working demonstration that the bug can actually be exploited.
  • P1, P2, P3: priority ratings a program assigns to a report, P1 being the most severe.
  • Recon (reconnaissance): the early phase of mapping out a target, such as finding subdomains and hidden pages.
  • Request: the message a browser sends to a server when loading a page or submitting a form.
  • Scope: the list of systems and features a program allows researchers to test.
  • Secondary email: a second address attached to an account, which receives the same kinds of messages as the primary one.
  • Triager: the person at a program who reviews reports and assigns a priority.
  • VDP (vulnerability disclosure program): a scheme for researchers to report bugs, usually without payment.

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.