Panel actions only from the site's own origin (adminSameOrigin); doctor reads serverURL from the running config
The plugin's panel actions (mail service connect / disconnect, test e-mail,
cookie scan, approval, crawl) act with the panel's login cookie and read a
text/plain body, which another origin sends without a CORS preflight; a
sibling subdomain is same-site and Payload's csrf list is empty without
serverURL. On 1.17.1 such a page reached connect with an admin's cookie
(it called the mail service). Now each refuses a request a browser marks as
coming from elsewhere (403 before anything is read), the rule of the 2FA
endpoints; only endpoints the plugin added; logged once per origin, naming
adminSameOrigin. adminSameOrigin: false / { origins } (owner's Q6).
iapl-doctor csrf-empty: the deep status reports originKnown (serverURL or
csrf in the running config, never the value) and it wins over the file.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
97c62f21f0
commit
03f5cf1a8d
@@ -419,6 +419,40 @@ Real panel protection:
|
||||
`/admin → /its` is a layer (it filters out dumb bots), not a lock. Treat it as an
|
||||
addition to real safeguards, not a replacement for them.
|
||||
|
||||
## Panel actions only from the site's own origin (`adminSameOrigin`, 1.17.2)
|
||||
|
||||
The plugin's panel actions act with the panel's login cookie and read their body whatever its `Content-Type`
|
||||
says: `POST /api/iapl/mail-relay/connect` and `/disconnect` (the mail service), `/api/ipal/test-email`,
|
||||
`/api/ipal/cookie-scan`, `/api/ipal/cookie-approval`, `/api/ipal/cookie-crawl`. A `text/plain` POST needs no CORS
|
||||
preflight, a page on a sibling subdomain is "same site" (the browser sends the `SameSite=Lax` cookie), and
|
||||
Payload's own CSRF list is empty unless `serverURL` or `csrf` is set. So before 1.17.2 such a page could make a
|
||||
signed-in administrator disconnect the mail service, send test mails, run scans and crawls, or approve every
|
||||
waiting cookie. Now each of them refuses (`403`, before anything is read) a request a browser marks as coming
|
||||
from elsewhere — the same rule as the 2FA endpoints: the `Origin` header, else `Sec-Fetch-Site`. Own origins: the
|
||||
host the request came in on (`Host`, `X-Forwarded-Host`), `serverURL`, Payload's `csrf` and `cors` lists, and
|
||||
`adminSameOrigin.origins`. A request with neither header (a script, `curl`, a server) passes: it rides on nobody's
|
||||
cookie. The panel's own buttons are on the site's origin and are not affected. A project's own endpoint on one of
|
||||
these paths is left as it is. The 2FA endpoints keep their own switch (`twoFactor.sameOrigin`).
|
||||
|
||||
```ts
|
||||
iapl({
|
||||
// adminSameOrigin: { origins: ['https://panel.example.com'] }, // the panel served from another origin
|
||||
// adminSameOrigin: false, // no check (as before 1.17.2)
|
||||
})
|
||||
```
|
||||
|
||||
- **Behind a proxy that rewrites `Host`** and sends no `X-Forwarded-Host`, without `serverURL`, the site's own
|
||||
panel buttons are refused. It is not silent: the first refusal of each origin is logged
|
||||
(`[iapl] a panel action from origin "…" was refused … pass iapl({ adminSameOrigin: { origins: [...] } })`), and
|
||||
`iapl-doctor` warns when the running config has neither `serverURL` nor `csrf` (`csrf-empty`). Set
|
||||
`serverURL: process.env.NEXT_PUBLIC_SERVER_URL`.
|
||||
- **Any other value** than `true`, `false` or an object with `origins` (a list of strings) stops the start.
|
||||
- **Building blocks:** `requireOwnOrigin(endpoint, origins?)` for an endpoint of your own,
|
||||
`guardAdminEndpoints(config, projectEndpoints, option)`, `ADMIN_POST_ENDPOINTS` (the list), and the 2FA ones:
|
||||
`requestFromOwnOrigin`, `ownOrigins`, `reportRefusedOrigin(req, origins?, { what, option, docs }?)`.
|
||||
- **Check:** `curl -X POST <site>/api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain'
|
||||
-b <admin cookies> -d '{"to":"a@example.com"}'` → `403`; "Send test e-mail" in the panel still works.
|
||||
|
||||
## 2FA (TOTP) — ENFORCED for every user
|
||||
|
||||
The plugin enforces two-factor authentication (TOTP) for ALL panel users —
|
||||
|
||||
Reference in New Issue
Block a user