# GHSA-77mv-mp2j-gxxh: pygmentize Remote Code Execution

> Attackers can execute arbitrary code by exploiting unsafe input sanitization in the pygmentize highlight function.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 May 2024

## What is GHSA-77mv-mp2j-gxxh?

GHSA-77mv-mp2j-gxxh is a code injection vulnerability in 3f/pygmentize, published on 15 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

pygmentize is prone to remote code execution due to an unsafe sanitazation of user input when passed to the `highlight` function.

## Which versions are affected by GHSA-77mv-mp2j-gxxh?

2 open source packages ship an affected version, including 3f/pygmentize.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `3f/pygmentize` | Packagist | All versions | 1.2 |
| `3f/pygmentize` | Packagist | All versions | 1.2 |

## How do I fix GHSA-77mv-mp2j-gxxh?

Upgrade 3f/pygmentize to 1.2 or later.

## Is GHSA-77mv-mp2j-gxxh being exploited?

There is no known exploitation of GHSA-77mv-mp2j-gxxh in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-77mv-mp2j-gxxh and fix it if it is affected.

What it is: GHSA-77mv-mp2j-gxxh is a code injection vulnerability in 3f/pygmentize, published on 15 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-77mv-mp2j-gxxh in the wild and no public exploit code.

Affected packages and fixed versions:
- 3f/pygmentize (Packagist): affected all versions; fixed in 1.2
- 3f/pygmentize (Packagist): affected all versions; fixed in 1.2

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-77mv-mp2j-gxxh/ (Markdown: https://insights.sbomify.com/GHSA-77mv-mp2j-gxxh/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-77mv-mp2j-gxxh

---
From sbomify Insights: https://insights.sbomify.com/GHSA-77mv-mp2j-gxxh/
Summaries are generated and may contain mistakes; the official description above is the record.
