# GHSA-57q7-rxqq-7vgp: On Windows, `git-sizer` might run a `git` executable within the repository being analyzed

> An attacker can execute arbitrary code on Windows by tricking a user into running git-sizer on a malicious repository containing a fake git executable.

- **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:** 15 Feb 2022
- **Also known as:** GO-2022-0424

## What is GHSA-57q7-rxqq-7vgp?

GHSA-57q7-rxqq-7vgp is a command injection vulnerability in github.com/github/git-sizer, published on 15 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
On Windows, if `git-sizer` is run against a non-bare repository, and that repository has an executable called `git.exe`, `git.bat`, etc., then that executable might be run by `git-sizer` rather than the system `git` executable. An attacker could try to use social engineering to get a victim to run `git-sizer` against a hostile repository and thereby get the victim to run arbitrary code.

On Linux or other Unix-derived platforms, a similar problem could occur if the user's `PATH` has the current directory before the path to the standard `git` executable, but this is would be a very unusual configuration that has been known for decades to lead to all kinds of security problems.

### Patches
Users should update to git-sizer v1.4.0

### Workarounds
If you are on Windows, then either
* Don't run `git-sizer` against a repository that might contain hostile code, or, if you must…
* Run `git-sizer` against a bare clone of the hostile repository, or, if that is not possible…
* Make sure that the hostile repository doesn't have an executable in its top-level directory before running `git-sizer`.

If you are on Linux or other Unix-based system, then (for myriad reasons!) don't add the current directory to your `PATH`.

### References
* [Command PATH security in Go](https://blog.golang.org/path-security)

### For more information
If you have any questions or comments about this advisory:
* Open an issue in [the `git-sizer` project](https://github.com/github/git-sizer).
* Email us at [GitHub support](mailto:support@github.com).

## Which versions are affected by GHSA-57q7-rxqq-7vgp?

3 open source packages ship an affected version, including github.com/github/git-sizer.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/github/git-sizer` | Go | All versions | 1.4.0 |
| `github.com/github/git-sizer` | Go | All versions | 1.4.0 |
| `github.com/github/git-sizer` | Go | All versions | 1.4.0 |

## How do I fix GHSA-57q7-rxqq-7vgp?

Upgrade github.com/github/git-sizer to 1.4.0 or later.

## Is GHSA-57q7-rxqq-7vgp being exploited?

There is no known exploitation of GHSA-57q7-rxqq-7vgp in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-57q7-rxqq-7vgp and fix it if it is affected.

What it is: GHSA-57q7-rxqq-7vgp is a command injection vulnerability in github.com/github/git-sizer, published on 15 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-57q7-rxqq-7vgp in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/github/git-sizer (Go): affected all versions; fixed in 1.4.0
- github.com/github/git-sizer (Go): affected all versions; fixed in 1.4.0
- github.com/github/git-sizer (Go): affected all versions; fixed in 1.4.0

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-57q7-rxqq-7vgp/ (Markdown: https://insights.sbomify.com/GHSA-57q7-rxqq-7vgp/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-57q7-rxqq-7vgp

---
From sbomify Insights: https://insights.sbomify.com/GHSA-57q7-rxqq-7vgp/
Summaries are generated and may contain mistakes; the official description above is the record.
