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
+18 -5
View File
@@ -240,7 +240,7 @@ site), **P** = a test in the panel. Full code: PROGRAMISTA.md §2.
| 3a | **Search Console / Bing** | recommended: **domain verification via DNS** (TXT record, deployment.md §6) — the plugin does nothing, the verification fields stay empty; only for URL-prefix verification: code in **Site settings → Search engines** (Google, Bing, Yandex), `generatePageMetadata` adds the `<meta>` itself; sitemap `https://<domain>/sitemap.xml` submitted in GSC and Bing | panel (optional), `verificationFrom` | P |
| 4 | **SEO** — structured data | layout: `<SiteProviders shell={…}>` gives `WebSite` + `Organization` (`sameAs`) from Site settings; local business → `createContentHelpers({ siteJsonLd })` with `buildLocalBusinessJsonLd` (`type`, hours → `formatOpeningHours`); navigation: `<SiteProviders jsonLd={[buildNavigationJsonLd(…)]}>`; page: `createPageRoute` adds `getPageJsonLd` (WebPage/BlogPosting, breadcrumbs, FAQ — `pageJsonLd: { faq }`) | `getSiteShell`, `SiteProviders`, `build*JsonLd`, `getPageJsonLd` | A, S |
| 5 | **GEO** — llms | `src/app/llms.txt/route.ts` (`llmsRoute`) and `src/app/llms-full.txt/route.ts` (`llmsFullRoute`) from `lib/content`; the `buildSummaryField()` field in Pages, `summaryField: 'aiSummary'` in `createContentHelpers` | `llmsRoute`, `llmsFullRoute`, `buildSummaryField` | A, S |
| 6 | **GEO** — Markdown | `src/app/md/[locale]/[[...slug]]/route.ts` (single-language: `src/app/md/[[...slug]]/route.ts`) = `export { markdownRoute as GET } from '@/lib/content'`; `createContentHelpers({ markdownAlternate: true })` (link in `<head>`); `createProxy(…, { NextResponse, markdown: true })` (without it `/md/…` gets redirected to a language) | `markdownRoute`, `markdownAlternate`, `createProxy({ markdown })` | A, S |
| 6 | **GEO** — Markdown | `src/app/md/[locale]/[[...slug]]/route.ts` (single-language: `src/app/md/[[...slug]]/route.ts`) = `export { markdownRoute as GET } from '@/lib/content'`; `createContentHelpers({ markdownAlternate: true })` (link in `<head>`); `createProxy(…, { NextResponse, markdown: true })` (without it `/md/…` gets redirected to a language; the `Accept: text/markdown` answer at a page URL is `private, no-store` + `Vary: Accept` since 1.18.0 — check: `curl -sD- -o/dev/null -H 'Accept: text/markdown' localhost:3000/pl \| grep -i cache-control` → `private, no-store`) | `markdownRoute`, `markdownAlternate`, `createProxy({ markdown })`, `markdown: { negotiate: false }` | A, S |
| 7 | **GEO** — MCP | `src/app/api/mcp/route.ts` = `export { mcpGET as GET, mcpPOST as POST } from '@/lib/content'` (public — AI browses the site: `get_site_info`, `list_pages`, `search_content`, `get_page`); name: `createContentHelpers({ mcp: { serverName } })` | `mcpGET`, `mcpPOST` | A, S |
| 8 | **GEO** — AI bots + IndexNow | robots **lets in** AI bots (default `aiBots: 'allow'`; block only on a client decision); AI bot policy and per-bot exceptions — Site settings → Search engines → AI assistants (works only with `getRobots`); `iapl({ indexNow: true })` + `src/app/indexnow-key.txt/route.ts` (`indexNowKeyRoute`; publishing → Bing/ChatGPT Search within minutes; IndexNow sends nothing with `IAPL_NOINDEX=1`) | `buildRobots`, `getRobots`, `indexNowKeyRoute` | A, S |
| 9 | **Media / R2 / speed** | `Media` with `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + field; **always** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` in `.env.example`; `<MediaPreconnect/>`; `images: buildImagesConfig()` and `buildUploadSecurityHeaders()` in `next.config.ts`; the project's `<Media>` via `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S |
@@ -562,6 +562,10 @@ No abbreviations (`HeroSection`, not `HeroSec`). Do not create `lib/pages.ts`,
(`pnpm why sharp`). The plugin's peer range stays open (`next >=15`) — the minimum is yours to keep.
**Check:** `pnpm ls next sharp` → next ≥ 16.4.5, sharp ≥ 0.35.5; `pnpm exec iapl-doctor` → no `next-min`
finding; `pnpm dev` prints no security-upgrade warning.
**Watch (security audit 2026-12, O1):** React's RSC advisory GHSA-xqc2-xf4c-x3h3 (critical) is fixed in
`react-server-dom-*` 19.3.1; Next vendors its own React copy, and no Next release note or advisory says yet whether
16.4.6 carries the fix. When Next publishes one that names it, move to the version it names and raise this
minimum; until then `deps-audit` does not flag `next` for it.
12. **No open production advisories.** Node.js 20 or later for the plugin itself (its `nodemailer` 10 requires it);
**Payload 3.94 needs Node.js 22.23.5 or later** on the 22 line (`engines`: `">=22.23.5 <23"`, `.nvmrc` `22`), locally,
in CI and in Coolify (Nixpacks takes the major from `engines` / `.nvmrc` and the patch from its own release: check
@@ -638,7 +642,9 @@ for visitors. Then, all four:
4. Payload's default for a collection or global without `access` is "any logged-in account" — a customer too.
Give every collection and global explicit `access` (writes: `adminOrEditor`, as the reference site's collections
and globals do since 1.17.2). Verify with `iapl-doctor --url …` (deep): no `visitor-writes` finding. 2FA covers
the panel's collection only.
the panel's collection only. Payload's document locks (`payload-locked-documents`) are staff only since 1.18.0
(`lockedDocuments`), and lists from outside are capped at 100 for non-staff (`listLimit`) — security.md
"Lists and sorting".
5. Never let a sign-up write a field that grants rights (`roles`, `isAdmin`, …): give such a field
`access: { create: adminOnlyField, update: adminOnlyField }`.
6. Check: log in as such an account (`POST /api/customers/login`), then `GET /api/globals/site-integrations`,
@@ -1129,7 +1135,9 @@ project → **plugin gap**, not a copy.
| Legal links in the footer (href + page title) | `getSystemLinks(locale)` / `resolveSystemLinks` | links.md |
| Highlighted item, button variant | `buildLinkField({ appearances: [...] })` — the project's names | links.md |
| Language paths, switcher, hreflang | `getLocalizedSlugs`, `switchLocalePath`, `LanguageSwitcher`, `buildLocalizedPath` | i18n.md |
| Safe URL (no `javascript:`) | `safeHref` | links.md |
| Safe URL (no `javascript:`) | `safeHref`; a text field for an address rendered into `href`: `buildUrlField({ schemes })`, `isAllowedUrl`, types `BuildUrlFieldOptions`, `UrlScheme` (security.md "Addresses rendered into `href`") | links.md, security.md |
| Lists and sorting from outside | `listLimit`, `refuseOperatorSort`, `lockedDocuments` (options); `buildQueryGuardHook`, `applyQueryGuard`, `capListLimit`, `isOperatorSort`, `isStaffRequest`, `isQueryGuardHook`, `QUERY_GUARD_MARK`, `RefusedSortError`, `DEFAULT_LIST_LIMIT`, `applyLockedDocumentsAccess`, `staffOnlyLocks`, `LOCKED_DOCUMENTS_SLUG`; types `ListLimitOptions`, `LockedDocumentsAccess` | security.md |
| Markdown negotiation, cache-safe | `MARKDOWN_NEGOTIATED_HEADER`, `NEGOTIATED_CACHE_CONTROL`, `appendVary`, `markdownResponse(md, { negotiated })` | content.md |
**Forms**
| Need | Use | Doc |
@@ -1166,7 +1174,7 @@ project → **plugin gap**, not a copy.
| Enlarge an image (card, gallery, product, rich text) | `<SiteProviders lightbox>` + `<LightboxTrigger group image={lightboxImage(media, { size })}>` (`/client`), `RenderRichText lightbox`, `useLightbox`; labels: `iapl({ lightbox: true })` → Form messages → Image viewer | lightbox.md |
| YouTube without cookies before a click | `<YouTubeEmbed poster={…}>` (`/client`) — always pass an uploaded poster (without it the thumbnail comes from Google before any choice; a development warning says so) | storage.md |
| `next.config` | `buildImagesConfig`, `buildSecurityHeaders` (`csp`), `buildCsp`, `buildCspHeaders`, `buildAdminCsp` / `buildAdminCspHeaders`, `buildUploadSecurityHeaders`, `withSecurityConfig` (the OUTER wrapper: hides `X-Powered-By`, keeps Payload's `Accept-CH` / `Critical-CH` / `Vary` colour-scheme hints on the admin only; `adminClientHints: { route, sources } \| false`), `scopeColorSchemeClientHints`, `adminClientHintSources`, `COLOR_SCHEME_CLIENT_HINT` | storage.md, security.md |
| CSP reports, nonces | `createCspReportRoute` (`parseCspReports`, type `CspViolation`), `createProxy({ csp })` + `<SiteProviders nonce>` (dynamic pages only), `createCspNonce`, `CSP_NONCE_HEADER`, `buildReportingEndpoints`, `cspHeaderKey`, `DEFAULT_CSP_REPORT_GROUP`; types `BuildAdminCspArgs`, `CspDirective`, `CspSources`, `CreateCspReportRouteArgs`, `WithSecurityConfigOptions` | security.md |
| CSP reports, nonces | `createCspReportRoute` (`parseCspReports`, `cspLogLine`, `CSP_LOG_VALUE_MAX`, type `CspViolation`), `createProxy({ csp })` + `<SiteProviders nonce>` (dynamic pages only), `createCspNonce`, `CSP_NONCE_HEADER`, `buildReportingEndpoints`, `cspHeaderKey`, `DEFAULT_CSP_REPORT_GROUP`; types `BuildAdminCspArgs`, `CspDirective`, `CspSources`, `CreateCspReportRouteArgs`, `WithSecurityConfigOptions` | security.md |
| Fluid typography and spacing | `fluid.css` / `fluid-wide.css` (`--ipal-*` variables); your own sizes: `fluidClamp`, `FLUID_SCALE`, `FLUID_RANGES` | design-tokens.md |
| Brand colours, fonts, radii, motion, dark mode | `tokens.css` + `tailwind.css`, `src/design/tokens.ts` (`defineTokens`, types `TokensInput`, `ColorInput`, `ColorRole`), `pnpm exec iapl-tokens` (`--check`, `--report`, `--warn-only`); building blocks `tokensToCss`, `defaultTokensCss`, `contrastReport` (`ContrastRow`), `contrastRatio`, `parseColor`, `resolveColors`, `IAPL_TOKENS`, `iaplVar`, `IaplTokenName`, `IAPL_BREAKPOINTS`, `COLOR_DEFAULTS`, `STATIC_DEFAULTS`, `FLUID_TOKENS`, `INVERSE_SCOPE`, `LEGACY_DARK_ROLES`, `LIGHT_SELECTOR`, `DARK_SELECTOR`, `INVERSE_SELECTOR`, `RemValue`, `FluidRange` | design-tokens.md |
| Accessibility widget CSS | `@intecion/ipal-kit/a11y.css` (works through the tokens) | accessibility.md |
@@ -1248,6 +1256,11 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
| The second factor on every collection and global, whichever plugin added it, and on the plugin's endpoints; an unrecognised 2FA package = startup error | per entity: `custom.ipal.secondFactor: false` or `{ read: false }` (or the package's `custom.totp.disableAccessWrapper`); everywhere: `twoFactor.guard: false` (not recommended) | `requireSecondFactor` / `secondFactorPassed` in your own access functions and endpoints |
| At most 5 **wrong** verify codes per account in 10 minutes (`POST /api/verify-totp` → `429`); a right code gives its place back (1.17.1), so correct logins are never refused; an attempt held out only by others still being checked gets `429` + `Retry-After: 2` ("try again in a moment"); the count is kept in memory and in the database (`payload.kv`), so a restart or a second instance does not reset it. **Verify:** log in correctly 7 times in a row → all in; 5 wrong codes → the next gets `429` with a long `Retry-After` | `twoFactor.verifyLimit: false` | `verifyLimit: { max, windowMinutes, store: 'memory' }`; own wiring: `buildVerifyLimit(...)` + `limit.settle(req, correct)` |
| The plugin's panel actions (`POST` mail service connect / disconnect, test e-mail, cookie scan / approval / crawl) refuse a request a browser marks as coming from another origin (`403`, before anything is read; 1.17.2). The panel's buttons are not affected; set `serverURL` (doctor `csrf-empty` warns without it). **Verify:** `curl -X POST <site>/api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b <admin cookies> -d '{}'` → `403` | `adminSameOrigin: false` | `adminSameOrigin: { origins: [...] }`; `requireOwnOrigin(endpoint, origins?)` for your own endpoints |
| Public lists capped (1.18.0, audit F4): a REST / GraphQL list from a caller that is not staff gets at most 100 documents; `pagination=false` / `limit=0` become one page of 100; staff and the Local API untouched. **Verify:** `curl -s '<site>/api/pages?limit=100000' \| jq .limit` → `100` | `listLimit: false` | `listLimit: { max, staff, exclude }`; `buildQueryGuardHook` for a collection a plugin adds after iapl; `capListLimit` |
| Operator names in `sort` refused (1.18.0, audit F5): `?sort=$where`, `-$natural`, `a.$ne` → `400` for everyone (logged as one `info` line, `RefusedSortError`) instead of a database error. **Verify:** `curl -s -o /dev/null -w '%{http_code}' '<site>/api/pages?sort=%24where'` → `400` | `refuseOperatorSort: false` | `loggingLevels: { RefusedSortError: false }`; `isOperatorSort` |
| Payload's document locks (`payload-locked-documents`) for staff accounts only, with the second factor (1.18.0); Payload's default was any signed-in account, a customer too. **Verify:** a visitor account gets `403` on `/api/payload-locked-documents`; the panel still shows who edits a document | `lockedDocuments: false` | `lockedDocuments: { access: { read, create, update, delete } }`; `staffOnlyLocks`, `applyLockedDocumentsAccess` |
| CSP report log lines normalised (1.18.0, audit F1): origin of the blocked resource, path of the page, no control characters, every value ≤ 128 characters; at most 10 violations per request, 60 requests per client a minute (answer stays `204`) | `rateLimit: false`; your own `onReport` (gets the raw values) | `createCspReportRoute({ maxReports, rateLimit: { max, windowMs }, onReport })`, `cspLogLine` |
| Markdown negotiated at a page URL is `private, no-store` + `Vary: Accept`; pages under the proxy matcher get `Vary: Accept` (1.18.0, audit F3); `/md/…` stays publicly cacheable | `markdown: { negotiate: false }` (Markdown only at `/md/…`) | `markdown: { prefix }`; `MARKDOWN_NEGOTIATED_HEADER`, `appendVary` for your own proxy |
| 2FA first set-up confirmed by e-mail (1.18.0): the code only starts it; a link to the account's own address, opened in the same browser within 30 min, turns it on and ends the account's sessions; notice mails on every enrolment, change, removal / reset; without working mail the link goes to the server log and an admin confirms on the account page ("Confirm the waiting set-up", `POST /api/iapl/two-factor/confirm-pending`). **Verify:** security.md "Set-up confirmed by e-mail" → Verify; doctor `2fa-enrolment-mail` | `twoFactor.confirmByEmail: false` | `confirmByEmail: { linkMinutes, sameBrowser, adminConfirm, logLinkWhenMailFails, notices, maxMailsPerHour }`; `startEnrolment`, `buildEnrolmentEndpoints`, `buildTotpNoticeHooks`, `sendTwoFactorNotice`, `verifyTotpCode`, `readPendingEnrolment`, `pendingEnrolmentInfo`, `countPendingEnrolments`, `mailConfigured` |
| 2FA verify and setup attempts only from the site's own origin: a request a browser marks as coming from elsewhere (`Origin`, `Sec-Fetch-Site`) gets `403` and is not counted. The admin's reset `POST /api/ipal/two-factor/reset` follows the same rule (1.17.1). **Verify:** `curl -X POST <site>/api/ipal/two-factor/reset -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b <admin cookies> -d '{"userId":1}'` → `403`; the panel's button still works. **Set `serverURL`**: behind a proxy that rewrites `Host` and sends no `X-Forwarded-Host` the site's own page is refused without it (logged once per origin: `[iapl] 2FA: a code from origin … was refused`) | `twoFactor.sameOrigin: false` | `sameOrigin: { origins: ['https://app.example.com'] }`; `requestFromOwnOrigin`, `reportRefusedOrigin` |
| Stored secrets are write-only: `smtpPassword` and `turnstileSecretKey` come back as `'********'` over REST, GraphQL and in the panel; an empty save keeps the value, `'[[clear]]'` removes it; server code reads the real value with the Local API. A query cannot name a secret (1.17.1): `where` / `sort` on it — REST, GraphQL, versions — is refused (`secretReadAccess`, the field's `read` rule; verify: `GET /api/globals/site-integrations/versions?where[version.smtpPassword][exists]=true` as an admin → 400 `QueryError`, no `totalDocs`). **The panel is the source — never add an env variable for them** (`TURNSTILE_SECRET_KEY` is deprecated) | `secrets: { writeOnly: false }` | `writeOnlySecret(field)` / `writeOnlySecrets(fields, names)` for your own secret fields; with versions on the entity add `hooks.afterRead: [maskSecretsOnRestore]` |
@@ -1272,7 +1285,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
| Locale cookie: consent read under its own stored version | — | `createProxy(config, { policyVersion })` / `createLocaleMiddleware({ policyVersion })` |
| No `X-Powered-By` (with `withSecurityConfig`) | `withSecurityConfig(config, { hidePoweredBy: false })` | — |
| Payload's colour-scheme client hints only on `/admin/:path*` (with `withSecurityConfig` outside `withPayload`) | `withSecurityConfig(config, { adminClientHints: false })` | `{ adminClientHints: { route, sources } }`, `scopeColorSchemeClientHints(rules, sources)` |
| CSP off until `buildSecurityHeaders({ csp })`; then hard rules, `'unsafe-eval'` only in dev | leave out `csp` | `buildCsp({ extra, override, strictDynamic, dev })`, `buildAdminCsp({ extra, override })`, `createCspReportRoute({ onReport, maxBytes })`, your own string via `additional` |
| CSP off until `buildSecurityHeaders({ csp })`; then hard rules, `'unsafe-eval'` only in dev | leave out `csp` | `buildCsp({ extra, override, strictDynamic, dev })`, `buildAdminCsp({ extra, override })`, `createCspReportRoute({ onReport, maxBytes, maxReports, rateLimit })`, your own string via `additional` |
| Construction mode hides pages in Markdown, MCP | `markdown: { isPathVisible: () => true }`, `mcp: { isPathVisible: () => true }` | `isPathVisible`, `isPathVisibleIn(mode, path)`, `pathOf(url)`, type `PathVisibility` |
| Construction mode filters the sitemap and llms.txt | `underConstructionSeo: false` | `include` / `getIncludedPaths` in the low-level builders |
| `getSettings` at `depth: 1` | — | `createContentHelpers({ settingsDepth: 2 })` (every request pays) |
+2
View File
@@ -71,6 +71,8 @@ names, env, admin, AGENTS.md, skills, seeds and — with `--url` / `--deep` —
endpoint. On the live site: `pnpm exec iapl-doctor --url https://<domain> --only live-probes`. The code side:
`pnpm exec iapl-doctor --only security` (`code-patterns`, `config-dangerous`); a correct place gets
`// iapl-security-ok: <why>`. Dependencies: `pnpm audit --prod` (the doctor's `deps-audit`) — no high or critical.
Every address field rendered into `href` (social profiles, a website) is `buildUrlField()` and rendered through
`safeHref()` (security.md "Addresses rendered into `href`"); the static rules do not flag an `href` from data.
- **Editor test** (AGENT.md §11): every text, image, button, section,
menu, footer and SEO field can be changed in the panel, in every language.
+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` |
+4 -1
View File
@@ -54,7 +54,10 @@ the request, `eval`, `NEXT_PUBLIC_` secrets, redirects and fetches to an address
nothing, run against the real site (secret files, bundle secrets, proxy bypass, open redirects, cache poisoning,
NoSQL operators, anonymous where / draft / GraphQL reads, error leaks, unbounded lists, `/_next/image`). Verify: on a
fresh starter site the run lists no `code-*` finding; add `eval(x)` to a page and `code-eval` appears. A correct
place is marked `// iapl-security-ok: <why>`.
place is marked `// iapl-security-ok: <why>`. From 1.18.0 a site on IAPL's defaults passes every probe; `markdown-vary`,
`unbounded-list` or `sort-operator` on such a site means a fix was turned off (`markdown: { negotiate }` with a proxy
of its own, `listLimit: false`, `refuseOperatorSort: false`) — security.md "Lists and sorting"; silence the rule with
the reason when that was the decision.
Exit `0` ok · `1` findings at or above `--fail-on` · `2` could not run · `3` a rule crashed.
@@ -46,6 +46,9 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
| "Sending method" (`emailMethod`; `getMailMethod` / `setMailMethod`) | nobody has chosen: the order of 1.17.0, shown as selected | `relay` (IWSN), `smtp`, `graph` (deprecated): what is chosen is what is used, no fallback; a stored field (Postgres / SQLite: one migration) |
| `secrets.reenterOnChange` | on | a save through access control that changes `smtpHost`, `smtpPort` or `smtpUser` while a password is stored must send the password again or remove it (`400` on the field otherwise), whatever `emailTransport` says — so an admin session cannot send the stored password to a server of its own. A change of the transport alone, and the Local API with access control off, are not asked | `false` = the stored password follows the new server |
| `dashboardAlerts` | `{ integrations: 'admin', cookies: 'editor' }` | who sees the plugin's dashboard alerts: integration details (error text, link) for `integrations` and above, a neutral "ask an administrator" for editors below it, nothing for others; the cookie crawl / approval alert for `cookies` and above. With a role, a session that owes its second factor sees none | `integrations: 'editor' | 'all'`, `cookies: 'all'` (`'all'` = as before: no role and no second factor is checked) |
| `listLimit` | `{ max: 100, staff: false }` (1.18.0, audit F4) | a REST / GraphQL list (`find`, versions, distinct) from a caller that is not staff gets at most `max` documents; `pagination=false` / `limit=0` become one page; staff and the Local API untouched | `false` (Payload's behaviour); `{ max, staff: true, exclude: ['slug'] }`; `buildQueryGuardHook` for a collection added after iapl |
| `refuseOperatorSort` | `true` (1.18.0, audit F5) | a `sort` naming a database operator (`$where`, `-$natural`, `a.$ne`) → `400` for everyone, logged as one `info` line (`RefusedSortError`) | `false`; `loggingLevels: { RefusedSortError: false }` hides the log line |
| `lockedDocuments` | staff only (1.18.0) | Payload's document locks (`payload-locked-documents`) for staff accounts with the second factor; Payload's default was any signed-in account | `false` (Payload's default); `{ access: { read, create, update, delete } }` |
| `adminSameOrigin` | on (1.17.2) | `POST` mail service connect / disconnect, test e-mail, cookie scan / approval / crawl refuse (`403`) a request a browser marks as coming from another origin; own origins: the request's host, `serverURL`, `csrf`, `cors`, `origins` | `{ origins: [...] }` adds origins; `false` = no check; any other value stops the start |
| `adminRoute` | `'/admin'` | `config.routes.admin`; stats link and views, `IntegrationAlerts` | the project moves `app/(payload)/<route>/` itself and adds the route to the proxy matcher (security.md) |
| `twoFactor` | **none = error** | `@clocklimited/payload-2fa` with `forceSetup: true` (TOTP enforced, also checked in the API) | `twoFactor: false` (discouraged); omitting the option throws `[iapl] twoFactor.issuer is required` |
@@ -301,6 +301,7 @@ Opt-in with `iapl({ cookieScanner: true })`; the plugin wires the collection, en
| `MARKDOWN_PREFIX` | `@intecion/ipal-kit` | constant `'/md'` — default prefix of Markdown routes |
| `markdownHref(pathname, prefix?)` | `@intecion/ipal-kit` | page path → Markdown version address (`/pl/o-nas` → `/md/pl/o-nas`), e.g. for `alternates.types` |
| `prefersMarkdown(request \| headers \| accept)` | `@intecion/ipal-kit` | whether the `Accept` header prefers `text/markdown` (q-values); for your own proxy — `createProxy({ markdown: true })` does it itself |
| `MARKDOWN_NEGOTIATED_HEADER`, `NEGOTIATED_CACHE_CONTROL`, `appendVary(headers, token)` | `@intecion/ipal-kit` | 1.18.0 (audit F3): the request marker the proxy sets on a negotiated rewrite (the route then answers `private, no-store` + `Vary: Accept`), that cache-control, and `Vary` with a token added once — for your own proxy (content.md "content negotiation"). `markdownResponse(md, { negotiated: true })` gives the same headers. `createProxy({ markdown: { prefix?, negotiate? } })`: `negotiate: false` = no rewrite. |
| `searchContent({ payload, query, config, locale?, limit?, baseUrl?, collection?, summaryField? })` | `@intecion/ipal-kit` | searches published, indexable pages by title/description → `SearchResult[]`; does not throw |
| `listContent({ payload, config, locale?, limit? })` | `@intecion/ipal-kit` | list of published, indexable pages (no query) — used by MCP `list_pages` |
| `createSearchRoute({ getCachedPayload, config, baseUrl, defaultLimit?, rateLimit?, clientIp?, isPathVisible? })` | `@intecion/ipal-kit` | `GET` handler for the JSON search endpoint (`?q=&locale=&limit=`), with a per-IP rate limit; pass `isPathVisible` from `@/lib/content` so construction mode hides pages here too |
@@ -503,6 +504,7 @@ The editor builds forms in the panel (Forms collection). The project does NOT wr
| `resolveSystemLinks(settings, { locale, config, roles?, … })` | `@intecion/ipal-kit` | Links to system pages from Site settings (privacy/cookies/terms) with the page title as the label → `SystemLink[]`; in a project usually `getSystemLinks` from `lib/content` |
| `homeSlugFrom(settings, field?)` | `@intecion/ipal-kit` | Homepage slug from `SiteSettings.homepage` (populated) or `undefined` |
| `safeHref(url)` | `@intecion/ipal-kit` | The URL when safe (http(s), mailto, tel, sms, #, `/` path), otherwise `null` — blocks `javascript:`/`data:` |
| `buildUrlField({ name?, label?, required?, schemes?, description?, overrides? })`, `isAllowedUrl(value, schemes?)` | `@intecion/ipal-kit` | 1.18.0 (audit F2): a text field for an address rendered into `href` — `https://` / `http://` pass, plus the `schemes` you list (`mailto`, `tel`, `sms`, `hash`, `relative`); `javascript:`, `data:`, `//host` never. Render the value with `safeHref` too. Types `BuildUrlFieldOptions`, `UrlScheme`. |
**Types:** `BuildLinkFieldOptions`, `BuildLinksFieldOptions`, `LinkAppearance`, `LinkAppearanceOption` — link field options and styles; `LinkValue`, `ResolveLinkHrefOptions`, `ResolvedLink`, `NavItem`, `ResolveNavOptions`, `SystemLink` — panel link value, resolver options and results.
@@ -650,7 +652,10 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
| `buildCsp({ mode?, reportUri?, reportGroup?, r2Url?, analytics?, metaPixel?, linkedIn?, tiktok?, clarity?, turnstile?, youtube?, googleMaps?, nonce?, strictDynamic?, dev?, extra?, override? })` | `@intecion/ipal-kit` | Returns `{ key, value }` with a hardened CSP (`base-uri`, `object-src`, `frame-ancestors`, `form-action`) + sources for the enabled integrations. `mode: 'report-only'` → `…-Report-Only` (start here), `'enforce'` later. `extra` adds to any directive, `override` replaces / drops one (`null`). `dev` (default `NODE_ENV === 'development'`) adds `'unsafe-eval'`. `nonce` → `'nonce-…' 'strict-dynamic'`. |
| `buildCspHeaders(args)` | `@intecion/ipal-kit` | `[csp, Reporting-Endpoints]` (the second only with `reportUri`). |
| `buildAdminCsp(args)` / `buildAdminCspHeaders(args)` | `@intecion/ipal-kit` | Looser policy for Payload's admin: Monaco from `cdn.jsdelivr.net`, `blob:` workers, `https:` images, Live Preview `frame-src 'self'`, `frame-ancestors 'self'`. Rule `{ source: '/admin/:path*', headers: buildAdminCspHeaders({ mode, reportUri }) }` AFTER the site-wide rule. |
| `createCspReportRoute({ onReport?, maxBytes? })` | `@intecion/ipal-kit` | `POST` handler for `reportUri` (`src/app/api/csp-report/route.ts`): both report formats, body cap 16 KB, always `204`; default sink = one `[csp] …` `console.warn` line per violation (Coolify logs). |
| `createCspReportRoute({ onReport?, maxBytes?, maxReports?, rateLimit? })` | `@intecion/ipal-kit` | `POST` handler for `reportUri` (`src/app/api/csp-report/route.ts`): both report formats, body cap 16 KB, always `204`; default sink = one `[csp] …` `console.warn` line per violation (Coolify logs) made by `cspLogLine` — origin / path only, no control characters, values ≤ `CSP_LOG_VALUE_MAX` (128) (1.18.0, audit F1); at most `maxReports` (10) per request, `rateLimit` 60 / min per client (`false` = none); your `onReport` gets the raw values. |
| `cspLogLine(violation)`, `CSP_LOG_VALUE_MAX` | `@intecion/ipal-kit` | the default CSP log line (safe to log) for your own sink, and its value cap. |
| `buildQueryGuardHook({ listLimit?, refuseOperatorSort? })`, `applyQueryGuard(config, options)`, `capListLimit(args, max?)`, `isOperatorSort(sort)`, `isStaffRequest(req)`, `RefusedSortError`, `DEFAULT_LIST_LIMIT`, `isQueryGuardHook`, `QUERY_GUARD_MARK` | `@intecion/ipal-kit` | 1.18.0 (audit F4, F5; security.md "Lists and sorting"): the `beforeOperation` hook iapl adds to every collection — lists from a non-staff caller over REST / GraphQL capped at 100 (`pagination=false`, `limit=0` included), a `sort` naming a database operator → `400` (logged as `info`). Options `listLimit: false \| { max, staff, exclude }`, `refuseOperatorSort: false`. Put the hook on a collection a plugin adds after iapl. Type `ListLimitOptions`. |
| `applyLockedDocumentsAccess(config, access?)`, `staffOnlyLocks`, `LOCKED_DOCUMENTS_SLUG` | `@intecion/ipal-kit` | 1.18.0: Payload's document locks (`payload-locked-documents`) for staff accounts only (with the second factor); iapl sets it at start (`lockedDocuments: false` = Payload's default, `{ access }` = your rule per operation). Type `LockedDocumentsAccess`. |
| `parseCspReports(body)` | `@intecion/ipal-kit` | Normalises a report body (`csp-report` object or Reporting API array) to `CspViolation[]` — for your own collector. |
| `buildReportingEndpoints(url, group?)`, `cspHeaderKey(mode?)`, `DEFAULT_CSP_REPORT_GROUP` | `@intecion/ipal-kit` | Building blocks: the `Reporting-Endpoints` header, the header name for a mode, the default `report-to` group (`'csp-endpoint'`). |
| `createCspNonce()`, `CSP_NONCE_HEADER` | `@intecion/ipal-kit/next/middleware`, `@intecion/ipal-kit` | A per-request nonce and the request header (`x-nonce`) `createProxy({ csp })` passes it in — for your own proxy. Nonces make pages dynamic (no ISR). |
+3 -2
View File
@@ -487,7 +487,7 @@ and `rel="alternate" type="text/markdown"`; `/pl/nie-ma-takiej` → 404 with con
| `src/app/robots.ts` | `export { getRobots as default } from '@/lib/content'` + `force-dynamic` (AI crawler policy from Site settings → Search engines; `robots` = code only) |
| `src/app/manifest.ts` | `export { manifest as default } from '@/lib/content'` + `force-dynamic` |
| `src/app/api/health/route.ts` | `export { healthRoute as GET } from '@/lib/content'` + `force-dynamic` |
| `src/app/api/csp-report/route.ts` | `import { createCspReportRoute } from '@intecion/ipal-kit'` + `export const POST = createCspReportRoute()` (CSP violation reports → `[csp]` lines in the logs) |
| `src/app/api/csp-report/route.ts` | `import { createCspReportRoute } from '@intecion/ipal-kit'` + `export const POST = createCspReportRoute()` (CSP violation reports → `[csp]` lines in the logs: origins and paths only, 10 per request, 60 requests per client a minute; security.md "Collecting reports") |
```ts
// next.config.ts
@@ -581,7 +581,8 @@ Already wired and required: `markdown: true` (stage 6 proxy), `markdownAlternate
**Check.** `curl -s localhost:3000/llms.txt` → site name and a list of pages with descriptions (`aiSummary`);
`/llms-full.txt` → page content; `curl -s localhost:3000/md/pl` → Markdown of the home page; `curl -s -H 'Accept:
text/markdown' localhost:3000/pl` → the same Markdown; `curl -s -X POST localhost:3000/api/mcp -H 'content-type:
text/markdown' localhost:3000/pl` → the same Markdown, sent `cache-control: private, no-store` with `Vary: Accept`
(`curl -sD- -o/dev/null -H 'Accept: text/markdown' localhost:3000/pl`; 1.18.0, so no CDN stores it as the page); `curl -s -X POST localhost:3000/api/mcp -H 'content-type:
application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'` → `get_site_info`, `list_pages`,
`search_content`, `get_page`; `/indexnow-key.txt` → `404` until the key is generated in the panel, then the key.
+16
View File
@@ -47,6 +47,22 @@ are not affected. Nothing to wire, no migration, no import-map change. Off: `two
**Check:** `pnpm exec iapl-doctor --deep` shows no `2fa-enrolment-mail` error; a test editor scans the code → the
screen says "we sent a link to …", the link opened in the same browser → "Two-step verification is on".
**→ 1.18.0, security audit fixes (CHANGELOG 1.18.0 "Security audit 2026-12"; security.md "Lists and sorting") — no
migration, no import-map change; check before deploying:** (1) **public lists are capped at 100** for callers that are
not staff (REST / GraphQL; the Local API and the panel are not touched): a client-side script that reads more than
100 documents anonymously gets `hasNextPage: true` — page through, or `listLimit: { max }` / `{ exclude: ['slug'] }`
/ `false`; (2) a `?sort=$…` answers `400` (`refuseOperatorSort: false` = Payload's way); (3) Payload's document locks
are staff only (`lockedDocuments: false` = Payload's default); (4) the negotiated Markdown at a page URL is
`private, no-store` + `Vary: Accept`, and pages under the proxy matcher get `Vary: Accept` — a proxy of your own that
rewrites to `/md/…` copies the headers (content.md); `markdown: { negotiate: false }` turns negotiation off; (5) CSP
report log lines show origins and paths, at most 10 per request and 60 requests per client a minute (a log parser
that read full URLs adapts; `createCspReportRoute({ maxReports, rateLimit })`); (6) a text field of your own whose
value goes into `href` (social profiles, a website): `buildUrlField()` and `safeHref()` at render (no schema change);
(7) the first `iapl-doctor --only security` run shows the new `code-*` / `config-dangerous` rules — judge each, mark a
correct place `// iapl-security-ok: <why>`. **Check:** `curl -s '<site>/api/pages?limit=100000' | jq .limit` → `100`;
`curl -s -o /dev/null -w '%{http_code}' '<site>/api/pages?sort=%24where'` → `400`;
`pnpm exec iapl-doctor --url <site> --only live-probes` → no finding.
**→ 1.17.2, security (CHANGELOG 1.17.2; PROGRAMISTA §6, items 84–87) — nothing required, check:** `readVersions:
readPublished()` now works (a wrapper of your own around it: use `readPublishedVersions()` inside); behind a proxy
that rewrites `Host` without `X-Forwarded-Host`, set `serverURL` or the panel's mail / cookie buttons answer 403