{"id":"CVE-2025-54381","aliases":["CVE-2025-54381","GHSA-mrmq-3q62-6cc8","PYSEC-2026-297"],"related":[],"kind":"vulnerability","state":"published","title":"BentoML is Vulnerable to an SSRF Attack Through File Upload Processing","summary":"BentoML is a Python library for building online serving systems optimized for AI apps and model inference. In versions 1.4.0 until 1.4.19, the file upload processing system contains an SSRF vulnerability that allows unauthenticated remote attackers to force the server to make arbitrary HTTP requests. The vulnerability stems from the multipart form data and JSON request handlers, which automatically download files from user-provided URLs without validating whether those URLs point to internal network addresses, cloud metadata endpoints, or other restricted resources. The documentation explicitly promotes this URL-based file upload feature, making it an intended design that exposes all deployed services to SSRF attacks by default. Version 1.4.19 contains a patch for the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"BentoML is a Python library for building online serving systems optimized for AI apps and model inference. In versions 1.4.0 until 1.4.19, the file upload processing system contains an SSRF vulnerability that allows unauthenticated remote attackers to force the server to make arbitrary HTTP requests. The vulnerability stems from the multipart form data and JSON request handlers, which automatically download files from user-provided URLs without validating whether those URLs point to internal network addresses, cloud metadata endpoints, or other restricted resources. The documentation explicitly promotes this URL-based file upload feature, making it an intended design that exposes all deployed services to SSRF attacks by default. Version 1.4.19 contains a patch for the issue.","source":"cvelist"},{"lang":"en","text":"### Description\n\nThere'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.\n\nThe 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.\n\nThe 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.\n\n### Source - Sink Analysis\n\n**Source:** User-controlled multipart form field values and JSON request bodies containing URLs\n\n**Call Chain - Path 1 (MultipartSerde - No Validation):**\n1. HTTP POST request with multipart form data to any BentoML endpoint with file-type input parameters  \n2. `MultipartSerde.parse_request()` in `src/_bentoml_impl/serde.py:202` processes the request\n3. `form = await request.form()` parses multipart data using Starlette\n4. For file-type fields: `value = [await self.ensure_file(v) for v in form.getlist(k)]` at line 209\n5. `MultipartSerde.ensure_file()` called at lines 186-200 with user-controlled string URL\n6. **Sink:** `resp = await client.get(obj)` at line 193 - Direct HTTP request with zero validation\n\n**Call Chain - Path 2 (JSONSerde - Weak Validation):**  \n1. HTTP POST request with JSON body containing URL to endpoint with `IORootModel` + `multipart_fields`\n2. `JSONSerde.parse_request()` in `src/_bentoml_impl/serde.py:157` processes the request\n3. `body = await request.body()` extracts request body\n4. Condition check: `if issubclass(cls, IORootModel) and cls.multipart_fields:` at line 164\n5. Weak validation: `if is_http_url(url := body.decode(\"utf-8\", \"ignore\")):` at line 165 (only checks scheme)\n6. **Sink:** `resp = await client.get(url)` at line 168 - HTTP request after insufficient validation\n\n### Proof of Concept\n\nCreate a BentoML service:\n```python\nfrom pathlib import Path\nimport bentoml\n\n@bentoml.service  \nclass ImageProcessor:\n    @bentoml.api\n    def process_image(self, image: Path) -> str:\n        return f\"Processed image: {image}\"\n```\n\nDeploy and exploit:\n```bash\n# Start service (binds to 0.0.0.0:3000 by default)\nbentoml serve service.py:ImageProcessor\n\n# SSRF Attack 1 - Access AWS metadata  \ncurl -X POST http://target:3000/process_image \\\n     -F 'image=http://169.254.169.254/latest/meta-data/'\n\n# SSRF Attack 2 - Internal service enumeration\ncurl -X POST http://target:3000/process_image \\  \n     -F 'image=http://localhost:8080/admin'\n\n# SSRF Attack 3 - Internal network scanning\ncurl -X POST http://target:3000/process_image \\\n     -F 'image=http://10.0.0.1:22'\n```\n\nExpected result: Server makes HTTP requests to internal/cloud endpoints, potentially returning sensitive data in error messages or logs.\n\n### Impact\n- Access AWS/GCP/Azure cloud metadata services for credential theft\n- Enumerate and interact with internal HTTP services and APIs  \n- Bypass firewall restrictions to reach internal network resources\n- Perform network reconnaissance from the server's perspective\n- Retrieve sensitive information disclosed in HTTP response data\n- Potential for internal service exploitation through crafted requests\n\n### Remediation  \n\nImplement 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"BentoML es una librería de Python para crear sistemas de servicios en línea optimizados para aplicaciones de IA e inferencia de modelos. En las versiones 1.4.0 a 1.4.19, el sistema de procesamiento de carga de archivos contiene una vulnerabilidad SSRF que permite a atacantes remotos no autenticados forzar al servidor a realizar solicitudes HTTP arbitrarias. La vulnerabilidad se origina en los manejadores de datos de formularios multiparte y solicitudes JSON, que descargan archivos automáticamente desde URL proporcionadas por el usuario sin validar si estas URL apuntan a direcciones de red internas, endpoints de metadatos en la nube u otros recursos restringidos. La documentación promueve explícitamente esta función de carga de archivos basada en URL, lo que la convierte en un diseño que expone todos los servicios implementados a ataques SSRF por defecto. La versión 1.4.19 incluye un parche para este problema.","source":"nvd"}],"published":"2025-07-29T19:24:47.000Z","modified":"2026-10-27T15:30:03.235Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L","score":9.9,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L","score":9.9,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L","score":9.9,"rating":"CRITICAL"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L","score":9.9,"rating":"CRITICAL"}],"cwes":["CWE-918"],"affected":[{"ranges":[{"version":">= 1.4.0, < 1.4.19","status":"affected"}],"vendor":"bentoml","product":"BentoML","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"1.4.0","status":"affected","fixed":"1.4.19"}],"ecosystem":"PyPI","package":"bentoml","purl":"pkg:pypi/bentoml","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"1.4.0","fixed":"1.4.19"}],"vendor":"bentoml","product":"bentoml","cpe":"cpe:2.3:a:bentoml:bentoml:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"1.4.0","status":"affected","fixed":"1.4.19"}],"ecosystem":"PyPI","package":"bentoml","purl":"pkg:pypi/bentoml","source":"pysec"}],"references":[{"url":"https://github.com/bentoml/BentoML/security/advisories/GHSA-mrmq-3q62-6cc8","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/bentoml/BentoML/commit/534c3584621da4ab954bdc3d814cc66b95ae5fb8","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54381","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/bentoml/BentoML","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/bentoml/PYSEC-2026-297.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://pypi.org/project/bentoml","tags":["package","web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/advisories/GHSA-mrmq-3q62-6cc8","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2025-07-30T13:32:09.733Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54381","url":"https://www.cve.org/CVERecord?id=CVE-2025-54381","licence":"CVE Terms of Use","modified":"2025-07-30T15:07:10.836Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mrmq-3q62-6cc8","url":"https://github.com/advisories/GHSA-mrmq-3q62-6cc8","licence":"CC-BY-4.0","modified":"2026-10-27T15:30:03.235Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54381","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54381","licence":"Public domain","modified":"2026-06-17T09:39:57.463Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-297","url":"https://osv.dev/vulnerability/PYSEC-2026-297","licence":"CC-BY-4.0","modified":"2026-07-01T20:22:49.858Z"}],"updatedAt":"2026-11-25T22:59:01.859Z","epss":{"score":0.13849,"percentile":0.9661,"date":"2026-12-01T12:00:22.000Z"}}