Skip to content
CSRF Write-up Intermediate

Account Take Over Vulnerability in Google acquisition [Famebit]

The email change functionality lacked server-side validation of the anti-CSRF token, allowing an attacker to change a victim's email address via a CSRF attack and then reset the password to take over the account.

Hassan Khan Yusufzai Follow

Published on medium.com

{{media:0}}

HassanKhanYusufzai, 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

Famebit is a site that Google had acquired, and the researcher tested it as a bug bounty target. The feature at the centre of the report is the email change functionality on the account settings page. Normally, changing the email address on an account is a sensitive action: it is the first half of a password reset, so whoever controls the email address on the account can usually take the account over.

HassanKhanYusufzai
HassanKhanYusufzai From the original on medium.com
Image for post
Image for post

Setup

The researcher did not use a private program for this test. He says he normally prefers to do penetration testing only in Bugcrowd private programs, but on this occasion he decided to hunt Famebit instead. No specific accounts, roles, tools beyond Burp Suite, or versions are described in the report. The only stated precondition is an authenticated victim session on Famebit, which is what any CSRF attack against the email change endpoint relies on.

Finding it

The researcher starts testing a web application from the /settings page, because that page contains the basic functionality of the application. Looking at the email change functionality, he noticed there is no current password protection: the form does not ask the user to re-enter their password before the email address is changed. He notes that a missing current password check on a sensitive action is considered a p4 vulnerability on the Bugcrowd platform, so reporting only that to Google would not be worthwhile.

He then checked the POST request used to perform the email change, with the idea of a CSRF attack. The request carried an X-Famebit-Token header. His first reaction was that bypassing it would not be possible because it is a Google acquisition site, but he decided to try anyway.

Exploitation

Step 1: Compare the request with and without the anti-CSRF header

The researcher captured the email change request and compared two versions: one with the anti-CSRF headers and one without them.

Request and response with anti-CSRF headers:

Request and response without anti-CSRF headers:

Both versions returned the same response. In his words: WDF same Response :D. The conclusion he drew is that there was no server side validation of X-Famebit-Token, which means CSRF is possible. The report does not reproduce the raw request or response bodies, only the screenshots above.

Step 2: Build a CSRF proof of concept in Burp Suite

He made a CSRF proof of concept with Burp Suite and it did not work: the response was 404. He was puzzled about why it failed.

Image for post
Image for post From the original on medium.com

His first thought was that it might be a referrer based CSRF protection, but he later found out it was not referrer based.

Step 3: Understand the trailing = in JSON CSRF

The actual problem was that when a JSON CSRF proof of concept is submitted, extra data is appended at the end of the POST data. In his request it looked like this:

Text
{"email":"[redacted]"}=

He admits he initially mistook this for some kind of server side protection, but later understood it is not server side protection at all, just extra data that is automatically appended in JSON CSRF. He asks readers to correct him if that is not right.

Step 4: Absorb the = with an extra parameter

He dealt with the = in a simple way: he added one extra parameter to the POST data, called ignore. The ignore parameter simply takes the = and ignores it.

Final exploit:

The form posts to https://famebit.com/auth/changeEmail with method POST. The single hidden input carries the JSON body, HTML-entity encoded inside the name attribute, with the value "} in the value attribute. The ignore key is placed at the end of the JSON so that the appended = is absorbed by it.

POST data:

JSON
{"email":"[redacted]","ignore":"="}

With this, the CSRF was possible: the victim's email could be changed, and then the attacker could change the password as well. Account takeover.

Image for post
Image for post From the original on medium.com

Step 5: Proof of concept

The report labels the section above as the POC and does not add further request or response detail beyond the form and the POST data shown.

Root cause

The server did not validate the X-Famebit-Token header on the email change endpoint. The header was present in the request, but sending the request without it produced the same response, so the token was decorative rather than enforced. With no server side check of the token, the endpoint accepted cross-site form submissions from an authenticated victim's browser.

The second part of the root cause is how the JSON body was parsed. A cross-site HTML form cannot send a clean JSON body, and the browser appends an extra = to the submitted data. Adding the ignore key made the request work, so the email change was accepted. The report does not describe the parser itself, so the exact parsing behaviour is only implied by the working payload.

Impact

An attacker who can get an authenticated Famebit user to load a malicious page can change that user's email address to one the attacker controls. Because the email address is the recovery channel, the attacker can then change the password and take over the account. The attack requires the victim to be logged in to Famebit; the report does not discuss any further conditions. The researcher notes the missing current password check alone is p4 on Bugcrowd; with the CSRF bypass, account takeover was possible.

Fix

Google's security team fixed it in a day. The report does not say what the fix was.

Variants to test

  1. Anti-CSRF header present but not enforced. Remove the custom header (for example X-Famebit-Token) from a sensitive request and replay it. A positive result is the same response and the same state change as with the header.
  2. JSON endpoints reachable from a cross-site form. Submit a form with enctype set to text/plain or the default encoding to a JSON API. A positive result is the server accepting the body despite the appended = or other trailing characters.
  3. Parser tolerance for extra keys. Add an unused key such as ignore at the end of the JSON body and see whether the server still processes the request. A positive result is the action succeeding with the extra key present.
  4. Email change without current password. Change the email address on an account without supplying the current password. A positive result is the change being accepted, which is the precondition for the takeover chain above.
  5. Referrer based protection assumptions. Test whether the endpoint actually checks the Referer or Origin header by sending the request from a different origin. A positive result is the request being accepted with a foreign origin.

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 security researcher found a way to take over someone else's account on Famebit, a website that Google had bought. The trick was to make a logged-in victim's own browser send a request that changed the victim's email address to one the attacker controlled. Once the attacker controls the email address on an account, they can usually reset the password and get in. This kind of attack is called Cross-Site Request Forgery, or CSRF for short.

HassanKhanYusufzai
HassanKhanYusufzai From the original on medium.com
Image for post
Image for post

To follow the story you only need a few ideas:

  • Account settings page: the page on a website where you change your name, email, password and similar details. On Famebit the researcher looked at the /settings page.
  • Email change: the feature that lets you swap the email address linked to your account. It matters because the email address is normally where password reset links are sent.
  • Request: when you click a button on a website, your browser sends a message to the website's server asking it to do something. That message is a request.
  • Header: extra information attached to a request, like the label on a parcel. Some headers carry security checks.
  • Token: a short secret value that a website gives your browser so it can tell your real requests apart from forged ones. If the server checks the token, a forged request without the right token is rejected.
  • CSRF: an attack where a malicious page makes your browser send a request to another site you are logged into, using your existing login. Your browser happily attaches your login because it thinks the request comes from you.

Setup

The researcher did not test Famebit through a private bug bounty program. He says he normally prefers to do penetration testing only in Bugcrowd private programs, but on this occasion he decided to hunt Famebit instead. The report does not name any specific test accounts, user roles, tool versions, or anything beyond Burp Suite, a tool that lets you capture, inspect and replay the requests your browser sends. The one thing the attack needs is a victim who is logged in to Famebit at the moment the attack runs, because CSRF relies on the victim's existing session.

Finding it

He starts testing a web application from the /settings page, because that page contains the basic functionality of the application. Looking at the email change feature, he noticed there is no current password protection: the form does not ask the user to re-enter their password before the email address is changed. He notes that a missing current password check on a sensitive action is considered a p4 vulnerability on the Bugcrowd platform, so reporting only that to Google would not be worthwhile. In other words, the missing password prompt alone was too minor to bother reporting.

He then checked the POST request used to perform the email change, with the idea of a CSRF attack. A POST request is the kind of request a browser sends when you submit a form, as opposed to simply loading a page. The request carried an X-Famebit-Token header. His first reaction was that bypassing it would not be possible because it is a Google acquisition site, but he decided to try anyway.

Exploitation

Step 1: Compare the request with and without the anti-CSRF header

He captured the email change request and compared two versions: one with the anti-CSRF headers and one without them. The idea is simple: if the server really enforces the token, removing it should make the request fail. If the server ignores the token, both versions behave the same.

Request and response with anti-CSRF headers:

Request and response without anti-CSRF headers:

Both versions returned the same response. In his words: WDF same Response :D. The conclusion he drew is that there was no server side validation of X-Famebit-Token, which means CSRF is possible. Server side validation means the server itself checks something; here the server did not check the token at all, so the token was decorative. The report does not reproduce the raw request or response bodies, only the screenshots above.

Step 2: Build a CSRF proof of concept in Burp Suite

A proof of concept, or POC, is a small demonstration that proves the attack works. He made a CSRF proof of concept with Burp Suite and it did not work: the response was 404. A 404 is the standard web response for "not found", so the server was not accepting the request at all. He was puzzled about why it failed.

Image for post
Image for post From the original on medium.com

His first thought was that it might be a referrer based CSRF protection, but he later found out it was not referrer based. Referrer based protection means the server looks at the Referer header, which tells the server which page the request came from, and rejects requests that come from another site.

Step 3: Understand the trailing = in JSON CSRF

The actual problem was that when a JSON CSRF proof of concept is submitted, extra data is appended at the end of the POST data. JSON is a text format for structured data, made of keys and values in curly braces, like {"email":"[redacted]"}. In his request it looked like this:

Text
{"email":"[redacted]"}=

Line by line: the curly braces hold one key, email, with the value [redacted]. The = at the very end is not part of the JSON. It is added automatically by the browser when a form is submitted in a certain way. He admits he initially mistook this for some kind of server side protection, but later understood it is not server side protection at all, just extra data that is automatically appended in JSON CSRF. He asks readers to correct him if that is not right.

Step 4: Absorb the = with an extra parameter

He dealt with the = in a simple way: he added one extra parameter to the POST data, called ignore. The ignore parameter simply takes the = and ignores it. Think of it as adding an empty bin at the end of a form so the stray character has somewhere harmless to land.

Final exploit:

Line by line:

  • <html> and </html> wrap the whole page. This is a tiny web page the attacker would host somewhere.
  • <form action="https://famebit.com/auth/changeEmail" method="POST" /> starts a form. action is the address the browser will send the data to, and method="POST" says to send it as a form submission.
  • The <input type="hidden" ...> line is the interesting one. type="hidden" means the field is not shown to the user. The name attribute holds the field name, and the value attribute holds the field value. Both are written with HTML entities such as &#123; for { and &quot; for ", because those characters have special meaning in HTML and must be encoded to appear literally. Decoded, the name is {"email":"[redacted]","ignore":" and the value is "}. When the browser joins name and value together, the result is the JSON body with an ignore key at the end.
  • <input type="submit" value="Submit Request"> is the button. The attacker does not need the victim to click it; a script on the malicious page can submit the form automatically.
  • </form> closes the form.

The form posts to https://famebit.com/auth/changeEmail with method POST. The single hidden input carries the JSON body, HTML-entity encoded inside the name attribute, with the value "} in the value attribute. The ignore key is placed at the end of the JSON so that the appended = is absorbed by it.

POST data:

JSON
{"email":"[redacted]","ignore":"="}

Line by line: email is set to the attacker's address, which is the change the attacker wants. ignore is set to =, which is exactly the stray character the browser appends. The server processes the email change with the ignore key present.

With this, the CSRF was possible: the victim's email could be changed, and then the attacker could change the password as well. Account takeover.

Image for post
Image for post From the original on medium.com

Step 5: Proof of concept

The report labels the section above as the POC and does not add further request or response detail beyond the form and the POST data shown.

Root cause

The server did not validate the X-Famebit-Token header on the email change endpoint. The header was present in the request, but sending the request without it produced the same response, so the token was decorative rather than enforced. With no server side check of the token, the endpoint accepted cross-site form submissions from an authenticated victim's browser.

The second part of the root cause is how the JSON body was parsed. A cross-site HTML form cannot send a clean JSON body, and the browser appends an extra = to the submitted data. Adding the ignore key made the request work, so the email change was accepted. The report does not describe the parser itself, so the exact parsing behaviour is only implied by the working payload.

Impact

An attacker who can get an authenticated Famebit user to load a malicious page can change that user's email address to one the attacker controls. Because the email address is the recovery channel, the attacker can then change the password and take over the account. The attack requires the victim to be logged in to Famebit; the report does not discuss any further conditions. The researcher notes the missing current password check alone is p4 on Bugcrowd; with the CSRF bypass, account takeover was possible.

Fix

Google's security team fixed it in a day.

Variants to test

  1. Anti-CSRF header present but not enforced. Remove the custom header (for example X-Famebit-Token) from a sensitive request and replay it. A positive result is the same response and the same state change as with the header.
  2. JSON endpoints reachable from a cross-site form. Submit a form with enctype set to text/plain or the default encoding to a JSON API. A positive result is the server accepting the body despite the appended = or other trailing characters.
  3. Parser tolerance for extra keys. Add an unused key such as ignore at the end of the JSON body and see whether the server still processes the request. A positive result is the action succeeding with the extra key present.
  4. Email change without current password. Change the email address on an account without supplying the current password. A positive result is the change being accepted, which is the precondition for the takeover chain above.
  5. Referrer based protection assumptions. Test whether the endpoint actually checks the Referer or Origin header by sending the request from a different origin. A positive result is the request being accepted with a foreign origin.

Glossary

  • Account takeover: when an attacker gains control of someone else's account, usually by changing the email or password so the real owner is locked out.
  • Anti-CSRF header: a header carrying a secret value that a server can check to confirm a request really came from its own site.
  • Bug bounty program: a scheme where a company pays researchers for reporting security problems to it.
  • Burp Suite: a tool that lets you capture, inspect, modify and replay the requests your browser sends.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests, which is how you stay logged in.
  • CSRF (Cross-Site Request Forgery): an attack where a malicious page makes your browser send a request to another site you are logged into, using your existing login.
  • Endpoint: a specific address on a server that performs a specific action, such as /auth/changeEmail.
  • Form: the part of a web page that collects data and sends it to a server when submitted.
  • Header: extra information attached to a request or response, such as the token or the referrer.
  • HTML entity: a code such as &#123; that represents a character like { in HTML so it is not treated as markup.
  • JSON: a text format for structured data made of keys and values in curly braces.
  • p4: a low severity rating on the Bugcrowd platform.
  • Penetration testing: deliberately probing a system for security weaknesses, with permission.
  • POST request: a request a browser sends when submitting a form, carrying data to the server.
  • Proof of concept (POC): a small demonstration that proves an attack works.
  • Referer header: a header that tells the server which page the request came from.
  • Referrer based protection: a defence that rejects requests whose Referer header shows they came from another site.
  • Request: a message a browser sends to a server asking it to do something.
  • Response: the message a server sends back, including a status code such as 404.
  • Server side validation: a check performed by the server itself, rather than only in the browser.
  • Session: the period during which a website recognises you as logged in.
  • Token: a short secret value used to tell genuine requests apart from forged ones.
  • 404: the standard web response meaning the requested thing was not found.

More by Hassan Khan Yusufzai

View all

1 more disclosed report, best first.

More from Google

View all

The newest disclosed reports for this program.

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.