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
+5
-1
@@ -636,7 +636,11 @@ request came in on (`Host`, `X-Forwarded-Host`), `serverURL`, Payload's `csrf` a
|
||||
`twoFactor: { …, sameOrigin: { origins: ['https://app.example.com'] } }` for a front end on another domain.
|
||||
A request with neither header (a script, `curl`, a server) passes: it cannot ride on somebody's cookie.
|
||||
A default port written out (`X-Forwarded-Host: site.example:443`) is the same host.
|
||||
`sameOrigin: false` turns it off.
|
||||
**The admin's reset** (`POST /api/ipal/two-factor/reset`, "Reset two-step verification" / "Reopen setup") follows
|
||||
the same rule since 1.17.1: it reads a `text/plain` body, which a foreign page can send without a CORS preflight,
|
||||
so before a page on a sibling subdomain could reset any account's TOTP and end its sessions with an admin's
|
||||
cookie. The panel's own button is on the site's origin and is not affected.
|
||||
`sameOrigin: false` turns it off (verify, setup and the reset).
|
||||
|
||||
**Behind a reverse proxy that hides the site's address** — it rewrites `Host` and sends no `X-Forwarded-Host`
|
||||
(nginx's plain `proxy_pass`; Traefik and Coolify keep `Host`) — and without `serverURL`, the server cannot know
|
||||
|
||||
Reference in New Issue
Block a user