# GHSA-mhfv-8rc9-w38c: Arbitrary shell execution

> Attackers can execute arbitrary shell commands due to insufficient escaping of filenames and configuration settings in PHP library functions.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not stated
- **Attackable:** Not stated
- **Victim action needed:** Not stated
- **Fix available:** Yes
- **Published:** 26 Mar 2022

## What is GHSA-mhfv-8rc9-w38c?

GHSA-mhfv-8rc9-w38c is a command injection vulnerability in squizlabs/php_codesniffer, published on 26 Mar 2022. 

### Official description

Uses of shell_exec() and exec() were not escaping filenames and configuration settings in most cases

## Which versions are affected by GHSA-mhfv-8rc9-w38c?

2 open source packages ship an affected version, including squizlabs/php_codesniffer.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `squizlabs/php_codesniffer` | Packagist | From 1.0.0 | 2.8.1 |
| `squizlabs/php_codesniffer` | Packagist | From 1.0.0 | 2.8.1 |

## How do I fix GHSA-mhfv-8rc9-w38c?

Upgrade squizlabs/php_codesniffer to 2.8.1 or later.

## Is GHSA-mhfv-8rc9-w38c being exploited?

There is no known exploitation of GHSA-mhfv-8rc9-w38c in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mhfv-8rc9-w38c and fix it if it is affected.

What it is: GHSA-mhfv-8rc9-w38c is a command injection vulnerability in squizlabs/php_codesniffer, published on 26 Mar 2022. 
Exploitation: There is no known exploitation of GHSA-mhfv-8rc9-w38c in the wild and no public exploit code.

Affected packages and fixed versions:
- squizlabs/php_codesniffer (Packagist): affected from 1.0.0; fixed in 2.8.1
- squizlabs/php_codesniffer (Packagist): affected from 1.0.0; fixed in 2.8.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-mhfv-8rc9-w38c/ (Markdown: https://insights.sbomify.com/GHSA-mhfv-8rc9-w38c/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mhfv-8rc9-w38c

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mhfv-8rc9-w38c/
Summaries are generated and may contain mistakes; the official description above is the record.
