{"id":"CVE-2025-54381","kind":"vulnerability","aliases":["CVE-2025-54381","GHSA-mrmq-3q62-6cc8"],"related":[],"title":"BentoML SSRF Vulnerability in File Upload Processing","description":"### 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.","summary":"BentoML services that accept file-type inputs (pathlib.Path, PIL.Image.Image) download any URL a client supplies in a multipart or JSON request, with no check for internal addresses. An unauthenticated attacker can make the server request cloud metadata endpoints, localhost services and internal hosts, and see or log the responses.","severity":"critical","cvss":9.9,"epss":0.16152,"exploited":false,"exploited_at":null,"products":[{"name":"bentoml","fixed":["1.4.19"],"affected":">= 1.4.0, < 1.4.19","ecosystem":"pypi"},{"name":"bentoml","fixed":["1.4.19"],"affected":">= 1.4.0, < 1.4.19","ecosystem":"vendor"}],"ecosystems":["pypi","vendor"],"tags":["bentoml","cloud","cwe-918","ml-serving","package","python","self-hosted"],"not_affected_if":["no-file-type-parameters","version-outside-range"],"how_to_check":"- Run `pip show bentoml` and confirm the installed version is below `1.4.19`\n- Search service code for endpoints whose parameters are typed `Path` or `PIL.Image.Image`\n- Check `bentoml list` or `requirements.txt` / `pyproject.toml` for `bentoml` pinned to `>=1.4.0,<1.4.19`","fix":"- Upgrade the `bentoml` package to `1.4.19` or later\n- Until upgraded, remove file-type URL inputs from exposed endpoints or block outbound requests from the service host to internal and metadata addresses such as `169.254.169.254`","status":"open","published_at":"2025-07-29T19:24:47+00:00","first_seen_at":"2026-10-27T15:18:30+00:00","triaged_at":"2026-10-27T15:18:57+00:00","updated_at":"2026-10-27T15:32:59+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-10-27T15:18:57Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade the `bentoml` package to `1.4.19` or later\n- Until upgraded, remove file-type URL inputs from exposed endpoints or block outbound requests from the service host to internal and metadata addresses such as `169.254.169.254`","reach":"internet","title":"BentoML: file upload fields fetch attacker-supplied URLs, enabling server-side request forgery","impact":"high","summary":"BentoML services that accept file-type inputs (pathlib.Path, PIL.Image.Image) download any URL a client supplies in a multipart or JSON request, with no check for internal addresses. An unauthenticated attacker can make the server request cloud metadata endpoints, localhost services and internal hosts, and see or log the responses.","category":"package","nicknames":[],"who_cares":["bentoml","python","ml-serving","self-hosted","cloud"],"confidence":0.8,"needs_auth":"no","worst_case":"Attacker reaches cloud metadata and internal services, may steal credentials","analyst_note":"","how_to_check":"- Run `pip show bentoml` and confirm the installed version is below `1.4.19`\n- Search service code for endpoints whose parameters are typed `Path` or `PIL.Image.Image`\n- Check `bentoml list` or `requirements.txt` / `pyproject.toml` for `bentoml` pinned to `>=1.4.0,<1.4.19`","needs_analyst":false,"not_affected_if":["no-file-type-parameters","version-outside-range"],"who_is_affected":"Any BentoML service on versions from `1.4.0` up to but not including `1.4.19` that exposes an endpoint with a `Path` or `PIL.Image.Image` parameter is exposed, because the framework registers those endpoints as URL-fetching automatically. Services without such parameters, and services running on versions outside the affected range, are not affected by this report.","user_interaction":"no","needs_special_setup":"no","severity_if_unknown":"critical"},"cost_usd":0.000819,"input_tokens":4770,"output_tokens":684,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-200':322C '-2025':9A,17A '-54381':10A,18A '-8':405C '-918':24B '/latest/meta-data':487C '0.0.0.0':465C '1':256C,260C,351C,475C '10.0.0.1':516C '157':371C '164':394C '165':409C '168':421C '169.254.169.254':486C '186':321C '193':337C '2':278C,347C,366C,490C '202':283C '209':314C '22':517C '3':287C,375C,505C '3000':466C '3000/process_image':483C,498C,513C '3q62':14A '4':296C,382C '5':315C,395C '6':329C,413C '6cc8':15A '8080/admin':502C 'accept':36B 'access':198C,476C,537C,602C 'add':596C 'address':60B,137C 'affect':166C 'allow':95C 'analysi':238C 'api':553C 'arbitrari':100C 'attack':63B,97C,156C,233C,474C,489C,504C 'authent':107C 'automat':123C,140C 'aw':477C 'await':289C,303C,332C,377C,416C 'aws/gcp/azure':538C 'base':215C 'bash':460C 'basic':179C 'bentoml':1A,19A,20A,21B,33B,177C,270C,432C,440C,469C 'bentoml.api':444C 'bentoml.service':441C 'bind':463C 'bodi':250C,357C,376C,381C 'body.decode':403C 'bypass':554C 'call':253C,318C,344C 'chain':254C,345C 'check':57B,384C,411C,599C 'class':442C 'client':47B 'client.get':333C,417C 'cloud':22B,69B,202C,539C,609C 'cls':387C 'cls.multipart':390C 'comprehens':588C 'concept':429C 'condit':383C 'contain':251C,358C 'control':242C,326C 'craft':584C 'creat':430C 'credenti':543C 'curl':479C,494C,509C 'cve':8A,16A 'cwe':23B 'data':118C,267C,293C,530C,577C 'def':445C 'default':235C,468C 'deploy':229C,457C 'descript':83C 'design':225C 'direct':338C 'disclos':573C 'document':209C 'download':43B,124C 'endpoint':71B,144C,204C,271C,361C,526C,611C 'enumer':493C,545C 'error':532C 'exist':110C 'existin':613C 'expect':518C 'explicit':210C 'exploit':459C,582C 'expos':227C 'extract':379C 'f':453C,484C,499C,514C 'featur':218C 'field':245C,301C,365C,391C 'file':5A,38B,90C,125C,147C,174C,216C,274C,299C,305C,317C 'file-typ':37B,146C,273C,298C 'firewal':555C 'form':117C,244C,266C,288C 'form.getlist':310C 'framework':139C,161C 'framework-wid':160C 'ghsa':12A 'ghsa-mrmq-3q62-6cc8':11A 'handl':173C 'handler':114C 'host':32B,76B 'http':101C,261C,339C,352C,400C,422C,522C,550C,575C 'ignor':406C 'imag':447C,449C,455C,456C,485C,500C,515C 'imageprocessor':443C,472C 'impact':536C 'implement':178C,587C 'import':437C,439C 'inform':572C 'input':40B,276C 'insecur':224C 'insuffici':425C 'intend':222C 'interact':547C 'intern':59B,75B,135C,200C,491C,506C,549C,559C,580C 'internal/cloud':525C 'internal/private':604C 'iorootmodel':363C,388C 'issu':164C 'issubclass':386C 'json':53B,120C,248C,356C 'jsonserd':185C,348C 'jsonserde.parse':367C 'k':311C 'line':313C,320C,336C,393C,408C,420C 'localhost':72B,206C,501C,607C 'log':80B,535C 'make':65B,99C,157C,219C,521C 'messag':533C 'metadata':70B,203C,478C,540C,610C 'ml':26B,171C 'ml-serv':25B 'mrmq':13A 'multipart':51B,116C,243C,265C,292C,364C 'multipartserd':188C,257C 'multipartserde.ensure':316C 'multipartserde.parse':279C 'neither':195C 'network':136C,201C,507C,560C,563C,597C,605C 'obj':334C 'packag':28B 'paramet':149C,277C 'pars':291C 'path':186C,189C,196C,255C,346C,438C,450C,594C 'pathlib':436C 'pathlib.path':41B,150C 'perform':562C 'perspect':569C 'pil.image.image':42B,151C 'post':262C,353C,481C,496C,511C 'potenti':527C,578C 'prevent':601C 'process':7A,92C,284C,372C,446C,454C 'promot':211C 'proof':427C 'proper':132C 'provid':129C 'python':29B,434C 'rang':606C 'reach':558C 'real':169C 'real-world':168C 'reconnaiss':564C 'regist':141C 'remedi':586C 'remot':96C 'request':54B,68B,102C,121C,249C,263C,280C,286C,340C,354C,368C,374C,380C,423C,523C,585C 'request.body':378C 'request.form':290C 'resourc':561C 'resp':331C,415C 'respons':82B,576C 'restrict':197C,556C,598C 'result':519C 'retriev':570C 'return':452C,528C 'scan':508C 'scheme':181C,412C 'secur':163C 'see':78B 'self':31B,448C 'self-host':30B 'self.ensure':304C 'sensit':529C,571C 'serial':593C 'serialization/deserialization':113C 'serv':27B,470C 'server':67B,105C,520C,567C 'servic':34B,73B,143C,172C,207C,230C,433C,462C,492C,541C,551C,581C 'service.py':471C 'sink':237C,330C,414C 'sourc':236C,239C 'src/_bentoml_impl/serde.py':282C,370C 'ssrf':2A,87C,232C,473C,488C,503C 'starlett':295C 'start':461C 'str':451C 'string':327C 'suppli':48B 'system':93C 'target':482C,497C,512C 'theft':544C 'type':39B,148C,275C,300C 'unauthent':62B 'upload':6A,91C,175C,217C 'url':45B,130C,180C,214C,252C,328C,359C,401C,402C,418C,589C 'url-bas':213C 'use':294C 'user':128C,241C,325C 'user-control':240C,324C 'user-provid':127C 'utf':404C 'v':306C,308C 'valid':133C,182C,192C,259C,343C,350C,397C,426C,590C 'valu':246C,302C 'vulner':3A,109C,153C 'weak':349C,396C 'whatsoev':193C 'wide':162C 'without':106C,131C 'world':170C 'x':480C,495C,510C 'zero':342C","nicknames":[],"mitigations":[],"who_affected":"Any BentoML service on versions from `1.4.0` up to but not including `1.4.19` that exposes an endpoint with a `Path` or `PIL.Image.Image` parameter is exposed, because the framework registers those endpoints as URL-fetching automatically. Services without such parameters, and services running on versions outside the affected range, are not affected by this report.","tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2025-07-29T19:24:47+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:L","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-mrmq-3q62-6cc8","url":"https://github.com/advisories/GHSA-mrmq-3q62-6cc8","severity":"critical","published_at":"2025-07-29T19:24:47+00:00","modified_at":"2026-10-27T15:16:09+00:00","first_seen_at":"2026-10-27T15:18:30+00:00","fetched_at":"2026-10-27T15:18:30+00:00","note":null},{"source":"nvd","external_id":"CVE-2025-54381","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54381","severity":null,"published_at":"2025-07-29T23:15:32+00:00","modified_at":"2026-06-17T09:39:57+00:00","first_seen_at":"2026-10-27T15:32:59+00:00","fetched_at":"2026-10-27T15:32:59+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}