2FA reset endpoint: only from the site's own origin (twoFactor.sameOrigin)
POST /api/ipal/two-factor/reset reads a text/plain body, which another origin can send without a CORS preflight; a sibling subdomain is same-site, so the browser sends the admin's SameSite=Lax cookie, and Payload's csrf list is empty without serverURL. Such a page could reset any account's TOTP and end its sessions (reproduced on SQLite, Postgres, MongoDB). Now the endpoint takes the same origin rule as verify and setup, before it reads or changes anything; twoFactor.sameOrigin: false leaves it out, and buildTwoFactorResetEndpoint takes ownOrigin for own wiring. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
91770ec17f
commit
6ca0730c08
@@ -0,0 +1,15 @@
|
||||
/** twoFactor.sameOrigin: false leaves the origin check of the 2FA reset endpoint out (twoFactorResetOriginSuite.ts). */
|
||||
import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { SIBLING, site } from './twoFactorResetOriginSuite.js'
|
||||
|
||||
vi.mock('server-only', () => ({}))
|
||||
vi.mock('next/headers.js', async () => (await import('./http/server.js')).nextHeadersMock)
|
||||
|
||||
describe('the 2FA reset endpoint with sameOrigin: false', () => {
|
||||
test('a request from a sibling subdomain is taken, as before 1.17.1', async () => {
|
||||
const { reset, secretOf } = await site(false)
|
||||
expect((await reset(SIBLING)).status).toBe(200)
|
||||
expect(await secretOf()).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user