Critical

BentoML SSRF Vulnerability in File Upload Processing

  • Disclosed: 29.07.2025
  • Updated: 11.10.2026 15:17

Description

There's an SSRF in the file upload processing system that allows remote attackers to make arbitrary HTTP requests from the server without authentication. The vulnerability exists in the serialization/deserialization handlers for multipart form data and JSON requests, which automatically download files from user-provided URLs without proper validation of internal network addresses.

The framework automatically registers any service endpoint with file-type parameters (pathlib.Path, PIL.Image.Image) as vulnerable to this attack, making it a framework-wide security issue that affects most real-world ML services handling file uploads. While BentoML implements basic URL scheme validation in the JSONSerde path, the MultipartSerde path has no validation whatsoever, and neither path restricts access to internal networks, cloud metadata endpoints, or localhost services.

The documentation explicitly promotes this URL-based file upload feature, making it an intended but insecure design that exposes all deployed services to SSRF attacks by default.

Source - Sink Analysis

Source: User-controlled multipart form field values and JSON request bodies containing URLs

Call Chain - Path 1 (MultipartSerde - No Validation):

  1. HTTP POST request with multipart form data to any BentoML endpoint with file-type input parameters
  2. MultipartSerde.parse_request() in src/_bentoml_impl/serde.py:202 processes the request
  3. form = await request.form() parses multipart data using Starlette
  4. For file-type fields: value = [await self.ensure_file(v) for v in form.getlist(k)] at line 209
  5. MultipartSerde.ensure_file() called at lines 186-200 with user-controlled string URL
  6. Sink: resp = await client.get(obj) at line 193 - Direct HTTP request with zero validation

Call Chain - Path 2 (JSONSerde - Weak Validation):

  1. HTTP POST request with JSON body containing URL to endpoint with IORootModel + multipart_fields
  2. JSONSerde.parse_request() in src/_bentoml_impl/serde.py:157 processes the request
  3. body = await request.body() extracts request body
  4. Condition check: if issubclass(cls, IORootModel) and cls.multipart_fields: at line 164
  5. Weak validation: if is_http_url(url := body.decode("utf-8", "ignore")): at line 165 (only checks scheme)
  6. Sink: resp = await client.get(url) at line 168 - HTTP request after insufficient validation

Proof of Concept

Create a BentoML service:

python
from pathlib import Path
import bentoml

@bentoml.service  
class ImageProcessor:
    @bentoml.api
    def process_image(self, image: Path) -> str:
        return f"Processed image: {image}"

Deploy and exploit:

bash
# Start service (binds to 0.0.0.0:3000 by default)
bentoml serve service.py:ImageProcessor

# SSRF Attack 1 - Access AWS metadata  
curl -X POST http://target:3000/process_image \
     -F 'image=http://169.254.169.254/latest/meta-data/'

# SSRF Attack 2 - Internal service enumeration
curl -X POST http://target:3000/process_image \  
     -F 'image=http://localhost:8080/admin'

# SSRF Attack 3 - Internal network scanning
curl -X POST http://target:3000/process_image \
     -F 'image=http://10.0.0.1:22'

Expected result: Server makes HTTP requests to internal/cloud endpoints, potentially returning sensitive data in error messages or logs.

Impact

  • Access AWS/GCP/Azure cloud metadata services for credential theft
  • Enumerate and interact with internal HTTP services and APIs
  • Bypass firewall restrictions to reach internal network resources
  • Perform network reconnaissance from the server's perspective
  • Retrieve sensitive information disclosed in HTTP response data
  • Potential for internal service exploitation through crafted requests

Remediation

Implement comprehensive URL validation in both serialization paths by adding network restriction checks to prevent access to internal/private network ranges, localhost, and cloud metadata endpoints. The existing is_http_url() function should be enhanced to include allowlist validation rather than just scheme checking.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) bentoml >= 1.4.0, < 1.4.19 1.4.19

References

CVSS score 9.9/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L
Weakness (CWE)
CWE-918
Platform
Python (PyPI)
Package
bentoml
Disclosed
29.07.2025
Updated
11.10.2026 15:17

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-297 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-mrmq-3q62-6cc8 - CC BY 4.0

Vulnerability history: bentoml

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (17) in the archive
Total entries
17
First → latest
04.2024 07.2026
Without a fix
5
Exploited in attacks
0

Severity breakdown

  • Critical 5
  • High 10
  • Medium 2

Disclosures per year

  1. 2024: 1
  2. 2025: 7
  3. 2026: 9
Severity:
  1. High · 8.8 CVE-2026-35044 < 1.4.38 1.4.38
  2. High · 7.8 CVE-2026-35043 < 1.4.38 1.4.38
  3. High · 7.4 CVE-2026-24123 < 1.4.34 1.4.34
  4. BentoML SSRF Vulnerability in File Upload Processing this entry
    Critical · 9.9 CVE-2025-54381 >= 1.4.0, < 1.4.19 1.4.19
  5. Critical · 9.8 CVE-2025-27520 >= 1.3.4, < 1.4.3 1.4.3
  6. High · 7.5 CVE-2024-9056 <= 1.4.5 no fix
  7. Critical · 9.8 CVE-2024-9070 <= 1.4.5 no fix
  8. High · 7.5 ghsa-hh3j-9m59-p8vc <= 1.3.9 no fix
  9. Critical · 9.8 CVE-2024-2912 < 1.2.5 1.2.5

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.