Exploit database

Vulnerability

CVE-2022-23642

Code Injection in Sourcegraph

Vulnerability details

Score
8.8
Severity
high

CVSS 3.1 · GitHub_M

Vector string

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Description

Sourcegraph is a code search and navigation engine. Sourcegraph prior to version 3.37 is vulnerable to remote code execution in the `gitserver` service. The service acts as a git exec proxy, and fails to properly restrict calling `git config`. This allows an attacker to set the git `core.sshCommand` option, which sets git to use the specified command instead of ssh when they need to connect to a remote system. Exploitation of this vulnerability depends on how Sourcegraph is deployed. An attacker able to make HTTP requests to internal services like gitserver is able to exploit it. This issue is patched in Sourcegraph version 3.37. As a workaround, ensure that requests to gitserver are properly protected.

CVE Program

Exploit source choices

3 sources
Sourcegraph gitserver sshCommand RCE
MSF-linux--http--sourcegraph_gitserver_sshcmdMetasploitLinux,Unix / remote

A vulnerability exists within Sourcegraph's gitserver component that allows a remote attacker to execute arbitrary OS commands by modifying the core.sshCommand value within the git configuration. This command can then be triggered on demand by executing a git push operation. The vulnerability was patched by introducing a feature flag in version 3.37.0. This flag must be enabled for the protections to be in place which filter the commands that are able to be executed through the git exec REST API.

2022-02-18sourcegraph_gitserver_sshcmd.rb
altelus1/cve-2022-23642
GH-132c77145d1f05bc7d4cefcc52e9b9bcGitHubUnofficial GitHub source

PoC for Sourcegraph Gitserver < 3.37.0 RCE (CVE-2022-23642)

2022-06-103 files · 7 stars