Rapid7 Vulnerability & Exploit Database

Bitbucket Environment Variable RCE

Back to Search

Bitbucket Environment Variable RCE

Disclosed
11/16/2022
Created
03/16/2023

Description

For various versions of Bitbucket, there is an authenticated command injection vulnerability that can be exploited by injecting environment variables into a user name. This module achieves remote code execution as the `atlbitbucket` user by injecting the `GIT_EXTERNAL_DIFF` environment variable, a null character as a delimiter, and arbitrary code into a user's user name. The value (payload) of the `GIT_EXTERNAL_DIFF` environment variable will be run once the Bitbucket application is coerced into generating a diff. This module requires at least admin credentials, as admins and above only have the option to change their user name.

Author(s)

  • Ry0taK
  • y4er
  • Shelby Pace

Platform

Linux,Unix,Windows

Architectures

cmd, x86, x64

Development

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/multi/http/bitbucket_env_var_rce
msf exploit(bitbucket_env_var_rce) > show targets
    ...targets...
msf exploit(bitbucket_env_var_rce) > set TARGET < target-id >
msf exploit(bitbucket_env_var_rce) > show options
    ...show and set options...
msf exploit(bitbucket_env_var_rce) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;