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:
co-authored by
Claude Opus 5.5
parent
e9f9947eb7
commit
e5964d4e05
+18
-5
@@ -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) |
|
||||
|
||||
Reference in New Issue
Block a user