Broken Access Control via Hardcoded Bearer Token in Public JS Fil
A hardcoded Bearer token was found in a public JavaScript file, granting full read and write access to product metadata via an API. An attacker could use this token to read, modify, and corrupt product data, potentially disrupting business logic.
Published on medium.com
While casually reviewing public-facing JavaScript files on the target website, I stumbled upon something that made my inner hacker scream:
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, a secret authentication token was hardcoded into client-side JavaScript, and the server accepted it without proper authorization checks.
What the attacker needed
Access to public JavaScript files; No authentication required
The fix
Secrets should never be hardcoded in frontend JavaScript; use environment variables, rotate tokens, and enforce proper authentication and authorization on the server side.
How it was found
- Review public JavaScript files on the target website.
- Find a hardcoded Bearer token in a JavaScript file.
- Discover the API endpoint /bc/v2/items that accepts the token.
- Send a GET request to /bc/v2/items to read all product metadata.
- Send a PATCH request to /bc/v2/items/123456 with modified fields to update a product.
- Fetch /bc/v2/items again to confirm the changes were saved.
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.
A developer left a secret password (called a token) inside a file that anyone can download from the website. This token let the finder read and change product information without needing to log in. It's like finding a key to the building in a public brochure.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.