# GHSA-4qqc-mp5f-ccv4: Command Injection in bestzip

> Attackers can execute arbitrary system commands via unsanitized input in the bestzip library if the destination path is user-controlled.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Sep 2020

## What is GHSA-4qqc-mp5f-ccv4?

GHSA-4qqc-mp5f-ccv4 is a command injection vulnerability in bestzip, published on 2 Sep 2020. 

### Official description

Versions of `bestzip` prior to 2.1.7 are vulnerable to Command Injection. The package fails to sanitize input rules and passes it directly to an `exec` call on the `zip` function . This may allow attackers to execute arbitrary code in the system as long as the values of `destination` is user-controlled. This only affects users with a native `zip` command available. The following examples demonstrate the issue from the CLI and also programatically:
- `bestzip test.zip 'sourcefile; mkdir folder'`
- `zip({ source: 'sourcefile', destination: './test.zip; mkdir folder' })`

## Which versions are affected by GHSA-4qqc-mp5f-ccv4?

2 open source packages ship an affected version, including bestzip.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `bestzip` | npm | All versions | 2.1.7 |
| `bestzip` | npm | All versions | 2.1.7 |

## How do I fix GHSA-4qqc-mp5f-ccv4?

Upgrade bestzip to 2.1.7 or later.

## Is GHSA-4qqc-mp5f-ccv4 being exploited?

There is no known exploitation of GHSA-4qqc-mp5f-ccv4 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-4qqc-mp5f-ccv4 and fix it if it is affected.

What it is: GHSA-4qqc-mp5f-ccv4 is a command injection vulnerability in bestzip, published on 2 Sep 2020. 
Exploitation: There is no known exploitation of GHSA-4qqc-mp5f-ccv4 in the wild and no public exploit code.

Affected packages and fixed versions:
- bestzip (npm): affected all versions; fixed in 2.1.7
- bestzip (npm): affected all versions; fixed in 2.1.7

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-4qqc-mp5f-ccv4/ (Markdown: https://insights.sbomify.com/GHSA-4qqc-mp5f-ccv4/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-4qqc-mp5f-ccv4

---
From sbomify Insights: https://insights.sbomify.com/GHSA-4qqc-mp5f-ccv4/
Summaries are generated and may contain mistakes; the official description above is the record.
