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
+1
-1
@@ -394,7 +394,7 @@ export const iapl = (options: IaplOptions): Plugin => {
|
||||
}
|
||||
}
|
||||
// An admin resets an account's TOTP (lost phone) / reopens its setup window.
|
||||
config.endpoints = [...(config.endpoints ?? []), buildTwoFactorResetEndpoint(target, { access: tf.resetAccess })]
|
||||
config.endpoints = [...(config.endpoints ?? []), buildTwoFactorResetEndpoint(target, { access: tf.resetAccess, ...(guards.ownOrigin ? { ownOrigin: guards.ownOrigin } : {}) })]
|
||||
// Called by Payload on every request before any access function: guards whatever
|
||||
// the live config has that was added after iapl (start, dev hot reload).
|
||||
const sweep = buildGuardStrategy(adoptConfig)
|
||||
|
||||
Reference in New Issue
Block a user