← Blog

Claude skill open redirect vulnerabilities — SA-SKL-REDIRECT3

Open redirects are exploited primarily for phishing — an attacker uses a trusted domain's redirect endpoint as a hop that makes the attack URL appear legitimate to email scanners and human readers. SA-SKL-REDIRECT3 covers four patterns: an unvalidated ?next= post-login redirect that accepts absolute URLs to attacker domains; a client-side SPA that assigns location.href from a URL parameter without checking the hostname; an OAuth redirect_uri validated only with a substring match so evil.com/oauth-callback passes; and an Express route that calls res.redirect(req.query.url) without any hostname validation.

By SkillAudit  |  7 Nov 2026

Open redirect as a trust amplifier

Open redirect vulnerabilities are routinely underrated because they do not directly compromise the vulnerable server. The real damage is reputational and downstream: a URL of the form https://app.skillaudit.dev/redirect?next=https://evil.com/phishing passes corporate email scanners that check the first domain, appears legitimate in browser status bars and URL previews, and inherits the trust users place in the skillaudit.dev domain. When chained with an OAuth flow, an open redirect can be used to intercept authorization codes — the attacker uses the open redirect as the OAuth redirect_uri, directing the authorization code to their server via the legitimate application's redirect endpoint.

OAuth-specific open redirects (REDIRECT3-003) are categorized as CRITICAL rather than HIGH because they can directly compromise OAuth tokens. For the other three patterns, the CVSS base score is typically 6.1 (medium) but the exploited impact is high in real-world phishing campaigns targeting authenticated users of a trusted SaaS application.

SA-SKL-REDIRECT3 in scope: REDIRECT3-001 (unvalidated ?next= post-login redirect to external domain), REDIRECT3-002 (SPA location.href = urlParam without hostname check), REDIRECT3-003 (OAuth redirect_uri substring validation bypass — CRITICAL), REDIRECT3-004 (Express res.redirect(req.query.url) without domain validation). Each finding includes SkillAudit detection rules and correct fixes.

REDIRECT3-001 — ?next= parameter not validated against path prefix allowlist

An MCP skill's login flow accepts a ?next= query parameter that specifies where to redirect the user after successful authentication. The intent is to allow deep-linking: a user who visits /dashboard/settings while logged out is redirected to login, and after authentication is sent back to /dashboard/settings. The implementation checks only that the parameter is non-empty, then passes it directly to res.redirect(). An attacker crafts a phishing email with a link to https://app.skillaudit.dev/login?next=https://evil.com/harvest-credentials. After the user authenticates, they are silently redirected to the phishing site with the legitimate session established.

The correct validation strategy for a post-login redirect is to accept only path-only values: the redirect target must start with /, must not contain :// (which would indicate an absolute URL), and must not start with // (protocol-relative URL that is equivalent to an absolute URL). Parse the value with the WHATWG URL API relative to the application's base URL and compare the resulting hostname to the expected hostname. Reject anything that navigates outside the application's origin.

// VULNERABLE — ?next= accepts any URL including external domains
import express from 'express';
const router = express.Router();

router.post('/login', async (req, res) => {
  const { username, password } = req.body;
  const next = req.query.next as string | undefined;

  const user = await authenticateUser(username, password);
  if (!user) {
    return res.status(401).render('login', { error: 'Invalid credentials' });
  }

  req.session.userId = user.id;

  // VULNERABLE: next is used directly without validation
  // Attacker crafts: /login?next=https://evil.com/phishing-page
  // After successful login, user is sent to evil.com
  if (next) {
    return res.redirect(next);
  }
  res.redirect('/dashboard');
});

// Also vulnerable — JavaScript client-side:
// const params = new URLSearchParams(location.search);
// window.location.href = params.get('returnUrl'); // No validation at all
// FIXED — validate redirect target is a safe path within the same origin
import express from 'express';

const ALLOWED_HOST = 'app.skillaudit.dev';
const SAFE_PATH_RE = /^\/[a-zA-Z0-9\-._~!$&'()*+,;=:@/]*$/; // RFC 3986 path chars

function validateRedirectTarget(next: string | undefined, fallback = '/dashboard'): string {
  if (!next || typeof next !== 'string') return fallback;

  // Reject protocol-relative URLs (//evil.com) and absolute URLs (https://evil.com)
  if (next.startsWith('//') || /^[a-zA-Z][a-zA-Z0-9+\-.]*:/.test(next)) {
    return fallback;
  }

  // Must start with / (path-only, no host)
  if (!next.startsWith('/')) return fallback;

  // Parse relative to our origin to catch edge cases like /%5Cevil.com
  try {
    const resolved = new URL(next, `https://${ALLOWED_HOST}`);
    // Reject if parsing resolved to a different hostname
    if (resolved.hostname !== ALLOWED_HOST) return fallback;
    // Reject paths that don't match our safe path character set
    if (!SAFE_PATH_RE.test(resolved.pathname)) return fallback;
    // Return only the path+query+hash — no host component
    return resolved.pathname + resolved.search + resolved.hash;
  } catch {
    return fallback;
  }
}

const router = express.Router();

router.post('/login', async (req, res) => {
  const { username, password } = req.body;
  const next = req.query.next as string | undefined;

  const user = await authenticateUser(username, password);
  if (!user) {
    return res.status(401).render('login', { error: 'Invalid credentials' });
  }

  req.session.userId = user.id;

  // Safe redirect — always resolves to a path within our own origin
  res.redirect(validateRedirectTarget(next, '/dashboard'));
});
HIGH
SA-SKL-REDIRECT3-001 — Post-login ?next= or ?returnUrl= parameter passed directly to res.redirect() without validating that the target is a path within the application's own origin; attacker crafts a phishing link using the application's trusted domain as a hop that redirects to a credential-harvesting page after authentication; fix by rejecting any value that starts with // or matches an absolute URL pattern, then parsing with the WHATWG URL API relative to the application origin and comparing the resulting hostname. Detection: SkillAudit flags Express route handlers where res.redirect(req.query.*) or res.redirect(req.body.*) is called without an intervening hostname validation function.

REDIRECT3-002 — SPA client-side location.href assignment from URL parameter

A React or Vue SPA companion to an MCP skill reads a redirect or to query parameter from the current page URL and assigns it directly to window.location.href or the router's navigation function. Because the assignment happens client-side in JavaScript, server-side redirect validation does not apply. The vulnerability pattern typically appears in a "magic link" handler, an email confirmation page, or an OAuth callback that extracts a post-action redirect from the URL. An attacker who can influence the URL (via a link in a phishing email, an XSS in another feature, or a referral campaign that appends UTM parameters with arbitrary values) can redirect the user to any hostname after the action completes.

The fix is to parse the redirect target with the WHATWG URL constructor relative to window.location.origin and check that the resulting hostname equals window.location.hostname. If the hostname matches, navigate to the validated path. If not, navigate to a safe default. This check must happen on the client side — the server-side validation of REDIRECT3-001 does not cover client-side navigation.

// VULNERABLE — SPA assigns location.href from URL parameter without hostname check
// React component in an MCP skill companion web app

import { useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';

function EmailConfirmationPage() {
  const [params] = useSearchParams();

  useEffect(() => {
    async function confirm() {
      const token = params.get('token');
      const redirectTo = params.get('redirect'); // User-controlled

      await fetch('/api/auth/confirm-email', {
        method: 'POST',
        body: JSON.stringify({ token }),
        headers: { 'Content-Type': 'application/json' },
      });

      // VULNERABLE: redirectTo can be "https://evil.com/phishing"
      // Attacker emails: https://app.skillaudit.dev/confirm?token=REAL&redirect=https://evil.com
      if (redirectTo) {
        window.location.href = redirectTo; // No hostname validation
      } else {
        window.location.href = '/dashboard';
      }
    }
    confirm();
  }, []);

  return <p>Confirming your email...</p>;
}
// FIXED — parse URL and validate hostname before navigating
import { useEffect } from 'react';
import { useSearchParams, useNavigate } from 'react-router-dom';

function safeRedirectTarget(redirectTo: string | null, fallback = '/dashboard'): string {
  if (!redirectTo) return fallback;

  try {
    // Parse relative to current origin — catches absolute URLs and protocol-relative
    const resolved = new URL(redirectTo, window.location.origin);

    // Must be on the same hostname
    if (resolved.hostname !== window.location.hostname) {
      console.warn('Open redirect attempt blocked:', redirectTo);
      return fallback;
    }

    // Return only path + search + hash — strip any hostname/protocol
    return resolved.pathname + resolved.search + resolved.hash;
  } catch {
    return fallback;
  }
}

function EmailConfirmationPage() {
  const [params] = useSearchParams();
  const navigate = useNavigate();

  useEffect(() => {
    async function confirm() {
      const token = params.get('token');
      const redirectTo = params.get('redirect');

      try {
        const response = await fetch('/api/auth/confirm-email', {
          method: 'POST',
          body: JSON.stringify({ token }),
          headers: { 'Content-Type': 'application/json' },
        });

        if (!response.ok) throw new Error('Confirmation failed');

        // Validate redirect target before navigating
        const safePath = safeRedirectTarget(redirectTo, '/dashboard');
        // Use react-router navigate (keeps us in the SPA) instead of location.href
        navigate(safePath, { replace: true });
      } catch {
        navigate('/error?reason=confirmation-failed', { replace: true });
      }
    }
    confirm();
  }, []);

  return <p>Confirming your email...</p>;
}
HIGH
SA-SKL-REDIRECT3-002 — SPA client-side code that assigns window.location.href = urlParams.get('redirect') without parsing and validating the hostname allows an attacker to redirect users to external domains after any in-app action triggered via a crafted URL; fix by parsing the target with new URL(redirectTo, window.location.origin) and comparing resolved.hostname to window.location.hostname before navigating, using the router's navigate function rather than direct location.href assignment. Detection: SkillAudit flags React/Vue component files that contain window.location.href = or location.replace( where the right-hand side derives from useSearchParams, URLSearchParams, or location.search without an intervening hostname check.

REDIRECT3-003 — OAuth redirect_uri substring validation bypass — CRITICAL

An OAuth authorization server or OAuth client library that validates the redirect_uri parameter using a substring or startsWith check instead of an exact string match is vulnerable to a redirect URI manipulation attack. Consider a registered redirect URI of https://app.skillaudit.dev/oauth/callback. A startsWith check passes for https://app.skillaudit.dev/oauth/callback.evil.com (suffix added), https://app.skillaudit.dev/oauth/callback/../../../evil.com (path traversal), and https://app.skillaudit.devl.evil.com/oauth/callback (subdomain confusion if the check is on the wrong end). An attacker who registers a domain matching the bypass pattern receives the authorization code in the redirect, then exchanges it for an access token using the legitimate client secret.

OAuth 2.0 (RFC 6749 §4.1.3) and OAuth 2.1 both require exact string matching of the redirect_uri against the registered value. The comparison must be case-sensitive and must compare the full URL including scheme, host, port (if non-default), path, and query string. Fragment identifiers are not sent by browsers in HTTP requests, so the comparison should not need to handle them. For MCP skills that implement their own OAuth server or proxy, an exact set membership check against a list of registered URIs is the correct implementation.

// VULNERABLE — redirect_uri validated with startsWith (prefix match only)
import express from 'express';

// Registered redirect URIs for the OAuth client
const REGISTERED_REDIRECT_URIS = [
  'https://app.skillaudit.dev/oauth/callback',
  'https://app.skillaudit.dev/oauth/callback/github',
];

function isRedirectUriAllowed(redirectUri: string): boolean {
  // VULNERABLE: startsWith allows suffix bypasses
  // 'https://app.skillaudit.dev/oauth/callback.evil.com' passes this check
  // 'https://app.skillaudit.dev/oauth/callbackXYZmalicious' also passes
  return REGISTERED_REDIRECT_URIS.some(registered =>
    redirectUri.startsWith(registered) // <-- substring match, not exact match
  );
}

const authRouter = express.Router();

authRouter.get('/oauth/authorize', (req, res) => {
  const { client_id, redirect_uri, state, code_challenge } = req.query;

  // redirect_uri validation is bypassed by: ?redirect_uri=https://app.skillaudit.dev/oauth/callback.evil.com/steal
  if (!isRedirectUriAllowed(redirect_uri as string)) {
    return res.status(400).send('Invalid redirect_uri');
  }

  // ... generate authorization code ...
  const code = generateAuthCode(client_id as string, redirect_uri as string);
  // Authorization code sent to attacker's server:
  res.redirect(`${redirect_uri}?code=${code}&state=${state}`);
});
// FIXED — exact string match against the registered URI set
import express from 'express';

// Registered redirect URIs — exact strings, no prefix matching
const REGISTERED_REDIRECT_URIS = new Set([
  'https://app.skillaudit.dev/oauth/callback',
  'https://app.skillaudit.dev/oauth/callback/github',
]);

function isRedirectUriAllowed(redirectUri: string): boolean {
  // FIXED: exact Set membership — no prefix, suffix, or substring matching
  return REGISTERED_REDIRECT_URIS.has(redirectUri);
}

// Defense-in-depth: also validate the URI structure before the set check
function validateRedirectUri(redirectUri: unknown): string {
  if (typeof redirectUri !== 'string') {
    throw new Error('redirect_uri must be a string');
  }

  // Parse and normalize before comparing to prevent encoding tricks
  let parsed: URL;
  try {
    parsed = new URL(redirectUri);
  } catch {
    throw new Error('redirect_uri is not a valid URL');
  }

  // Must be HTTPS (except localhost for development)
  if (parsed.protocol !== 'https:' && parsed.hostname !== 'localhost') {
    throw new Error('redirect_uri must use HTTPS');
  }

  // Must not contain fragment (browsers don't send fragments, so this is suspicious)
  if (parsed.hash) {
    throw new Error('redirect_uri must not contain a fragment');
  }

  // Exact set membership check on the normalized href
  const normalized = parsed.href;
  if (!isRedirectUriAllowed(normalized)) {
    throw new Error('redirect_uri is not registered for this client');
  }

  return normalized;
}

const authRouter = express.Router();

authRouter.get('/oauth/authorize', (req, res) => {
  const { client_id, redirect_uri, state, code_challenge, code_challenge_method } = req.query;

  let validatedUri: string;
  try {
    validatedUri = validateRedirectUri(redirect_uri);
  } catch (err) {
    // Return error WITHOUT redirecting — RFC 6749 §4.1.2.1
    // Never redirect to an invalid or unregistered redirect_uri
    return res.status(400).json({
      error: 'invalid_request',
      error_description: (err as Error).message,
    });
  }

  const code = generateAuthCode(client_id as string, validatedUri, {
    state: state as string,
    codeChallenge: code_challenge as string,
    codeChallengeMethod: code_challenge_method as string,
  });

  const params = new URLSearchParams({ code, state: state as string });
  res.redirect(`${validatedUri}?${params}`);
});
CRITICAL
SA-SKL-REDIRECT3-003 — OAuth redirect_uri validated with startsWith, includes, or a regular expression prefix match instead of exact string equality allows an attacker to register a URI like https://app.skillaudit.dev/oauth/callback.evil.com that passes the check and receives the authorization code in the redirect, enabling account takeover via token theft; fix by using exact Set.has() membership against normalized registered URIs, normalizing both the registered and submitted URI with the WHATWG URL API before comparison, and returning a 400 response (never a redirect) when the URI is invalid. Detection: SkillAudit flags redirect_uri validation logic that uses startsWith, includes, or indexOf for comparison rather than strict equality or Set membership.

REDIRECT3-004 — Express res.redirect to external domain via req.query.url

An Express API route intended to provide a convenience redirect for external documentation links or asset URLs passes the target URL directly from a query parameter to res.redirect(). The developer's intent is to track outbound link clicks while redirecting to external resources. However, any URL can be supplied in the query parameter — including URLs to phishing pages, malware distribution sites, or attacker-controlled OAuth servers. Because the redirect originates from the application's trusted domain, email scanners and security proxies may not flag it. The 301 Moved Permanently response also caches the redirect in browser history, meaning once exploited the browser may continue redirecting without hitting the server again.

The fix is to reject any redirect target whose hostname does not exactly match skillaudit.dev (or the application's configured domain). For link-tracking functionality, use an allowlist of external domains (e.g., documentation sites) rather than accepting arbitrary URLs. Use only path-relative redirects where possible — a redirect to /docs instead of https://skillaudit.dev/docs is safer and simpler.

// VULNERABLE — res.redirect to req.query.url without any domain validation
import express from 'express';
const app = express();

// Intent: track clicks on outbound links
// Vulnerability: any URL is accepted and redirected
app.get('/go', (req, res) => {
  const url = req.query.url as string;
  const ref = req.query.ref as string; // UTM tracking

  if (!url) {
    return res.status(400).send('Missing url parameter');
  }

  // Log the click for analytics
  console.log('Outbound click', { url, ref, ip: req.ip, ua: req.headers['user-agent'] });

  // VULNERABLE: res.redirect accepts any URL
  // Attacker crafts: https://app.skillaudit.dev/go?url=https://evil.com/malware
  // The redirect origin is app.skillaudit.dev — appears trustworthy
  // 301 response caches in browser — attacker can "poison" a user's cache
  res.redirect(301, url);
});

// Also seen as:
app.get('/redirect', (req, res) => {
  const { destination } = req.query;
  res.redirect(destination as string); // No validation at all
});
// FIXED — validate hostname against allowlist; use path-only redirects where possible
import express from 'express';

// Allowlist of trusted external domains for outbound link tracking
const ALLOWED_EXTERNAL_DOMAINS = new Set([
  'docs.skillaudit.dev',
  'github.com',
  'npmjs.com',
]);

const OWN_DOMAIN = 'skillaudit.dev';

function validateOutboundUrl(urlString: string): URL | null {
  if (!urlString || typeof urlString !== 'string') return null;

  let parsed: URL;
  try {
    parsed = new URL(urlString);
  } catch {
    return null; // Not a valid URL
  }

  // Must be HTTP or HTTPS — block javascript:, data:, etc.
  if (!['http:', 'https:'].includes(parsed.protocol)) return null;

  const hostname = parsed.hostname.toLowerCase();

  // Allow own domain and subdomains
  if (hostname === OWN_DOMAIN || hostname.endsWith(`.${OWN_DOMAIN}`)) {
    return parsed;
  }

  // Allow explicitly allowlisted external domains (exact match — no subdomain wildcards)
  if (ALLOWED_EXTERNAL_DOMAINS.has(hostname)) {
    return parsed;
  }

  return null; // All other domains are rejected
}

const app = express();

app.get('/go', (req, res) => {
  const urlParam = req.query.url as string | undefined;
  const ref = req.query.ref as string | undefined;

  const validated = validateOutboundUrl(urlParam ?? '');
  if (!validated) {
    // Log the rejected attempt — may indicate active probing
    console.warn('Rejected open redirect attempt', { url: urlParam, ip: req.ip });
    return res.redirect(302, '/');
  }

  // Log the click for analytics before redirecting
  console.log('Outbound click', {
    url: validated.href,
    hostname: validated.hostname,
    ref,
    ip: req.ip,
    ua: req.headers['user-agent'],
  });

  // Use 302 (temporary) instead of 301 (permanent) to prevent browser caching
  // of redirects that could be used to poison browsers after the endpoint is fixed
  res.redirect(302, validated.href);
});
HIGH
SA-SKL-REDIRECT3-004 — Express route calling res.redirect(req.query.url) without hostname validation redirects the browser to any attacker-supplied domain using the application's trusted origin as the redirect source, bypassing email and proxy security scanners; a 301 Permanent redirect additionally caches the redirect in the browser, persisting the attack after remediation; fix by parsing the target URL, allowing only the application's own domain and an explicit allowlist of external domains, and using 302 instead of 301. Detection: SkillAudit flags Express route handlers where res.redirect( receives a value derived from req.query, req.body, or req.params without an intervening URL hostname validation step.

Detection summary

ID Severity Pattern Fix
REDIRECT3-001 HIGH ?next= or ?returnUrl= post-login redirect to attacker domain — trusted domain as phishing hop Reject absolute URLs; parse with WHATWG URL API; require matching hostname; return path-only
REDIRECT3-002 HIGH SPA location.href = urlParams.get('redirect') without hostname check — client-side open redirect new URL(target, window.location.origin) then compare .hostname to window.location.hostname
REDIRECT3-003 CRITICAL OAuth redirect_uri validated with startsWith — evil.com/oauth-callback suffix passes check, receives auth code Exact Set.has() match against normalized registered URIs; return 400 (never redirect) on invalid URI
REDIRECT3-004 HIGH Express res.redirect(req.query.url) — 301 cached redirect to arbitrary external domain Domain allowlist check; use 302; log rejected attempts; path-only redirects where possible

Related patterns: SA-SKL-REDIRECT1 covers foundational open redirect patterns in MCP skills. SA-SKL-OAUTH1 covers OAuth PKCE flow security where open redirects chain into auth code theft. SA-SKL-REDIRECT2 covers redirect chain attacks where intermediate redirects bypass validation at the first hop.