{"id":"CVE-2022-23642","published":"2022-02-18T22:15:11Z","modified":"2025-04-22T18:21:53Z","title":"Code Injection in Sourcegraph","vendor":"sourcegraph","product":"sourcegraph","tier":"core","eol":null,"affectedVersions":[{"vendor":"sourcegraph","product":"sourcegraph","versions":["< 3.37"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2025-04-22T15:44:24.013601Z","from":"CISA ADP","provenance":"source"},"description":{"text":"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.","provenance":"source","from":"CVE.org"},"summary":{"text":"Sourcegraph, the code search and navigation engine, contains a code injection flaw in its gitserver service, which acts as a git exec proxy and fails to restrict calls to git config. An attacker who can make HTTP requests to internal services such as gitserver, with a low-privilege account, can set git's core.sshCommand option to run an arbitrary command in place of ssh, achieving remote code execution; exploitation depends on how the deployment exposes those internal services.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-21T03:45:04Z"},"cvss":{"score":8.8,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.7431,"percentile":0.995,"date":"2026-11-20","provenance":"source"},"kev":null,"vulncheckKev":null,"exploited":false,"otx":{"pulseCount":0,"pulses":[],"provenance":"machine"},"cwes":[{"id":"CWE-94","name":"Improper Control of Generation of Code"}],"references":[{"url":"https://github.com/sourcegraph/sourcegraph/security/advisories/GHSA-qcmp-fx72-q8q9","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/sourcegraph/sourcegraph/pull/30833","tags":["x_refsource_MISC"]},{"url":"http://packetstormsecurity.com/files/167506/Sourcegraph-Gitserver-3.36.3-Remote-Code-Execution.html","tags":["x_refsource_MISC"]},{"url":"http://packetstormsecurity.com/files/167741/Sourcegraph-gitserver-sshCommand-Remote-Command-Execution.html","tags":["x_refsource_MISC"]}],"techniques":[],"reports":[],"affected":[],"advisories":[],"euvd":{"id":"EUVD-2022-28590","url":"https://euvd.enisa.europa.eu/vulnerability/EUVD-2022-28590","exploited":false,"exploitedSince":null,"provenance":"source"},"exploits":[{"id":50964,"url":"https://www.exploit-db.com/exploits/50964","title":"Sourcegraph Gitserver 3.36.3 - Remote Code Execution (RCE)","type":"remote","platform":"multiple","date":"2022-06-14","verified":false,"provenance":"source"}],"exploitSources":{"exploitdb":{"count":1,"earliest":"2022-06-14"},"pocGithub":{"count":1,"skipped":0,"earliest":"2022-06-10","earliestUrl":"https://github.com/Altelus1/CVE-2022-23642","repos":[{"name":"Altelus1/CVE-2022-23642","url":"https://github.com/Altelus1/CVE-2022-23642","stars":7,"created":"2022-06-10"}]},"metasploit":[{"name":"Sourcegraph gitserver sshCommand RCE","module":"exploit/linux/http/sourcegraph_gitserver_sshcmd","type":"exploit","disclosureDate":"2022-02-18","url":"https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/sourcegraph_gitserver_sshcmd.rb"}],"first":{"date":"2022-02-18","source":"Metasploit","url":"https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/sourcegraph_gitserver_sshcmd.rb"},"provenance":"source"},"exploitRefs":["http://packetstormsecurity.com/files/167506/Sourcegraph-Gitserver-3.36.3-Remote-Code-Execution.html","http://packetstormsecurity.com/files/167741/Sourcegraph-gitserver-sshCommand-Remote-Command-Execution.html"],"flow":[],"timeline":[{"date":"2022-02-18","kind":"published","label":"Published (CVE.org)","url":"https://www.cve.org/CVERecord?id=CVE-2022-23642","provenance":"source"},{"date":"2022-02-18","kind":"exploit-public","label":"First public exploit: Metasploit; later: PoC-in-GitHub 2022-06-10, Exploit-DB 2022-06-14","url":"https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/sourcegraph_gitserver_sshcmd.rb","provenance":"source"}],"speed":{"daysToPublicExploit":0,"firstExploitFrom":"Metasploit","daysToKev":null},"priority":{"score":31.1,"factors":[{"name":"In a KEV catalog","points":0.0,"detail":"not listed"},{"name":"Recent KEV listing","points":0.0,"detail":"not listed"},{"name":"Known ransomware use","points":0.0,"detail":"not known"},{"name":"EPSS percentile","points":19.9,"detail":"percentile 0.9950"},{"name":"Named in threat reports","points":0.0,"detail":"0 reports"},{"name":"Public exploit code","points":5.0,"detail":"1 Exploit-DB entry; 2 NVD exploit links; 1 PoC-in-GitHub repo; 1 Metasploit module"},{"name":"Mentioned in OTX pulses","points":0.0,"detail":"0 pulses"},{"name":"CVSS severity","points":6.16,"detail":"base score 8.8"},{"name":"End-of-life product","points":0.0,"detail":"supported or unknown"}]}}