mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +08:00
fix: a security issue related to open external (#13864)
This commit is contained in:
@@ -14,6 +14,7 @@ const trustedDomain = [
|
||||
];
|
||||
|
||||
const logger = new DebugLogger('redirect_proxy');
|
||||
const ALLOWED_PROTOCOLS = new Set(['http:', 'https:']);
|
||||
|
||||
/**
|
||||
* /redirect-proxy page
|
||||
@@ -32,6 +33,11 @@ export const loader: LoaderFunction = async ({ request }) => {
|
||||
try {
|
||||
const target = new URL(redirectUri);
|
||||
|
||||
if (!ALLOWED_PROTOCOLS.has(target.protocol)) {
|
||||
logger.warn('Blocked redirect with disallowed protocol', target.protocol);
|
||||
return { allow: false };
|
||||
}
|
||||
|
||||
if (
|
||||
target.hostname === window.location.hostname ||
|
||||
trustedDomain.some(domain =>
|
||||
@@ -46,7 +52,8 @@ export const loader: LoaderFunction = async ({ request }) => {
|
||||
return { allow: false };
|
||||
}
|
||||
|
||||
return { allow: true };
|
||||
logger.warn('Blocked redirect to untrusted domain', redirectUri);
|
||||
return { allow: false };
|
||||
};
|
||||
|
||||
export const Component = () => {
|
||||
|
||||
Reference in New Issue
Block a user