How i Hacked your Beats account ? Apple Bug Bounty
The Beats website's anti-CSRF token was predictable because it was built from the user's numeric ID, which an attacker could obtain, allowing a cross-site request forgery attack. An attacker could change a victim's email address and then take over the account via password reset.
aadityapurani.com
Published on aadityapurani.com
Welcome back, This time i would be talking about a Bug which i found in Apple’s acquisition Beats by Dr dre. It was 2015 and i was trying to fiddle with Apple related Web applications and found Beats by Dr.
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.
Context
Beats by Dr. Dre, an Apple acquisition, ran a main website with a conventional account workflow: signup, login, fill in information, browse, logout. Creating an account asks for first name, last name, email and password; after email verification the user reaches a dashboard for browsing and shopping. The site also has an Account settings area where a user can edit first name, last name, email, subscription and similar fields, plus a separate password change section. That means two separate submit forms:
- Details Edit
- Password Change
The Details Edit form is the interesting one. It includes an E-Mail Address field, and submitting it does not ask the user to re-enter their password to confirm the change. On its own that is not a vulnerability, but it becomes significant once the form can be submitted cross-site.

The author notes that Apple has a strong record on CSRF protection for its web applications: at the time of writing, only eight CSRF issues (including this one) had been found across all Apple domains and acquisitions.
Setup
The researcher worked against the Beats main domain during 2015. Two Beats accounts were created, so that token reuse and per-account token structure could be compared. Requests were intercepted and edited with Burp Suite. No versions or other tooling details are given.
Finding it
The first step was to intercept the request produced by editing account details. The form supplied an anti-CSRF token in the POST request body. There was no double-submit CSRF validation, and the request was a POST, but the application also checked the session id and cookie in the headers, which ruled out IDOR-style manipulation of the request.

The obvious bypasses were tried first:
- Remove the anti-CSRF token parameter from the request body and forward the request. The token was validated server-side, so this failed.
- Change the request type. This also failed.
With the trivial routes closed, the remaining approach was to work out exactly what part of the token was validated. Two accounts were used to test whether a token could be reused across accounts; it could not. Both accounts, however, sent their requests to the same endpoint:
https://www.beatsbydre.com/on/demandware.store/Sites-beats-Site/en_US/GigyaRAAS-SaveCustomer
Something server-side was being checked after the request reached that endpoint. The token was 80 characters long, and comparing tokens intercepted from different accounts showed every token had a definite total length. The questions the researcher set out to answer were:
- Is the server-side check a full-length token based validation?
- Can the token's randomness, complexity and similarities be analysed?
- Are there constant characters, or a constant length, in the token?
- Is there a weakness in the token itself?
The token turned out to have three parts separated by forward slashes.
Part 1: the first 20 characters
The first 20 characters used a fixed value for every request, drawn from [a-zA-Z0-9], for example:
VxM7k0ya2N1R69Ix9E3m
Had these characters not been fixed, the entropy of this first part would have been 95.6 bits. Even if the characters were swapped or randomly changed, it would not pose a risk, because much more of the token remains.
Part 2: the 40-character hash
After the slash, the next part was a hash. Across most accounts it had the same length but different characters.

The next piece was:
[redacted]
Its length is 40. The first assumption was a SHA1 hash, since SHA1 is 160 bits: 160 / 8 = 20 bytes, and two hex characters per byte gives 20 x 2 = 40 hex digits, which matched the size. Treating it as a hash, the next step was brute force: combinations of name and user ID, user ID and email, email and name, and so on. None worked. The researcher suspected a timestamp might be included, as in email:id:timestamp; if so, a universal CSRF would be impossible.
Thinking in reverse, the researcher took combinations of user ID, name and email, hashed them, and cross-verified against the token portion. Two possibilities remained:
- The SHA1 random portion was hashed further by another hashing algorithm.
- It was only the SHA1 portion, but it might contain another parameter.

The first possibility was pursued: another encoding. The researcher had seen ROT13 used in a CTF and had previously pentested a Ruby application that used ROT13 for a download function without access controls. Here only the numeric ID was hashed with SHA1 and then converted to ROT13. The bottom-up approach was to hash suspicious values (ID, email, email plus ID) with SHA1 and then convert to ROT13, using two text files and cross-verifying against the token's hash.
The procedure, as given:
The plain text was the user ID. The second part of the token is derived from the numeric user ID through SHA1 and ROT13.
Part 3: the last 18 characters
The final 18 characters were:
3Ex5Klu9mD1x5vMo91
With 85.7 bits of entropy, cracking this was not practical. The researcher reasoned instead that validation must be full-length token based, with these 18 characters kept completely the same for every account. The final token looked like:
VxM7k0ya2N1R69Ix9E3m/[redacted]/3Ex5Klu9mD1x5vMo91


Exploitation
Step 1: build a token for the victim
Using the same encoding method, the researcher computed the token for a victim account from that account's user ID: fixed first part, SHA1 of the user ID converted to ROT13, fixed last part. The session token still had to be supplied by the web application, so this was not IDOR, but the CSRF worked site-wide on the Beats main domain.
Step 2: submit the forged request
The forged request was sent to the GigyaRAAS-SaveCustomer endpoint with the constructed token. The response indicated success or failure:
{"isCustomerSavedSuccessfully": true, "unsubscribeStatus": null }
{"isCustomerSavedSuccessfully": false, "unsubscribeStatus": null }
The first means the attack succeeded, the second that it did not. A proof of concept was published as a gist.
Step 3: account takeover
Because the Details Edit form accepts an email change without a password confirmation, the CSRF request could change the victim's email address, and also name, last name, number and zip. Once the email was changed to the attacker's dummy address, the attacker could use the forgot password flow to take over the victim's account. The video POC shows this chain.
Root cause
The token was derived from the user ID: a fixed 20-character prefix, a middle part derived from the numeric user ID, and a final 18-character part the researcher believed was kept the same for every account. Anyone who knows a victim's user ID can compute the token, though the session token still had to be supplied by the web application. The researcher reasoned that validation was full-length token based, and the token could be reconstructed from the user ID. The absence of a password confirmation on the email change turned a forged profile update into account takeover.
Impact
An attacker could forge a request that changed a victim's account details, including the email address, and then take over the account through the forgot password flow. The researcher describes it as a site-wide CSRF on the Beats main domain.
Fix
Apple fixed the bug in January 2016, before the write-up. The new protection cross-verifies the token in the headers as well. The Set-Cookie response now sends the details of input values separated by |. The endpoint was also changed to another one with particular random numbers at its end.
Variants to test
- Token structure analysis. Collect tokens from several accounts and compare length, character set and separators. A positive result is a constant prefix or suffix, or a middle section whose length matches a known hash output.
- Deterministic token derivation. Hash candidate values (user ID, email, name, combinations) with common algorithms and encodings such as ROT13, then compare against the token. A match means the token can be forged for any user whose identifier is known.
- Token reuse across accounts. Submit one account's token with another account's session. If it is accepted, the token is not bound to the session.
- Missing password confirmation on sensitive fields. Change the email address in a profile form without re-entering the password. If the change is accepted, combine it with a CSRF to attempt account takeover via forgot password.
- Header versus body validation. Remove the token from the body and see whether a header check still enforces it. A positive result is a request that succeeds without a valid body token.
Timeline
| Date | Event |
|---|---|
| October 8th 2015 | Reported |
| October 23th 2015 | Triaged |
| November 6th 2015 | Responded that "Matter is being investigated" |
| January 18th 2016 | Fixed |
| June 20th 2016 | Acknowledged |
Apple acknowledged the researcher in its Hall of Fame.




What happened, in plain words
Beats by Dr. Dre, a company Apple bought, ran a website where people could create an account, log in, edit their details and shop. The site had a form for editing your account details, and that form let you change the email address on the account without typing your password again. On its own that is just a design choice. The problem was that the form could be made to submit from somewhere else, on behalf of a logged-in user, without that user meaning to do it. This kind of trick is called CSRF, short for Cross Site Request Forgery.
Websites defend against CSRF with a secret value called a token, which the site gives to the browser and expects back with each form submission. The Beats site did have such a token. The researcher took the token apart, worked out how it was built, and found that it was not really secret at all: it could be calculated from the victim's user ID. With a valid token for any user, an attacker could change that user's email address to one the attacker controls, then use the site's "forgot password" feature to take over the account.

The author notes that Apple has a strong record on CSRF protection for its web applications: at the time of writing, only eight CSRF issues (including this one) had been found across all Apple domains and acquisitions.
The site and its forms
The Beats main website worked like most websites. You sign up, log in, fill in your information, browse, and log out. When you create an account it asks for your first name, last name, email and password. After you verify your email address, you reach a dashboard where you can browse and shop.
The site also has an Account settings area. There you can edit your first name, last name, email, subscription and similar fields. Separately there is a password change section. So there are two separate submit forms:
- Details Edit
- Password Change
The Details Edit form is the interesting one. It includes an E-Mail Address field, and submitting it does not ask you to re-enter your password to confirm the change. On its own that is not a vulnerability, but it becomes significant once the form can be submitted from another site.
Setting up
The researcher worked against the Beats main domain during 2015. Two Beats accounts were created, so that tokens from different accounts could be compared. Requests were intercepted and edited with a tool called Burp Suite. Burp Suite sits between your browser and the website: your browser sends its request to Burp, Burp shows it to you, lets you change it, and then forwards it to the site. Think of it as a post office that opens your letters, lets you rewrite them, and then delivers them.
Finding the problem
The first step was to intercept the request that the browser sends when you edit your account details. The form supplied an anti-CSRF token in the POST request body. A POST request is the kind a browser sends when you submit a form with data in it, as opposed to a GET request, which is what happens when you simply open a page. The body is the part of the request that carries the form data.
There was no double-submit CSRF validation. Double-submit means the site puts the same token in two places, usually a cookie and the form, and checks that both match. The request was a POST, but the application also checked the session id and cookie in the headers, which ruled out IDOR-style manipulation of the request. A cookie is a small piece of data the site stores in your browser so it can recognise you on the next request; the session id inside it is what ties a request to your logged-in session. IDOR, Insecure Direct Object Reference, means changing an identifier in a request to reach someone else's data. Because the session and cookie were checked, simply swapping an ID in the request was not going to work.

The obvious bypasses were tried first:
- Remove the anti-CSRF token parameter from the request body and forward the request. The token was validated server-side, so this failed. Server-side means the check happens on the website's own computers, not in your browser, so editing what your browser sends does not avoid it.
- Change the request type. This also failed.
With the trivial routes closed, the remaining approach was to work out exactly what part of the token was validated. Two accounts were used to test whether a token could be reused across accounts; it could not. Both accounts, however, sent their requests to the same endpoint:
https://www.beatsbydre.com/on/demandware.store/Sites-beats-Site/en_US/GigyaRAAS-SaveCustomer
An endpoint is the specific address on a server that handles a particular action, like a counter in a large building: the building is the website, the counter is where your form goes. This URL is the counter that saves customer details.
Something server-side was being checked after the request reached that endpoint. The token was 80 characters long, and comparing tokens intercepted from different accounts showed every token had a definite total length. The questions the researcher set out to answer were:
- Is the server-side check a full-length token based validation?
- Can the token's randomness, complexity and similarities be analysed?
- Are there constant characters, or a constant length, in the token?
- Is there a weakness in the token itself?
The token turned out to have three parts separated by forward slashes.
Part 1: the first 20 characters
The first 20 characters used a fixed value for every request, drawn from [a-zA-Z0-9], for example:
VxM7k0ya2N1R69Ix9E3m
[a-zA-Z0-9] simply means any letter, upper or lower case, or any digit. Fixed means the same characters appeared every time, for every account. Had these characters not been fixed, the entropy of this first part would have been 95.6 bits. Entropy is a measure of how unpredictable something is: more bits means more possible combinations, and therefore harder to guess. Even if the characters were swapped or randomly changed, it would not pose a risk, because much more of the token remains.
Part 2: the 40-character hash
After the slash, the next part was a hash. A hash is the output of a one-way mathematical function: you put data in, you get a fixed-length string out, and you cannot work backwards from the string to the data. Across most accounts it had the same length but different characters.

The next piece was:
[redacted]
Its length is 40. The first assumption was a SHA1 hash, since SHA1 is 160 bits: 160 / 8 = 20 bytes, and two hex characters per byte gives 20 x 2 = 40 hex digits, which matched the size. SHA1 is a well-known hashing algorithm. A bit is the smallest unit of digital information, a byte is eight bits, and a hex character is one of 0 to 9 or a to f. So a 160-bit hash is written as 40 hex characters.
Treating it as a hash, the next step was brute force: combinations of name and user ID, user ID and email, email and name, and so on. Brute force means trying every plausible input until one produces the output you are looking at. None worked. The researcher suspected a timestamp might be included, as in email:id:timestamp; if so, a universal CSRF would be impossible. A timestamp is the date and time of the request, which changes every second, so a token built from it could never be predicted in advance.
Thinking in reverse, the researcher took combinations of user ID, name and email, hashed them, and cross-verified against the token portion. Two possibilities remained:
- The SHA1 random portion was hashed further by another hashing algorithm.
- It was only the SHA1 portion, but it might contain another parameter.

The first possibility was pursued: another encoding. Encoding is a way of rewriting data in a different format, not to hide it but to change how it looks. The researcher had seen ROT13 used in a CTF and had previously pentested a Ruby application that used ROT13 for a download function without access controls. A CTF, capture the flag, is a practice security competition. ROT13 is a simple encoding that shifts each letter 13 places in the alphabet, so A becomes N, B becomes O, and so on; applying it twice brings you back to the original. Here only the numeric ID was hashed with SHA1 and then converted to ROT13. The bottom-up approach was to hash suspicious values (ID, email, email plus ID) with SHA1 and then convert to ROT13, using two text files and cross-verifying against the token's hash.
The procedure, as given:
Line by line: the first line is the piece taken from the token. The second line is what you get when you apply ROT13 to it, turning letters into other letters and leaving digits alone. The third line is that result written backwards. The fourth line is the original value, the plain text, which is the user ID 2292. The link is a public hash lookup site used to cross-check the result. So the second part of the token is the SHA1 of the numeric user ID, ROT13-encoded.
Part 3: the last 18 characters
The final 18 characters were:
3Ex5Klu9mD1x5vMo91
With 85.7 bits of entropy, cracking this was not practical. The researcher reasoned instead that validation must be full-length token based, with these 18 characters kept completely the same for every account. The final token looked like:
VxM7k0ya2N1R69Ix9E3m/[redacted]/3Ex5Klu9mD1x5vMo91
So the whole token is three pieces joined by slashes: a fixed prefix, the encoded user ID, and a fixed suffix. The only part that changes between accounts is the middle, and that part can be calculated by anyone who knows the user ID.


Exploitation
Step 1: build a token for the victim
Using the same encoding method, the researcher computed the token for a victim account from that account's user ID: fixed first part, SHA1 of the user ID converted to ROT13, fixed last part. The session token still had to be supplied by the web application, so this was not IDOR, but the CSRF worked site-wide on the Beats main domain. In other words, the attacker still needed the victim to be logged in and to be tricked into sending the request, but the token itself was no obstacle.
Step 2: submit the forged request
The forged request was sent to the GigyaRAAS-SaveCustomer endpoint with the constructed token. The response indicated success or failure:
{"isCustomerSavedSuccessfully": true, "unsubscribeStatus": null }
{"isCustomerSavedSuccessfully": false, "unsubscribeStatus": null }
JSON is a common way for servers to send structured data back, using curly brackets and name-value pairs. The first response means the attack succeeded, the second that it did not. A proof of concept was published as a gist, which is a small public code snippet hosted on GitHub.
Step 3: account takeover
Because the Details Edit form accepts an email change without a password confirmation, the CSRF request could change the victim's email address, and also name, last name, number and zip. Once the email was changed to the attacker's dummy address, the attacker could use the forgot password flow to take over the victim's account. The forgot password flow then allowed the attacker to take over the victim's account. The video POC shows this chain.
Root cause
The token was derived from the user ID: a fixed 20-character prefix, a middle part derived from the numeric user ID, and a final 18-character part the researcher believed was kept the same for every account. Deterministic means the same input always produces the same output, so there is nothing secret to guess. Anyone who knows a victim's user ID can compute the token, though the session token still had to be supplied by the web application. The researcher reasoned that validation was full-length token based, and the token could be reconstructed from the user ID. The absence of a password confirmation on the email change turned a forged profile update into account takeover.
Impact
An attacker could forge a request that changed a victim's account details, including the email address, and then take over the account through the forgot password flow. The researcher describes it as a site-wide CSRF on the Beats main domain.
Fix
Apple fixed the bug in January 2016, before the write-up. The new protection cross-verifies the token in the headers as well. The Set-Cookie response now sends the details of input values separated by |. Set-Cookie is the header a server uses to tell the browser to store a cookie. The endpoint was also changed to another one with particular random numbers at its end.
Variants to test
- Token structure analysis. Collect tokens from several accounts and compare length, character set and separators. A positive result is a constant prefix or suffix, or a middle section whose length matches a known hash output.
- Deterministic token derivation. Hash candidate values (user ID, email, name, combinations) with common algorithms and encodings such as ROT13, then compare against the token. A match means the token can be forged for any user whose identifier is known.
- Token reuse across accounts. Submit one account's token with another account's session. If it is accepted, the token is not bound to the session.
- Missing password confirmation on sensitive fields. Change the email address in a profile form without re-entering the password. If the change is accepted, combine it with a CSRF to attempt account takeover via forgot password.
- Header versus body validation. Remove the token from the body and see whether a header check still enforces it. A positive result is a request that succeeds without a valid body token.
Timeline
| Date | Event |
|---|---|
| October 8th 2015 | Reported |
| October 23th 2015 | Triaged |
| November 6th 2015 | Responded that "Matter is being investigated" |
| January 18th 2016 | Fixed |
| June 20th 2016 | Acknowledged |
Triaged means the security team looked at the report and confirmed it was a real issue worth working on. Apple acknowledged the researcher in its Hall of Fame.




Glossary
- API: a defined way for one piece of software to talk to another, like a service counter where you make a specific request and get a specific answer.
- Bit: the smallest unit of digital information, a 0 or a 1.
- Body: the part of an HTTP request that carries data, such as form fields.
- Brute force: trying every plausible input until one produces the result you are looking for.
- Burp Suite: a tool that sits between your browser and a website so you can see, pause and edit requests.
- Byte: eight bits.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
- CSRF (Cross Site Request Forgery): tricking a logged-in user's browser into sending a request the user did not intend.
- CTF (capture the flag): a practice security competition with challenges to solve.
- Deterministic: always producing the same output for the same input, with no randomness.
- Double-submit: a CSRF defence that puts the same token in two places and checks that both match.
- Encoding: rewriting data in a different format, such as ROT13, without hiding it.
- Endpoint: the specific address on a server that handles a particular action.
- Entropy: a measure of unpredictability; more bits means more possible combinations.
- GET: a request type used when you simply open a page.
- Gist: a small public code snippet hosted on GitHub.
- Hash: the fixed-length output of a one-way function; you cannot work backwards from it to the input.
- Header: extra information sent alongside a request or response, such as cookies.
- Hex character: one of 0 to 9 or a to f, used to write binary data as text.
- IDOR (Insecure Direct Object Reference): changing an identifier in a request to reach someone else's data.
- JSON: a text format for structured data using curly brackets and name-value pairs.
- POST: a request type used when you submit a form with data in it.
- Proof of concept (POC): a demonstration that an attack works.
- ROT13: an encoding that shifts each letter 13 places in the alphabet; applying it twice returns the original.
- Server-side: happening on the website's own computers, not in your browser.
- Session id: the value in a cookie that ties a request to your logged-in session.
- Set-Cookie: the response header a server uses to tell the browser to store a cookie.
- SHA1: a well-known hashing algorithm producing a 160-bit output, written as 40 hex characters.
- Timestamp: the date and time of an event.
- Token: a value a site gives to the browser and expects back, used to prove a request is legitimate.
- Triaged: reviewed and confirmed as a real issue by a security team.