Skip to content
CSRF Write-up Intermediate

Hack User Account Via Activation link

The account activation link accepted an extra parameter that connected the newly activated account to the currently logged-in account. An attacker could send a crafted activation link to a victim, and when the victim visited it while logged in, the attacker's account would be linked to the victim's account, giving the attacker access.

medium.com

Published on medium.com

While I was testing one of our clients web-application, there was a function called “Add Account” which allows user to connect two accounts, so that he can access both of them without needing to logout out the first account and sign in again. Both accounts will have access to each other and from any account of them…

Sherif Afifi, 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 client web application that offered an "Add Account" feature. The feature lets a user connect two accounts so that they can access both without logging out of the first and signing in again. Once connected, both accounts have access to each other: from either account the user can control the other, and a user can connect any number of accounts together. The connected accounts appear in a drop-down menu from which the user can switch between them.

The researcher's goal was to understand how the linking works and whether it could be abused to attach an attacker-controlled account to a victim's account.

Setup

The researcher used their own accounts on the application. No specific tools, versions or roles are described in the report. The preconditions that matter are:

  1. The application sends an activation link by email when a new account is registered, and visiting that link activates the account and logs the user in directly.
  2. The application has an "Add Account" flow that connects the currently logged-in account with a second one.
  3. The researcher controls an email inbox for the account being registered, so they can read the activation link.

Finding it

Under settings, clicking "Add Account" redirected the researcher to the login page with a URL parameter marking the intent to connect:

Text
https://www.reacted.com/account/login?action=connect

On that page the user enters the email and password of the second account, and after login both accounts are connected. The new account then appears in the drop-down menu of accounts.

The first idea was to make a victim log in to the attacker's account while already logged in to their own, using CSRF, so that the two accounts would be connected and the attacker could then reach the victim's account. That did not work because the login page was protected by an anti-CSRF token:

HTTP
POST /sessions?action=connect HTTP/1.1

Host: [www.reacted.com](http://www.bonanza.com)

headers,,,

auth-[redacted]&link=true&username=Tachi&[redacted]&commit=Log+in

The request carries an auth-token field alongside link=true, the username, the password and the commit button value.

Exploitation

The researcher then recalled that the first registration produced an activation link by email, and that visiting it activated the account and logged the user in directly. That flow, unlike the login form, was worth testing.

Step 1: Try the activation link while logged in to another account

The researcher created a new account, took the verification link from the inbox, and opened it in another browser where a different user account was logged in. Nothing happened: the browser was simply logged in to the new account, and the two accounts were not connected. Logging a user in to another account while they are logged in is therefore not sufficient on its own; something else in the request must be what connects the two accounts, most likely a parameter.

Step 2: Identify the connecting parameter

The researcher remembered the action=connect URL parameter that was sent with the login request when adding an account. The hypothesis was that appending this parameter to the activation link would make the activation flow perform the connection.

The original activation link looked like this:

Text
https://www.reacted.com/users/ID/activate?activation_code={Random-Code}&tracker_id=xxxxx&utm_campaign=signup&utm_medium=Notifier&utm_source=email

The edited link adds action=connect to the query string:

Text
https://www.reacted.com/users/ID/activate?**action=connect**&activation_code={Random-Code}&tracker_id=xxxxxx&utm_campaign=signup&utm_medium=Notifier&utm_source=email

activation_code is the random code that identifies the pending activation, and the tracker_id, utm_campaign, utm_medium and utm_source parameters are the usual signup tracking values. The added action=connect is the same flag the login page used to signal that the second account should be linked to the current session.

Step 3: Visit the edited link while logged in

The researcher visited the edited activation link for the new account while logged in to their current account. The new account was activated and linked to the current account.

From the original on medium.com

The screenshot shows the result after visiting the edited activation link for the new account while logged in to the current account: the new account has been activated and linked to the current account.

Step 4: Reuse the link

The activation link does not expire after being used. This makes the attack more severe: an attacker can create an account, edit the activation link they receive, and distribute that link anywhere, then wait for accounts to be connected to it.

Root cause

Appending action=connect to the activation link caused the new account to be activated and linked to the account logged in in the browser that opened it. The anti-CSRF token on the login form does not help here, because the attack does not go through the login form at all: it uses a GET link that the victim is expected to click.

Impact

Opening the edited activation link while logged in to another account connected that account to the newly activated one. Because connected accounts have access to each other, the attacker can then control the victim's account from their own. The activation link does not expire after use, so the edited link can be distributed widely and accounts may be connected to it. The report does not state which users or roles are affected beyond the accounts that use the feature, nor does it give a bounty or severity.

Fix

The report does not describe a fix or a response from the vendor. Based on the behaviour described, the activation endpoint should not honour the action=connect parameter, or should require an explicit, CSRF-protected confirmation from the logged-in user before linking an account. Activation links should also expire after use, so a link cannot be replayed to connect further accounts.

Variants to test

  1. Other action parameters on email links. Take any emailed link (activation, password reset, email change, invitation) and append the parameter used by the application's account-linking or switching flow, such as action=connect. A positive result is that the link performs the linking action for the logged-in user.
  2. Replay of one-time links. Use an activation or invitation link a second time after it has already been consumed. A positive result is that the link still works and performs its action again.
  3. Linking without a confirmation step. Walk through the normal "Add Account" flow and check whether the final step is a GET request with no anti-CSRF token. A positive result is that a cross-site GET performs the link.
  4. Session and code mismatch. Visit an activation link for account A while logged in as account B and observe whether the two are linked. A positive result is that the accounts are connected without any check that the code belongs to the session.

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

What happened, in plain words

A web application had a feature called "Add Account" that let you connect two accounts so you could switch between them without logging out and back in. Once connected, each account could control the other, and you could connect as many accounts as you liked. The researcher wanted to see whether an attacker could trick someone into connecting the attacker's account to the victim's account. The first attempt, using a technique called CSRF (making a victim's browser send a request without them meaning to), failed because the login form had a protection token. The researcher then found that the email activation link sent when you register a new account could be edited: adding a small parameter, action=connect, made the link not only activate the new account but also link it to whichever account was already logged in in the browser that opened the link. The link also did not expire after use, so one edited link could be sent to many people. The result: opening the edited link while logged in to another account connected that account to the newly activated one.

Background: the feature and the goal

The target was a client web application. It offered an "Add Account" feature. The feature lets a user connect two accounts so that they can access both without logging out of the first and signing in again. Once connected, both accounts have access to each other: from either account the user can control the other, and a user can connect any number of accounts together. The connected accounts appear in a drop-down menu from which the user can switch between them.

The researcher's goal was to understand how the linking works and whether it could be abused to attach an attacker-controlled account to a victim's account.

Setup

The researcher used their own accounts on the application. No specific tools, versions or roles are described in the report. The preconditions that matter are:

  1. The application sends an activation link by email when a new account is registered, and visiting that link activates the account and logs the user in directly.
  2. The application has an "Add Account" flow that connects the currently logged-in account with a second one.
  3. The researcher controls an email inbox for the account being registered, so they can read the activation link.

Finding it

Under settings, clicking "Add Account" redirected the researcher to the login page with a URL parameter marking the intent to connect:

Text
https://www.reacted.com/account/login?action=connect

This is a URL. The part after the ? is called the query string. It carries small pieces of information called parameters, written as name=value. Here the parameter is action with the value connect. The application reads it and understands that the user wants to connect a second account, not just log in normally.

On that page the user enters the email and password of the second account, and after login both accounts are connected. The new account then appears in the drop-down menu of accounts.

The first idea was to make a victim log in to the attacker's account while already logged in to their own, using CSRF, so that the two accounts would be connected and the attacker could then reach the victim's account. CSRF stands for Cross-Site Request Forgery. It means making a victim's browser send a request to a site where the victim is logged in, without the victim intending to. A simple comparison: imagine someone quietly slipping a signed cheque into your pile of papers; when you sign the pile, you also sign the cheque. The browser automatically attaches the victim's login cookie (a small piece of data the site gave the browser to remember who is logged in) to requests, so a request triggered from another site can act as the victim.

That did not work because the login page was protected by an anti-CSRF token:

HTTP
POST /sessions?action=connect HTTP/1.1

Host: [www.reacted.com](http://www.bonanza.com)

headers,,,

auth-[redacted]&link=true&username=Tachi&[redacted]&commit=Log+in

Line by line:

  • POST /sessions?action=connect HTTP/1.1 is the start of an HTTP request. HTTP is the language browsers and servers use to talk. POST means "send data". /sessions?action=connect is the address on the server, and action=connect again says the intent is to connect an account. HTTP/1.1 is the version of the protocol.
  • Host: [www.reacted.com](http://www.bonanza.com) tells the server which site the request is for. (The link text in the report points to a different domain; the host header is what the request carries.)
  • headers,,, is a placeholder for other request headers, the extra lines of information a browser sends along with a request.
  • auth-[redacted]&link=true&username=Tachi&[redacted]&commit=Log+in is the body of the request, the data being sent. It is formatted like a query string: name=value pairs joined by &. auth-token is the anti-CSRF token: a secret value the server put into the page, which a request from another site would not know. link=true says the login should link the account. username and password are the credentials. commit=Log+in is the value of the submit button. The request includes an auth-token, which a request forged from another site would not know.

Exploitation

The researcher then recalled that the first registration produced an activation link by email, and that visiting it activated the account and logged the user in directly. That flow, unlike the login form, was worth testing.

Step 1: Try the activation link while logged in to another account

The researcher created a new account, took the verification link from the inbox, and opened it in another browser where a different user account was logged in. Nothing happened: the browser was simply logged in to the new account, and the two accounts were not connected. Logging a user in to another account while they are logged in is therefore not sufficient on its own; something else in the request must be what connects the two accounts, most likely a parameter.

Step 2: Identify the connecting parameter

The researcher remembered the action=connect URL parameter that was sent with the login request when adding an account. The hypothesis was that appending this parameter to the activation link would make the activation flow perform the connection.

The original activation link looked like this:

Text
https://www.reacted.com/users/ID/activate?activation_code={Random-Code}&tracker_id=xxxxx&utm_campaign=signup&utm_medium=Notifier&utm_source=email

This is the link the application emailed. The path /users/ID/activate is the activation endpoint. The query string has several parameters: activation_code is the random code that identifies the pending activation; tracker_id, utm_campaign, utm_medium and utm_source are the usual signup tracking values, used to record where the signup came from. {Random-Code} and xxxxx are placeholders for values.

The edited link adds action=connect to the query string:

Text
https://www.reacted.com/users/ID/activate?**action=connect**&activation_code={Random-Code}&tracker_id=xxxxxx&utm_campaign=signup&utm_medium=Notifier&utm_source=email

The only change is the new first parameter, action=connect, shown in bold in the report. It is the same flag the login page used to signal that the second account should be linked to the current session. A session is the server's memory of who is logged in; the browser holds a cookie that points to that session.

Step 3: Visit the edited link while logged in

The researcher visited the edited activation link for the new account while logged in to their current account. The new account was activated and linked to the current account.

From the original on medium.com

The screenshot shows the result after visiting the edited activation link for the new account while logged in to the current account: the new account has been activated and linked to the current account.

Step 4: Reuse the link

The activation link does not expire after being used. This makes the attack more severe: an attacker can create an account, edit the activation link they receive, and distribute that link anywhere, then wait for accounts to be connected to it.

Root cause

Appending action=connect to the activation link caused the new account to be activated and linked to the account logged in in the browser that opened it. The activation link is a bearer credential delivered by email: whoever holds the link can use it, like a key left under the doormat. The anti-CSRF token on the login form does not help here, because the attack does not go through the login form at all: it uses a GET link that the victim is expected to click. GET is the HTTP method a browser uses when you click a normal link or type an address; it carries data in the URL rather than in a request body.

Impact

Opening the edited activation link while logged in to another account connected that account to the newly activated one. Because connected accounts have access to each other, the attacker can then control the victim's account from their own. The activation link does not expire after use, so the edited link can be distributed widely and accounts may be connected to it. The report does not state which users or roles are affected beyond the accounts that use the feature, nor does it give a bounty or severity.

Fix

The report does not describe a fix or a response from the vendor. Based on the behaviour described, the activation endpoint should not honour the action=connect parameter, or should require an explicit, CSRF-protected confirmation from the logged-in user before linking an account. Activation links should also expire after use, so a link cannot be replayed to connect further accounts.

Variants to test

  1. Other action parameters on email links. Take any emailed link (activation, password reset, email change, invitation) and append the parameter used by the application's account-linking or switching flow, such as action=connect. A positive result is that the link performs the linking action for the logged-in user.
  2. Replay of one-time links. Use an activation or invitation link a second time after it has already been consumed. A positive result is that the link still works and performs its action again.
  3. Linking without a confirmation step. Walk through the normal "Add Account" flow and check whether the final step is a GET request with no anti-CSRF token. A positive result is that a cross-site GET performs the link.
  4. Session and code mismatch. Visit an activation link for account A while logged in as account B and observe whether the two are linked. A positive result is that the accounts are connected without any check that the code belongs to the session.

Glossary

  • API: a set of rules that lets one piece of software talk to another; here, the web endpoints the browser calls.
  • Activation link: a link sent by email that turns a newly registered account on.
  • Anti-CSRF token: a secret value placed in a form or request that a request from another site cannot know, used to block CSRF.
  • Bearer credential: something that grants access simply by being held, like a key or a ticket.
  • Cookie: a small piece of data a site stores in the browser so it can recognise the browser later, often to keep a user logged in.
  • CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request to a site without the user intending it.
  • Endpoint: a specific address on a server that performs an action or returns data.
  • GET: an HTTP method used when a browser requests a page or resource by URL; data travels in the URL.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Parameter: a name=value pair in a URL's query string or in a request body that passes information to the server.
  • POST: an HTTP method used to send data to the server, usually in the request body.
  • Query string: the part of a URL after ?, made of parameters joined by &.
  • Session: the server's record of a logged-in user, linked to the browser by a cookie.
  • Token: a value used to prove identity or permission; here, the anti-CSRF token and the activation code.
  • URL: the address of a resource on the web.
  • UTM parameters: tracking parameters (utm_campaign, utm_medium, utm_source) that record where a signup came from.

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.