GHSA-mrmq-3q62-6cc8 BentoML SSRF Vulnerability in File Upload Processing
DescriptionThere'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):**HTTP POST request with multipart form data to any BentoML endpoint with file-type input parameters`MultipartSerde.parse_request()` in `src/_bentoml_impl/serde.py:202` processes the request`form = await request.form()` parses multipart data using StarletteFor file-type fields: `value = [await self.ensure_file(v) for v in form.getlist(k)]` at line 209`MultipartSerde.ensure_file()` called at lines 186-200 with user-controlled string URL**Sink:** `resp = await client.get(obj)` at line 193 - Direct HTTP request with zero validation**Call Chain - Path 2 (JSONSerde - Weak Validation):**HTTP POST request with JSON body containing URL to endpoint with `IORootModel` + `multipart_fields``JSONSerde.parse_request()` in `src/_bentoml_impl/serde.py:157` processes the request`body = await request.body()` extracts request bodyCondition check: `if issubclass(cls, IORootModel) and cls.multipart_fields:` at line 164Weak validation: `if is_http_url(url := body.decode("utf-8", "ignore")):` at line 165 (only checks scheme)**Sink:** `resp = await client.get(url)` at line 168 - HTTP request after insufficient validationProof of ConceptCreate a BentoML service:Deploy and exploit:Expected result: Server makes HTTP requests to internal/cloud endpoints, potentially returning sensitive data in error messages or logs.ImpactAccess AWS/GCP/Azure cloud metadata services for credential theftEnumerate and interact with internal HTTP services and APIsBypass firewall restrictions to reach internal network resourcesPerform network reconnaissance from the server's perspectiveRetrieve sensitive information disclosed in HTTP response dataPotential for internal service exploitation through crafted requestsRemediationImplement 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.
CVSS v3.1 score: 9.9