VAITP Dataset

← Back to the dataset

CVE-2025-25183

vLLM hash collisions cause cache reuse, interfering with responses. Upgrade to v0.7.2.

  • CVSS 2.6
  • CWE-354
  • Resource Management
  • Remote

vLLM is a high-throughput and memory-efficient inference and serving engine for LLMs. Maliciously constructed statements can lead to hash collisions, resulting in cache reuse, which can interfere with subsequent responses and cause unintended behavior. Prefix caching makes use of Python's built-in hash() function. As of Python 3.12, the behavior of hash(None) has changed to be a predictable constant value. This makes it more feasible that someone could try exploit hash collisions. The impact of a collision would be using cache that was generated using different content. Given knowledge of prompts in use and predictable hashing behavior, someone could intentionally populate the cache using a prompt known to collide with another prompt in use. This issue has been addressed in version 0.7.2 and all users are advised to upgrade. There are no known workarounds for this vulnerability.

CVSS base score
2.6
Published
2025-02-07
OWASP
A03 Injection
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
Python
Fixed by upgrading
Yes

Solution

Upgrade to vLLM version 0.7.2 or later.

Vulnerable code sample

import hashlib

class PrefixCache:
    def __init__(self):
        self._store = {}

    def get(self, prompt):
        key = hash(prompt)  # VULNERABLE: uses predictable hash leading to collisions
        return self._store.get(key)

    def set(self, prompt, value):
        key = hash(prompt)  # VULNERABLE: uses predictable hash leading to collisions
        self._store[key] = value

Patched code sample

import hashlib

class PrefixCache:
    def __init__(self):
        self._store = {}

    def _stable_hash(self, prompt):
        # FIX: use cryptographic hash to avoid predictable collisions
        return hashlib.sha256(prompt.encode('utf-8')).hexdigest()

    def get(self, prompt):
        key = self._stable_hash(prompt)
        return self._store.get(key)

    def set(self, prompt, value):
        key = self._stable_hash(prompt)
        self._store[key] = value

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • [Core] Improve hash collision avoidance in prefix caching (#12621) (vllm-project/vllm)
    vllm/core/block/prefix_caching_block.py, vllm/core/block/prefix_caching_block.py · ComputedBlocksTracker._update_seq_hashes, vllm/core/block/prefix_caching_block.py · PrefixCachingBlock.content_hash, vllm/core/block/prefix_caching_block.py · PrefixCachingBlock.hash_block_tokens, vllm/v1/core/kv_cache_utils.py · hash_block_tokens

Payload

# This is a conceptual example and might require adjustments
# depending on the specific vLLM implementation and Python version.
# It aims to generate hash collisions with prompts that include None.

def generate_colliding_prompt(target_prompt):
  """
  Generates a prompt designed to hash collide with the target_prompt, 
  especially when the target_prompt includes None or variations that hash to the same value as None in Python 3.12+.
  """
  # This is a placeholder and needs to be refined based on actual hash collisions.
  # The real payload depends on the exact implementation of the hashing in vLLM.

  prefix = "A" * 10  # Example filler
  collision_trigger = None #or some equivalent to None that has a predictable hash value
  suffix = "B" * 10  # Example filler

  colliding_prompt = f"{prefix}{collision_trigger}{suffix}"
  return colliding_prompt

# Example usage:
target_prompt = "Tra

Cite this entry

@misc{vaitp:cve202525183,
  title        = {{vLLM hash collisions cause cache reuse, interfering with responses. Upgrade to v0.7.2.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2025},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2025-25183},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-25183/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.