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
+57 -8
View File
@@ -94,21 +94,70 @@ once there are more than 20.
> gate template. **Recommended for projects:** `index: true` on `slugHistory.slug`; the heading font with
> `preload: false` (the starter's default now); a placeholder of the 404 content's height.
### Security audit 2026-12: suites and fixes (docs/security.md)
### Security audit 2026-12: fixes and suites (docs/security.md)
> Nothing changes for a running site; nothing to wire. New checks a project can run on its own site:
> **What changes for an existing site** (no migration, no import-map change; each with its opt-out):
>
> 1. **Public lists are capped at 100** (`listLimit`, finding F4). A REST / GraphQL list (`find`, versions, distinct
> values) asked by a caller that is not staff gets at most 100 documents; `pagination=false` and `limit=0` become one
> page of 100. Before, one anonymous `GET /api/posts?limit=100000` read a whole collection with its relations.
> Staff accounts, the panel and the Local API (the frontend, seeds) are not capped. **A client-side script that reads
> more than 100 documents anonymously now gets the first 100 and `hasNextPage: true`** — page through, or adapt:
> `listLimit: { max: 500 }`, `{ exclude: ['products'] }`, `{ staff: true }`; off: `listLimit: false`.
> 2. **An operator name in `?sort=` answers 400** (`refuseOperatorSort`, F5): `$where`, `-$natural`, `title.$ne` —
> for everyone, staff too — instead of reaching MongoDB and ending in a 500 with a stack trace in the log. Logged as
> one `info` line (`RefusedSortError`; `loggingLevels: { RefusedSortError: false }` hides it). Off:
> `refuseOperatorSort: false`. Reported to Payload upstream.
> 3. **Payload's document locks are for staff only** (`lockedDocuments`). `payload-locked-documents` ("who edits
> what") ran on Payload's default, any signed-in account — a visitor account of a login collection for customers
> could read who edits which document and write or delete locks. Now staff accounts with the second factor; the
> panel works as before. Off: `lockedDocuments: false`; your own rule: `lockedDocuments: { access: { read } }`.
> 4. **The Markdown negotiated at a page URL is never cached as the page** (F3). `createProxy({ markdown: true })`
> marks the rewrite, the Markdown route answers `cache-control: private, no-store` with `Vary: Accept`, and the
> pages under the proxy matcher get `Vary: Accept`. Before, a CDN that caches HTML (Cloudflare "Cache Everything",
> Varnish) could store the Markdown copy after one anonymous `Accept: text/markdown` request and serve it to every
> visitor of that page. `/md/…` keeps its public caching. A proxy of your own that rewrites to `/md/…` copies the
> headers (`MARKDOWN_NEGOTIATED_HEADER`, `NEGOTIATED_CACHE_CONTROL`, `appendVary`; content.md). Off:
> `markdown: { negotiate: false }` (Markdown only at `/md/…`).
> 5. **CSP report log lines change shape** (F1): `blocked=` is the origin (`https://cdn.example`, or `inline` /
> `eval`), `page=` the path without its query, `src=` origin and path; control characters are removed and each
> value is cut at 128 characters, so a posted report can no longer write a forged line into the Coolify log. One
> request handles at most 10 violations (was 50), one client at most 60 requests a minute (the answer stays `204`).
> **A log parser that read full URLs must adapt.** Your own `onReport` still gets the raw values. Adapt:
> `createCspReportRoute({ maxReports: 50, rateLimit: false | { max, windowMs } })`; the line: `cspLogLine`.
> 6. **New doctor findings the first time** (the suites below): `iapl-doctor --only security` reads the project's own
> code and configs. Judge each; a correct place gets `// iapl-security-ok: <why>`.
>
> **Recommended for projects:** a text field of your own whose value goes into `href` (social profiles, a website)
> becomes `buildUrlField()` and its render goes through `safeHref()` (F2) — no schema change, it stays a text column.
> The reference site and every new site from `iapl create` do it for Company → Profiles (also in the `sameAs` of the
> JSON-LD). Not exploitable as the reference site wrote it (`target="_blank"`), but a copy without it would run an
> editor's `javascript:` link as the admin who clicks it.
>
> **New checks a project can run on its own site:**
>
> - **Static security rules** in the doctor: `iapl-doctor --only security` now also reads the project's own code
> (`code-patterns`: unescaped HTML / JSON-LD, `overrideAccess: true` and a Local API `user` without
> `overrideAccess: false` where a request reaches, a `where` from the request, `eval`, `NEXT_PUBLIC_` secrets,
> redirects and fetches to an address from the request) and its configs (`config-dangerous`). A correct place is
> marked `// iapl-security-ok: <why>`. Expect new warnings on an existing site the first time; judge each.
> redirects and fetches to an address from the request) and its configs (`config-dangerous`).
> - **Attack probes**: `iapl-doctor --url https://<domain> --only live-probes` (requests that change nothing) and the
> Playwright template `iapl-audit/resources/attack-probes.spec.template.ts`. Exported: `ATTACK_PROBES`,
> `runAttackProbes`, `createProbeContext`, `scanCode`, `scanConfigs` (`@intecion/ipal-kit/doctor`).
> - Known and reported by the probes until fixed (audit findings): the Markdown copy given at an HTML URL to
> `Accept: text/markdown` can be cached as the page by a CDN that caches HTML (`markdown-vary`); public REST lists
> take any `limit` (`unbounded-list`); an operator name in `?sort=` answers 500 on MongoDB (`sort-operator`).
> `runAttackProbes`, `createProbeContext`, `scanCode`, `scanConfigs` (`@intecion/ipal-kit/doctor`). A site on the
> 1.18.0 defaults passes every probe; `markdown-vary`, `unbounded-list` or `sort-operator` mean a fix above is off.
> - **For the plugin's own release:** `pnpm security:gate` (in `prepublishOnly`): `pnpm audit --prod` with no high /
> critical, the static-rule gate and the per-class tests; `--zap <url>` adds an optional OWASP ZAP baseline scan.
>
> **New exports:** `buildQueryGuardHook`, `applyQueryGuard`, `capListLimit`, `isOperatorSort`, `isStaffRequest`,
> `RefusedSortError`, `DEFAULT_LIST_LIMIT`, `isQueryGuardHook`, `QUERY_GUARD_MARK`, `applyLockedDocumentsAccess`,
> `staffOnlyLocks`, `LOCKED_DOCUMENTS_SLUG` (types `ListLimitOptions`, `LockedDocumentsAccess`); `buildUrlField`,
> `isAllowedUrl` (types `BuildUrlFieldOptions`, `UrlScheme`); `cspLogLine`, `CSP_LOG_VALUE_MAX`;
> `MARKDOWN_NEGOTIATED_HEADER`, `NEGOTIATED_CACHE_CONTROL`, `appendVary`. New options: `listLimit`,
> `refuseOperatorSort`, `lockedDocuments`; `createProxy({ markdown: { prefix, negotiate } })`;
> `createCspReportRoute({ maxReports, rateLimit })`; `markdownResponse(md, { negotiated })`.
>
> **Watch (no change in this release):** React's RSC advisory GHSA-xqc2-xf4c-x3h3 is fixed in React 19.3.1; whether
> Next 16.4.6 carries the fix is not confirmed by any Next release note or advisory. The minimum safe Next version in
> AGENT.md §4 is raised when Next publishes one that names it.
## 1.17.2 — version history with readPublished, sign-in and panel actions, staff-only REST submissions and jobs, the cookie button