How I Downloaded All Bitbucket Repos by Finding a Leaked Token in a JS file for $4k Bounty.
A Bitbucket read token was exposed in a public JavaScript file, allowing an attacker to list and clone all repositories in the workspace. The author used the token to download every repository, exposing source code and secrets.
Published on s41n1k.medium.com
While hunting for a JS file, I discovered a BITBUCKETREADTOKEN, and after researching online, I found that this token allows for the complete download of all repositories from the Bitbucket workspace.
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 developer moved code from development to production without removing the development environment's secret token from the JavaScript bundle.
What the attacker needed
Leaked token in public JS file; No authentication needed beyond token
The fix
Developers should check for and remove debugging and environment secret information before moving code from development to production.
How it was found
- Visit the target's JavaScript files.
- Extract the Bitbucket read token from the JavaScript file.
- Use the token to list all repositories in the workspace via the Bitbucket API.
- Retrieve information about a specific repository.
- Search for a project using its project key.
- Clone each repository using the token.
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 secret access token was accidentally left in a JavaScript file that anyone can download. That token acts like a password for Bitbucket, so the author could list and copy every code repository in the company's workspace.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.