# Social auth callback URLs are whitelisted

- **Pattern:** `ab-002221` (`saas-authentication.social-auth.social-callback-whitelist`)
- **Severity:** info
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-002221
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-002221)

## Why it matters

Wildcard redirect URIs registered with OAuth providers allow an attacker to redirect an authorization code to any subdomain they control — including user-generated content subdomains, preview deployments, or abandoned subdomains. CWE-601 (Open Redirect) is the direct failure; CAPEC-194 documents subdomain takeover-based OAuth redirect attacks. OWASP A01 (Broken Access Control) covers the authorization code interception that results. An authorization code delivered to the wrong endpoint is equivalent to handing the attacker a short-lived session credential.

## Severity rationale

Info because wildcard redirect URIs require a subdomain takeover or other coincident vulnerability to exploit, but the configuration defect itself is a low-effort fix.

## Remediation

Register exact redirect URIs in your OAuth provider's developer console — no wildcards, no trailing slash ambiguity:

```
# OAuth provider dashboard — Allowed redirect URIs
https://app.yourdomain.com/api/auth/callback/google
https://staging.yourdomain.com/api/auth/callback/google
```

If your application constructs the redirect URI dynamically, validate it against an explicit server-side allowlist before passing it to the provider:

```ts
const ALLOWED_REDIRECTS = [
  'https://app.yourdomain.com/api/auth/callback/google',
  'https://staging.yourdomain.com/api/auth/callback/google'
]
if (!ALLOWED_REDIRECTS.includes(redirectUri)) {
  return Response.json({ error: 'Invalid redirect URI' }, { status: 400 })
}
```

Never accept `redirect_uri` from user-supplied query parameters without explicit allowlist validation.

## Detection

**The detection method for this pattern is part of AuditBuffet Pro.**

The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the [Authentication Audit](https://auditbuffet.com/audits/saas-authentication). The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.

## External references

- cwe CWE-601
- owasp A01
- capec CAPEC-194

Taxons: access-control

HTML version: https://auditbuffet.com/patterns/ab-002221
