apply security audit
This commit is contained in:
@@ -30,8 +30,14 @@ const LoginCallback: React.FC = () => {
|
||||
|
||||
try {
|
||||
await login(code);
|
||||
// Navigate to the originally intended page, falling back to the dashboard
|
||||
const from = sessionStorage.getItem('auth_redirect_from') || '/dashboard';
|
||||
// Navigate to the originally intended page, falling back to the dashboard.
|
||||
// Validate that the stored path is a safe internal path: must start with '/'
|
||||
// but must NOT start with '//' (protocol-relative redirect).
|
||||
const rawFrom = sessionStorage.getItem('auth_redirect_from');
|
||||
const from =
|
||||
rawFrom && rawFrom.startsWith('/') && !rawFrom.startsWith('//')
|
||||
? rawFrom
|
||||
: '/dashboard';
|
||||
sessionStorage.removeItem('auth_redirect_from');
|
||||
navigate(from, { replace: true });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user