Skip to content

[BUG Follow-up] Extend clickjacking protections to all auth pages#496

Merged
benjaminfh merged 1 commit intomasterfrom
codex/2026-02-25/github-mention-bug]-fix-clickjacking-vurnerability
Feb 25, 2026
Merged

[BUG Follow-up] Extend clickjacking protections to all auth pages#496
benjaminfh merged 1 commit intomasterfrom
codex/2026-02-25/github-mention-bug]-fix-clickjacking-vurnerability

Conversation

@benjaminfh
Copy link
Owner

Motivation

  • The login page had frame protection added previously but the protection needed to be extended to all auth-related public routes to prevent iframe-based clickjacking across the auth surface.
  • The change centralizes header injection so anti-framing headers are applied consistently regardless of response type for matching auth routes.

Description

  • Added shouldApplyClickjackingProtection and withClickjackingHeaders helpers to middleware.ts to centralize the anti-framing logic and decisioning for protected paths.
  • The middleware now sets X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors 'none' for matching routes (/login, /check-email, /forgot-password, /reset-password, and /auth/*).
  • Headers are applied across response types (normal NextResponse.next(), redirect responses, maintenance responses, and the incomplete-env 500 response) by wrapping returned responses with withClickjackingHeaders when the request pathname matches.
  • Updated tests/server/middleware.test.ts to assert the new anti-framing headers on the authenticated /login redirect and on other auth pages like /forgot-password and /check-email.

Testing

  • Ran the targeted test file with npm test -- tests/server/middleware.test.ts using vitest, and all tests passed (4 tests, 1 file).
  • The updated tests specifically verify the x-frame-options and content-security-policy headers on protected auth pages and on the login redirect, and they succeeded.

Codex Task

Apply anti-framing headers to login and related auth pages so iframe-based clickjacking is blocked consistently. This updates middleware response handling to set headers on both normal and redirect responses without altering auth flow behavior.

- add dedicated helpers to target auth-related routes for clickjacking protection

- set X-Frame-Options and CSP frame-ancestors headers for applicable middleware responses

- cover login redirect and additional auth pages with middleware tests
@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
threds Ready Ready Preview, Comment Feb 25, 2026 3:28pm

@supabase
Copy link

supabase bot commented Feb 25, 2026

Updates to [Preview Branch (codex/2026-02-25/github-mention-bug]-fix-clickjacking-vurnerability) ↗︎](https://supabase.com/dashboard/project/mersykfigxgsnbbmjbvl)

Deployments Status Updated
Database Wed, 25 Feb 2026 15:27:39 UTC
Services Wed, 25 Feb 2026 15:27:39 UTC
APIs Wed, 25 Feb 2026 15:27:39 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Wed, 25 Feb 2026 15:27:49 UTC
Migrations Wed, 25 Feb 2026 15:27:50 UTC
Seeding Wed, 25 Feb 2026 15:27:53 UTC
Edge Functions Wed, 25 Feb 2026 15:27:53 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@benjaminfh benjaminfh merged commit bf3aee0 into master Feb 25, 2026
6 checks passed
@benjaminfh benjaminfh deleted the codex/2026-02-25/github-mention-bug]-fix-clickjacking-vurnerability branch February 25, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant