RocketChat/Rocket.Chat · warning
Unauthorized redirect path
Error message
Unauthorized redirect path
What it means
Second anti-open-redirect check in the SAML SLO endpoint: once origins match, the redirect target's path must also equal the configured SLO path (trailing slashes normalized via replace(/\/+$/, '') || '/'). A different path on the same host gets 403 'Unauthorized redirect path'.
Source
Thrown at apps/meteor/server/lib/saml/lib/SAML.ts:446
try {
configuredURL = new URL(idpSLORedirectURL);
requestURL = new URL(userRedirect);
} catch {
res.writeHead(400);
res.end('Invalid URL format');
return;
}
if (configuredURL.origin !== requestURL.origin) {
res.writeHead(403);
res.end('Unauthorized redirect origin');
return;
}
const normalizePath = (p: string): string => p.replace(/\/+$/, '') || '/';
if (normalizePath(configuredURL.pathname) !== normalizePath(requestURL.pathname)) {
res.writeHead(403);
res.end('Unauthorized redirect path');
return;
}
res.writeHead(302, {
Location: requestURL.toString(),
});
res.end();
}
private static async processAuthorizeAction(
req: IIncomingMessage,
res: ServerResponse,
service: IServiceProviderOptions,
samlObject: ISAMLAction,
): Promise<void> {
const serviceProvider = new SAMLServiceProvider(service);View on GitHub (pinned to 2a7de45707)
Solutions
- Use exactly the configured path (trailing slashes are ignored) - derive the redirect from the configured URL
- Change the provider's idp_slo_redirect_url to the path you want; it is the only redirect target this endpoint accepts
- Note the comparison uses pathname only: query strings may differ, paths may not
Defensive patterns
Strategy: validation
Validate before calling
// Reuse the configured SLO URL verbatim; vary only the query string, never the path
const sloTarget = (configured: string, query?: Record<string, string>): string => {
const u = new URL(configured);
if (query) for (const [k, v] of Object.entries(query)) u.searchParams.set(k, v);
return u.toString();
}; Prevention
- Treat idp_slo_redirect_url as the single source of truth for the post-logout location
- When changing the configured path, update every client that builds redirect targets
- Remember the endpoint compares pathname only - align paths exactly
When it happens
Trigger: ?redirect=https://chat.example.com/some/other/path when idp_slo_redirect_url is https://chat.example.com/slo; extra path segments; a deep link to /home or /login while the setting points at the IdP's SLO path.
Common situations: Wanting to land users on the home screen after logout while the configured SLO path is different; the setting changed to a new path but clients still redirect to old locations; copy-pasted redirect targets differing by one segment.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Unauthorized redirect origin
- SLO redirect not configured
- Missing redirect parameter
- Invalid URL format
- An assertion with the same ID cannot be used more than once.
AI-assisted analysis of RocketChat/Rocket.Chat@2a7de45707 (2026-08-18).
Data as JSON: /api/errors/171ae98e95457093.
Report an issue: GitHub.