From 3da3b6b929bd9c003a05f03d6a59a6a4298181a7 Mon Sep 17 00:00:00 2001 From: DrMelone <27028174+Classic298@users.noreply.github.com> Date: Fri, 3 Apr 2026 22:50:54 +0200 Subject: [PATCH] fix: exclude query/fragment delimiters from user-ID regex segment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change [^/]+ to [^/?#]+ so that inputs like /api/v1/users/alice?x=1/profile/image are rejected — the browser would interpret ? as the query string start, making the actual request target /api/v1/users/alice instead of the intended route. --- backend/open_webui/utils/validate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/utils/validate.py b/backend/open_webui/utils/validate.py index ae9d2ef4b2..4decac5eb7 100644 --- a/backend/open_webui/utils/validate.py +++ b/backend/open_webui/utils/validate.py @@ -3,10 +3,10 @@ import re from urllib.parse import urlparse -# Matches the OWUI-generated profile image route. The ``[^/]+`` segment -# accepts any user-ID without allowing path-traversal across segments, +# Matches the OWUI-generated profile image route. ``[^/?#]+`` accepts +# any user-ID without allowing path-traversal or query/fragment injection, # and the ``$`` anchor rejects trailing path components. -_USER_PROFILE_IMAGE_RE = re.compile(r'^/api/v1/users/[^/]+/profile/image$') +_USER_PROFILE_IMAGE_RE = re.compile(r'^/api/v1/users/[^/?#]+/profile/image$') # Validates MIME type and structure of base64 data URIs. Only the prefix # is checked — validating the full base64 payload would mean running a