Security audit fixes: docs (security.md, content.md, i18n.md, AGENT.md, skills), changelog, static-rule judgments for the merged doctor and 2FA code, hook mark for the account-rule tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 17:02:20 +01:00
co-authored by Claude Opus 5.5
parent e9f9947eb7
commit e5964d4e05
23 changed files with 283 additions and 47 deletions
+6
View File
@@ -44,6 +44,12 @@ through this procedure. Ask only when you are missing something you cannot get y
| `isAdmin(user)` / `isEditor(user)` is always `false` in a client component or in `proxy.ts` | the staff collections are not known there (no config in the browser bundle / middleware), and the predicates fail closed | `isAdmin(user, config)` with `useConfig()`, imported from `@intecion/ipal-kit/client`; in middleware `isAdmin(user, { staffCollections: ['users'] })` |
| `next build --webpack`: `'server-only' cannot be imported from a Client Component module … caused by importing '@intecion/ipal-kit/dist/index.js'` | a `'use client'` file imports the main entry (Turbopack lets it pass) | import from `@intecion/ipal-kit/client` (role predicates are there since 1.16.7; types: `import type` from the main entry is fine); data the browser needs → a prop from a server component |
| an account logs in but every page and request answers 403 / the setup screen says "The time to set up two-step verification has passed" | 2FA setup required: the account did not set TOTP up within the window (72 h from its creation, an admin's reset, or the first start after the upgrade) | an administrator opens the account in the panel → Two-step verification → "Reopen setup" (or `POST /api/ipal/two-factor/reset` `{ userId }`); every administrator is blocked: security.md "Every administrator is blocked" — a script with the Local API, `payload.update({ collection: 'users', id, data: { totpSetupFrom: new Date().toISOString() } })` (`pnpm payload run`), then log in and set TOTP up; or `requireSetup: { windowHours: false }`, redeploy, set up, put it back |
| a REST / GraphQL list from the front end returns only 100 documents (`hasNextPage: true`) although `limit` asks for more | `listLimit` (1.18.0, audit F4): callers that are not staff get at most 100 per request; staff and the Local API are not capped | page through (`page=2`), read on the server with the Local API, or `iapl({ listLimit: { max: 500 } })` / `{ exclude: ['slug'] }` / `false` (security.md "Lists and sorting") |
| `GET /api/<collection>?sort=$…` answers `400` "This sort field is not allowed." | `refuseOperatorSort` (1.18.0, audit F5): a sort naming a database operator is refused | sort by a field name; `refuseOperatorSort: false` = Payload's behaviour |
| a visitor account (customer) gets `403` on `/api/payload-locked-documents` | `lockedDocuments` (1.18.0): Payload's document locks are for staff only | intended; your own rule: `lockedDocuments: { access: { read } }`, or `false` |
| `[csp]` log lines show only `blocked=https://host` and `page=/path` (no query), or some reports are missing | `createCspReportRoute` (1.18.0, audit F1): the default line keeps origins and paths, at most 10 violations per request and 60 requests per client a minute | your own `onReport` gets the raw values; `maxReports`, `rateLimit: false` |
| a CDN or Varnish serves Markdown to visitors of an HTML page, or `Accept: text/markdown` answers `public, s-maxage` | a proxy of your own rewrites to `/md/…` without the 1.18.0 headers, or IAPL < 1.18.0 | `createProxy({ markdown: true })`, or copy `MARKDOWN_NEGOTIATED_HEADER` / `appendVary` into your proxy (content.md "content negotiation"); purge the CDN |
| saving a social profile / website address answers "Enter a full address, e.g. https://example.com." | `buildUrlField` (1.18.0, audit F2) accepts `https://` / `http://` and the `schemes` you list | type the full address; `buildUrlField({ schemes: ['mailto', 'tel'] })` for more kinds |
| after typing the code the setup screen says "we sent a link to …" / "the confirmation e-mail could not be sent", and nothing opens | 1.18.0 `twoFactor.confirmByEmail`: the first set-up waits for the link sent to the account's e-mail, opened in the browser that scanned the code | open the link in that browser, then sign in again; no mail: the link is in the server log (`[iapl] 2FA: … Link`), or an admin opens the account → "Confirm the waiting set-up"; fix e-mail (doctor `2fa-enrolment-mail`); "open this link in the browser where you scanned the code" = scan again in the browser you read mail in |
| a new account gets `403` from the API although its role allows the request | 2FA setup required: until TOTP is set up the account reaches only the setup screen | set TOTP up (log in to the panel); an integration: use an API key, or `twoFactor.requireSetup.exempt` |
| after an upgrade EVERY panel login answers `500` (also `/api/users/init`), administrators with 2FA included; log: `[iapl] 2FA: the column for "totpSetupFrom" is missing … NOBODY CAN LOG IN` or `column users.totp_setup_from does not exist` | Postgres/SQLite: the migration that adds the 2FA column has not run (needed whenever 2FA is on) | `pnpm payload migrate:create` if no migration has it, commit, and redeploy with migrations run when the new container starts — `prodMigrations` in the adapter or the start command `pnpm payload migrate && pnpm start` (deployment.md §4.3; not Coolify's Pre-deployment command, which runs in the old container); nothing is lost. `iapl-doctor` reports a project whose migrations lack `totp_setup_from` |