How a Simple Token Mistake Led Me to a Full Admin Account Takeover
The application trusted a client-side token's role and user ID without server-side validation, allowing an attacker to modify their token to gain admin access. A password change endpoint also accepted a user ID in the URL, enabling the attacker to change the admin's password without knowing the old one, resulting in full account takeover.
Published on medium.com
Sometimes, the most dangerous security bugs don’t look dangerous at first glance.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server did not verify the token's role or user ID against the actual user, and the password change endpoint trusted a user-supplied ID in the URL instead of using the authenticated user's identity.
Impact
The attacker could view and edit admin data, change the admin password without knowing the old one, lock out the real admin, and gain full control of the account.
What the attacker needed
A normal user account; ability to edit browser storage; admin user ID from JavaScript file
The fix
The application should validate tokens and roles on the server and not trust user-supplied IDs for sensitive actions like password changes.
How it was found
- Access the /admin page and observe redirection to normal user page.
- Modify the normal user token to change role from user to admin and store it in the browser.
- Access the admin page again and observe no redirection.
- Find an admin user ID from a JavaScript file.
- Create a token combining original user data, admin role, and admin user ID, then access admin page.
- Attempt to change admin password via endpoint with user ID in URL and no old password, succeeding.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The app stored a token in the browser that said who you are and what you can do. The server believed whatever the token said, so changing the token to say 'admin' gave admin access. Also, a password change page let you specify whose password to change by putting their ID in the web address, so you could change someone else's password without knowing their old one.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.