mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
fix(ui): validate protocol in useBaseUrl to prevent DOM-based XSS
Only allow http: or https: protocols when constructing the base URL from window.location, blocking javascript: and data: scheme injection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0290c7bc00
commit
dfe4bf6cef
1 changed files with 3 additions and 1 deletions
|
|
@ -7,7 +7,9 @@ export const useBaseUrl = () => {
|
|||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
const { protocol, host } = window.location;
|
||||
setBaseUrl(`${protocol}//${host}`);
|
||||
if (protocol === "http:" || protocol === "https:") {
|
||||
setBaseUrl(`${protocol}//${host}`);
|
||||
}
|
||||
}
|
||||
}, []); // Removed router dependency
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue