# GHSA-fqfh-778m-2v32: GitHub CLI can execute a git binary from the current directory

> GitHub CLI on Windows executes a malicious git binary from the current directory, allowing code execution when run in untrusted locations.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 11 Feb 2022
- **Also known as:** GO-2022-0395

## What is GHSA-fqfh-778m-2v32?

GHSA-fqfh-778m-2v32 is a command injection vulnerability in github.com/cli/cli, published on 11 Feb 2022. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

### Impact
GitHub CLI depends on a `git.exe` executable being found in system `%PATH%` on Windows. However, if a malicious `.\git.exe` or `.\git.bat` is found in the current working directory at the time of running `gh`, the malicious command will be invoked instead of the system one.

Windows users who run `gh` inside untrusted directories are affected.

### Patches
Users should upgrade to GitHub CLI v1.2.1.

### Workarounds
Other than avoiding untrusted repositories, there is no workaround.

### References
https://github.com/golang/go/issues/38736

## Which versions are affected by GHSA-fqfh-778m-2v32?

3 open source packages ship an affected version, including github.com/cli/cli.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/cli/cli` | Go | All versions | 1.2.1 |
| `github.com/cli/cli` | Go | All versions | 1.2.1 |
| `github.com/cli/cli` | Go | All versions | 1.2.1 |

## How do I fix GHSA-fqfh-778m-2v32?

Upgrade github.com/cli/cli to 1.2.1 or later.

## Is GHSA-fqfh-778m-2v32 being exploited?

There is no known exploitation of GHSA-fqfh-778m-2v32 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-fqfh-778m-2v32 and fix it if it is affected.

What it is: GHSA-fqfh-778m-2v32 is a command injection vulnerability in github.com/cli/cli, published on 11 Feb 2022. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-fqfh-778m-2v32 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/cli/cli (Go): affected all versions; fixed in 1.2.1
- github.com/cli/cli (Go): affected all versions; fixed in 1.2.1
- github.com/cli/cli (Go): affected all versions; fixed in 1.2.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-fqfh-778m-2v32/ (Markdown: https://insights.sbomify.com/GHSA-fqfh-778m-2v32/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-fqfh-778m-2v32

---
From sbomify Insights: https://insights.sbomify.com/GHSA-fqfh-778m-2v32/
Summaries are generated and may contain mistakes; the official description above is the record.
