mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #23389] [MERGED] fix: replace brittle profile_image_url allowlist with safe-scheme validation #50226
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23389
Author: @Classic298
Created: 4/3/2026
Status: ✅ Merged
Merged: 4/12/2026
Merged by: @tjbck
Base:
dev← Head:fix/profile-image-url-validation📝 Commits (8)
87d666ffix: replace brittle profile_image_url allowlist with safe-scheme validation9af9635Merge branch 'dev' into fix/profile-image-url-validationa3a385cfix: harden profile image URL validation per review feedback3d579f2fix: use structural validation instead of prefix checks90c6764fix: validate hostname not netloc, fix misleading comment8dd0153fix: constrain relative paths to known-safe prefixesa8f7b74fix: use exact matches and anchored regex, eliminate all prefix wildcarding3da3b6bfix: exclude query/fragment delimiters from user-ID regex segment📊 Changes
1 file changed (+61 additions, -20 deletions)
View changed files
📝
backend/open_webui/utils/validate.py(+61 -20)📄 Description
Fix: profile_image_url validation rejects OWUI's own paths, blocks user profile saves
Closes #23387
Problem
The profile_image_url validator used a hardcoded allowlist of two static paths and one Gravatar prefix. This rejected URLs that OWUI itself generates (like /api/v1/users/{id}/profile/image) and external OAuth avatar URLs, making it impossible to save user profiles from the admin panel.
Solution
Rewrote the validator in validate_profile_image_url to use a defense-in-depth approach with proper URL parsing:
What's rejected
Testing
30 test cases covering all accept/reject scenarios pass, including edge cases for path traversal, query injection, case sensitivity, and malformed inputs.
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.