Bitbucket’s Migration Endpoint
The Data Center Migration tool in Bitbucket extracted TAR archives without sanitising entry paths, allowing an Admin to write files outside the intended directory. By placing a Git hook with execute permissions in a repository's hooks directory, an attacker could achieve remote code execution when a Git event triggers the hook.
blog.ripstech.com
Published on blog.ripstech.com
In Bitbucket the four different user roles Bitbucket User, Project Creator, Admin and System Admin exist. An attacker with the permissions of the role Admin can abuse Bitbucket’s Data Center Migration tool to drop an executable shell script in an arbitrary directory.
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
Impact
An attacker with Admin role could achieve remote code execution on the Bitbucket server, but the exploit requires a Bitbucket Data Center license and the Admin role.
What the attacker needed
Admin role in Bitbucket; Bitbucket Data Center license; ability to import a TAR archive
The fix
The issue was fixed in Bitbucket 6.1.2.
How it was found
- Export repositories from Bitbucket Server to create a TAR archive.
- Modify the hooks archive entry to include a path traversal sequence.
- Import the modified archive via the Data Center Migration tool.
- Trigger a Git event (e.g., push) to execute the dropped hook.
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.
Bitbucket is a tool for managing code. Its migration feature unpacked a compressed archive but did not check where each file inside was going. An attacker with admin rights could use a path like '../../' to put a malicious script in a place where it would run automatically, giving them control of the server.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.