Skip to content
Leaked secrets Write-up Beginner

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.

Imran Hossain Follow

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.

Imran Hossain, on s41n1k.medium.com

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

  1. Visit the target's JavaScript files.
  2. Extract the Bitbucket read token from the JavaScript file.
  3. Use the token to list all repositories in the workspace via the Bitbucket API.
  4. Retrieve information about a specific repository.
  5. Search for a project using its project key.
  6. 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.

More by Imran Hossain

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.