# GHSA-hf3c-wxg2-49q9: vLLM vulnerable to Denial of Service by abusing xgrammar cache

> Attackers can cause Denial of Service by exhausting RAM via unique schema requests in vLLM's xgrammar cache.

- **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 Apr 2025

## What is GHSA-hf3c-wxg2-49q9?

GHSA-hf3c-wxg2-49q9 is a denial of service vulnerability in vllm, published on 15 Apr 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

This report is to highlight a vulnerability in XGrammar, a library used by the structured output feature in vLLM. The XGrammar advisory is here: https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-389x-67px-mjg3

The [xgrammar](https://xgrammar.mlc.ai/docs/) library is the default backend used by vLLM to support structured output (a.k.a. guided decoding). Xgrammar provides a required, built-in cache for its compiled grammars stored in RAM. xgrammar is available by default through the OpenAI compatible API server with both the V0 and V1 engines.

A malicious user can send a stream of very short decoding requests with unique schemas, resulting in an addition to the cache for each request. This can result in a Denial of Service by consuming all of the system's RAM.

Note that even if vLLM was configured to use a different backend by default, it is still possible to choose xgrammar on a per-request basis using the `guided_decoding_backend` key of the `extra_body` field of the request with the V0 engine. This per-request choice is not available when using the V1 engine. 
### Patches

* https://github.com/vllm-project/vllm/pull/16283

### Workarounds

There is no way to workaround this issue in existing versions of vLLM other than preventing untrusted access to the OpenAI compatible API server.

### References

* https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-389x-67px-mjg3

## Which versions are affected by GHSA-hf3c-wxg2-49q9?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `vllm` | PyPI | From 0.6.5 | 0.8.4 |
| `vllm` | PyPI | From 0.6.5 | 0.8.4 |

## How do I fix GHSA-hf3c-wxg2-49q9?

Upgrade vllm to 0.8.4 or later.

## Is GHSA-hf3c-wxg2-49q9 being exploited?

There is no known exploitation of GHSA-hf3c-wxg2-49q9 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-hf3c-wxg2-49q9 and fix it if it is affected.

What it is: GHSA-hf3c-wxg2-49q9 is a denial of service vulnerability in vllm, published on 15 Apr 2025. 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-hf3c-wxg2-49q9 in the wild and no public exploit code.

Affected packages and fixed versions:
- vllm (PyPI): affected from 0.6.5; fixed in 0.8.4
- vllm (PyPI): affected from 0.6.5; fixed in 0.8.4

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-hf3c-wxg2-49q9/ (Markdown: https://insights.sbomify.com/GHSA-hf3c-wxg2-49q9/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-hf3c-wxg2-49q9

---
From sbomify Insights: https://insights.sbomify.com/GHSA-hf3c-wxg2-49q9/
Summaries are generated and may contain mistakes; the official description above is the record.
