Skip to content

Overwrite of builtin Cody commands facilitates RCE

Critical
andreeleuterio published GHSA-8wmq-fwv7-xmwq Oct 23, 2023

Package

Cody AI VSCode extension

Affected versions

>=0.10.0 <=0.14.0

Patched versions

0.14.1

Description

Impact

The Cody AI VSCode extension versions >=0.10.0 and <=0.14.0 are vulnerable to Remote Code Execution under certain conditions.

An attacker in control of a malicious repository could modify the Cody configuration file .vscode/cody.json and overwrite Cody commands. If a user with the extension installed opens this malicious repository and runs a Cody command such as /explain or /doc, this could allow arbitrary code execution on the user's machine.

The vulnerability is rated as critical severity, but with low exploitability. It requires the user to have a malicious repository loaded and execute the overwritten command in VS Code. The issue is exploitable regardless of the user blocking code execution on a repository through VS Code Workspace Trust.

The issue was found during a regular 3rd party penetration test. We do not have evidence of open source repositories having malicious .vscode/cody.json files to exploit this vulnerability.

Patches

The issue is fixed in version 0.14.1 of the Cody VSCode extension.

Reference

PR

Workarounds

In case users can't promptly upgrade they should not open any untrusted repositories with the Cody extension loaded.

You may use the following Sourcegraph search query to find repositories overwriting Cody commands: file:^.vscode/cody.json$ "command". These can be compared against the default settings.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H

CVE ID

CVE-2023-46248

Weaknesses