Audit clean with dev tooling: overrides for esbuild (<0.25, via drizzle-kit), eslint (<9.39.4, @eslint/plugin-kit) and minimatch (7–11.0.7, via typescript-eslint); security:gate fails on moderate and above in the production tree and the dev tooling (--audit-level, --prod-only to loosen); doctor transitive-min warns on esbuild for Postgres sites; AGENT.md §4 item 12, skills, security.md, changelog
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f38a8cc677
commit
b9bcd55ac4
+7
-2
@@ -184,6 +184,10 @@ This heading and the 1.17.2 section below (never released on its own) become one
|
||||
> redeploy. The plugin, the reference site and new sites from `iapl create` carry it. The same for `cross-spawn`
|
||||
> below 7.1.0 (GHSA-ghv9-86vm-4v8m, critical, command injection when spawning batch files — Windows only; comes
|
||||
> with `cross-env` and `eslint`): `"cross-spawn@>=7 <7.1.0": "^7.1.2"`.
|
||||
> **Postgres sites:** `esbuild` below 0.25 (GHSA-67mh-4wv8-2f99, moderate) comes with `@payloadcms/db-postgres` →
|
||||
> `drizzle-kit`; `transitive-min` warns, fix `"esbuild@<0.25.0": "^0.25.12"`. The plugin's own dev tooling is clean
|
||||
> too now (`eslint` 9.39.4 and `minimatch` 11.0.10 through overrides); AGENT.md §4 item 12 lists them for a project
|
||||
> that uses `@payloadcms/eslint-config`.
|
||||
>
|
||||
> **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.
|
||||
@@ -201,8 +205,9 @@ This heading and the 1.17.2 section below (never released on its own) become one
|
||||
> Playwright template `iapl-audit/resources/attack-probes.spec.template.ts`. Exported: `ATTACK_PROBES`,
|
||||
> `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.
|
||||
> - **For the plugin's own release:** `pnpm security:gate` (in `prepublishOnly`): `pnpm audit` with no moderate, high
|
||||
> or critical advisory in the production tree **and the dev tooling** (lows reported; `--audit-level high` or
|
||||
> `--prod-only` for the looser rule), 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`,
|
||||
|
||||
@@ -590,6 +590,13 @@ No abbreviations (`HeroSection`, not `HeroSec`). Do not create `lib/pages.ts`,
|
||||
8.23 or later. `iapl-doctor` (`transitive-min`) warns while an older one is installed. `cross-spawn` comes with `cross-env` (the
|
||||
site's scripts) and `eslint`: GHSA-ghv9-86vm-4v8m (critical, command injection when spawning batch files, Windows
|
||||
only, published 2026-12-01) is fixed in 7.1.0; Coolify runs Linux, but `pnpm audit --prod` reports it as critical.
|
||||
**Postgres sites** also add `"esbuild@<0.25.0": "^0.25.12"`: `@payloadcms/db-postgres` → `drizzle-kit` →
|
||||
`@esbuild-kit/*` brings esbuild 0.18 (GHSA-67mh-4wv8-2f99, moderate: esbuild's own dev server answers any origin;
|
||||
drizzle-kit never starts that server, but `pnpm audit --prod` lists it). The plugin's own tests run the Postgres
|
||||
adapter on 0.25 with this override. A project that runs `@payloadcms/eslint-config` also adds
|
||||
`"eslint@>=9 <9.39.4": "^9.39.4"` and `"minimatch@>=7 <11.0.8": "^11.0.10"` (dev tooling: GHSA-xffm-g5w8-qvg7 in
|
||||
`@eslint/plugin-kit` 0.2, GHSA-g3hv-75wg-m249 and GHSA-c859-jr93-m5j4 in `minimatch` 9 / 10; the plugin's lint
|
||||
gives the same results with them).
|
||||
`happy-dom` comes from `@payloadcms/richtext-lexical` → `@lexical/headless` 0.50 (`^20.9.0`, still so in 3.94.1);
|
||||
every 20.x has GHSA-c8p4-j97h-3vg8 (high, SSRF when parsing untrusted HTML, fixed in 21.0.0) and
|
||||
GHSA-834v-8h66-3h79 (high, host code execution, fixed in 21.0.4). 21 is a major, but only
|
||||
|
||||
@@ -102,7 +102,7 @@ create-payload-app gave you an older one.
|
||||
**Node.js 22.23.5 or later** on the 22 line (`"engines": { "node": ">=22.23.5 <23" }`, `.nvmrc` `22`) — Payload 3.94's
|
||||
minimum, also in Coolify (Nixpacks picks the patch: check `node -v` in the app's Terminal after the first deploy). After the install, `pnpm audit --prod` → no high or critical; add the `cross-spawn`, `dompurify`, `happy-dom` and `ws` overrides
|
||||
from AGENT.md §4 item 12 (`"happy-dom@<21.0.4": "^21.0.4"` fixes two high advisories Lexical still brings in,
|
||||
`"ws@>=8 <8.23.0": "^8.23.0"` one in Payload's `ws`). On an
|
||||
`"ws@>=8 <8.23.0": "^8.23.0"` one in Payload's `ws`; a Postgres site also the `esbuild` one listed there). On an
|
||||
older Payload also the `mongoose` (MongoDB) and `undici` ones listed there. `pnpm exec iapl-doctor` → no
|
||||
`transitive-min` finding.
|
||||
`nodemailer`, `lucide-react`, `slugify`, `server-only` come with the plugin — do not add them (your own
|
||||
|
||||
@@ -188,7 +188,8 @@ saves; `pnpm exec iapl-doctor` → no `versions` finding; Coolify app → Termin
|
||||
|
||||
**Every upgrade — dependency advisories** (AGENT.md §4 item 12): `pnpm audit --prod`; on Payload 3.94.x add the
|
||||
`cross-spawn`, `dompurify`, `happy-dom` and `ws` overrides to `pnpm.overrides` (`ws`: GHSA-37g9-w4hg-h9qr, high;
|
||||
`cross-spawn`: GHSA-ghv9-86vm-4v8m, critical, Windows only; both 1.18.0); on an older Payload also `mongoose` (MongoDB sites; 3.90–3.93
|
||||
`cross-spawn`: GHSA-ghv9-86vm-4v8m, critical, Windows only; both 1.18.0); a Postgres site also
|
||||
`"esbuild@<0.25.0": "^0.25.12"` (via drizzle-kit, AGENT.md §4 item 12); on an older Payload also `mongoose` (MongoDB sites; 3.90–3.93
|
||||
pin 8.24.1, which has a critical advisory, GHSA-pcrw-h46h-c93h, and four more) and `undici` (3.90–3.91):
|
||||
```json
|
||||
"cross-spawn@>=7 <7.1.0": "^7.1.2",
|
||||
|
||||
+1
-1
@@ -1453,7 +1453,7 @@ Four suites, each runnable by a project on its own site. The plugin repository r
|
||||
| **Static rules** over the project's own code and config | `pnpm exec iapl-doctor --only security` (rules `code-patterns`, `config-dangerous`) | `test/securityPatterns.test.ts`: every hit in `src/`, `bin/`, `scripts/` and the reference site must be judged in `test/security-patterns.allow.json` (one reason per file and rule; a new place or a higher count fails) |
|
||||
| **Per-class tests** of the building blocks | — (the plugin's own) | `test/securityClasses.test.ts`: XSS payloads into JSON-LD, first-paint scripts, links, rich text, sitemap; open redirects; prototype pollution; log injection; body and batch caps; cache poisoning |
|
||||
| **HTTP attack probes** against a running site | live: `pnpm exec iapl-doctor --url https://<domain> --only live-probes` (changes nothing); local / staging: `.agents/skills/iapl-audit/resources/attack-probes.spec.template.ts` → `tests/attack-probes.spec.ts` | `reference/e2e/attack-probes.spec.ts` in `pnpm e2e:built`, after a webpack and a Turbopack production build, beside the closed-doors spec |
|
||||
| **Dependency audit** | the doctor's `deps-audit` (`pnpm audit --prod`, error on high / critical) | `pnpm security:gate` (also in `prepublishOnly`): `pnpm audit --prod` with no high / critical, then the two vitest suites; `--zap <url>` adds an OWASP ZAP baseline scan when the image `ghcr.io/zaproxy/zaproxy:stable` is already on the machine (offline; never pulled by the script) |
|
||||
| **Dependency audit** | the doctor's `deps-audit` (`pnpm audit --prod`, error on high / critical) | `pnpm security:gate` (also in `prepublishOnly`): `pnpm audit` with no moderate, high or critical advisory in the production tree and the dev tooling (lows reported; `--audit-level high` = only high / critical fail, `--audit-level low` = lows too, `--prod-only` = the dev tooling only reported), then the two vitest suites; `--zap <url>` adds an OWASP ZAP baseline scan when the image `ghcr.io/zaproxy/zaproxy:stable` is already on the machine (offline; never pulled by the script) |
|
||||
|
||||
**Static rules** (`code-*`, one finding per rule and file, seeds / migrations / scripts / tests left out where the
|
||||
rule is about requests):
|
||||
|
||||
@@ -226,10 +226,13 @@
|
||||
"browserslist@<4.28.7": "^4.28.7",
|
||||
"cross-spawn@>=7 <7.1.0": "^7.1.2",
|
||||
"dompurify@<3.4.17": "^3.4.17",
|
||||
"esbuild@<0.25.0": "^0.25.12",
|
||||
"eslint@>=9 <9.39.4": "^9.39.4",
|
||||
"fast-copy@<3.1.0": "^3.1.0",
|
||||
"fast-uri@<3.1.9": "^3.1.9",
|
||||
"happy-dom@<21.0.4": "^21.0.4",
|
||||
"js-yaml@>=4 <4.3.2": "^4.3.2",
|
||||
"minimatch@>=7 <11.0.8": "^11.0.10",
|
||||
"source-map-js@<1.2.2": "^1.2.2",
|
||||
"undici@>=7 <7.30.1": "^7.30.1",
|
||||
"ws@>=8 <8.23.0": "^8.23.0"
|
||||
|
||||
Generated
+197
-561
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ create-payload-app gave you an older one.
|
||||
**Node.js 22.23.5 or later** on the 22 line (`"engines": { "node": ">=22.23.5 <23" }`, `.nvmrc` `22`) — Payload 3.94's
|
||||
minimum, also in Coolify (Nixpacks picks the patch: check `node -v` in the app's Terminal after the first deploy). After the install, `pnpm audit --prod` → no high or critical; add the `cross-spawn`, `dompurify`, `happy-dom` and `ws` overrides
|
||||
from AGENT.md §4 item 12 (`"happy-dom@<21.0.4": "^21.0.4"` fixes two high advisories Lexical still brings in,
|
||||
`"ws@>=8 <8.23.0": "^8.23.0"` one in Payload's `ws`). On an
|
||||
`"ws@>=8 <8.23.0": "^8.23.0"` one in Payload's `ws`; a Postgres site also the `esbuild` one listed there). On an
|
||||
older Payload also the `mongoose` (MongoDB) and `undici` ones listed there. `pnpm exec iapl-doctor` → no
|
||||
`transitive-min` finding.
|
||||
`nodemailer`, `lucide-react`, `slugify`, `server-only` come with the plugin — do not add them (your own
|
||||
|
||||
@@ -188,7 +188,8 @@ saves; `pnpm exec iapl-doctor` → no `versions` finding; Coolify app → Termin
|
||||
|
||||
**Every upgrade — dependency advisories** (AGENT.md §4 item 12): `pnpm audit --prod`; on Payload 3.94.x add the
|
||||
`cross-spawn`, `dompurify`, `happy-dom` and `ws` overrides to `pnpm.overrides` (`ws`: GHSA-37g9-w4hg-h9qr, high;
|
||||
`cross-spawn`: GHSA-ghv9-86vm-4v8m, critical, Windows only; both 1.18.0); on an older Payload also `mongoose` (MongoDB sites; 3.90–3.93
|
||||
`cross-spawn`: GHSA-ghv9-86vm-4v8m, critical, Windows only; both 1.18.0); a Postgres site also
|
||||
`"esbuild@<0.25.0": "^0.25.12"` (via drizzle-kit, AGENT.md §4 item 12); on an older Payload also `mongoose` (MongoDB sites; 3.90–3.93
|
||||
pin 8.24.1, which has a critical advisory, GHSA-pcrw-h46h-c93h, and four more) and `undici` (3.90–3.91):
|
||||
```json
|
||||
"cross-spawn@>=7 <7.1.0": "^7.1.2",
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* pnpm security:gate — the security suites that need no built site (docs/security.md → "Security suites"):
|
||||
* 1. dependency audit: `pnpm audit --prod` must show no high or critical advisory (the plugin's own production
|
||||
* dependency tree; dev tooling is reported, not failed);
|
||||
* 1. dependency audit: `pnpm audit` must show no moderate, high or critical advisory, in the production tree AND
|
||||
* the dev tooling (since 1.18.0; lows are reported). `--audit-level high` fails only on high and critical again
|
||||
* (`low` fails on lows too); `--prod-only` judges the production tree and only reports the dev tooling;
|
||||
* 2. static rules over the plugin, its scripts and the reference site, every hit judged in
|
||||
* test/security-patterns.allow.json (test/securityPatterns.test.ts), and the per-class tests
|
||||
* (test/securityClasses.test.ts);
|
||||
@@ -10,7 +11,8 @@
|
||||
* the image `ghcr.io/zaproxy/zaproxy:stable` is already on this machine — the scan runs offline (`-I` keeps
|
||||
* warnings from failing; failures fail). Pull the image once yourself: `docker pull ghcr.io/zaproxy/zaproxy:stable`.
|
||||
* The built-site part (attack probes, closed doors) is `pnpm e2e:built`.
|
||||
* Options: --offline (skip the audit, it needs the registry), --zap <url>.
|
||||
* Options: --offline (skip the audit, it needs the registry), --audit-level <low|moderate|high|critical> (default
|
||||
* moderate), --prod-only, --zap <url>.
|
||||
*/
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import path from 'node:path'
|
||||
@@ -21,6 +23,18 @@ const args = process.argv.slice(2)
|
||||
const zapAt = args.indexOf('--zap')
|
||||
const zapUrl = zapAt >= 0 ? args[zapAt + 1] : null
|
||||
const results = []
|
||||
const levelAt = args.indexOf('--audit-level')
|
||||
const LEVELS = ['low', 'moderate', 'high', 'critical']
|
||||
const level = levelAt >= 0 ? args[levelAt + 1] : 'moderate'
|
||||
if (!LEVELS.includes(level)) {
|
||||
console.error(`[security:gate] --audit-level must be one of ${LEVELS.join(', ')}, got ${JSON.stringify(level)}`)
|
||||
process.exit(2)
|
||||
}
|
||||
const prodOnly = args.includes('--prod-only')
|
||||
/** The severities that fail the gate: the chosen level and everything above it. */
|
||||
const failing = LEVELS.slice(LEVELS.indexOf(level))
|
||||
const fails = (v) => failing.some((s) => (v?.[s] ?? 0) > 0)
|
||||
const counts = (v) => `${v.critical ?? 0} critical, ${v.high ?? 0} high, ${v.moderate ?? 0} moderate, ${v.low ?? 0} low`
|
||||
|
||||
const step = (label, command, commandArgs, { allowFail = false } = {}) => {
|
||||
console.log(`\n[security:gate] ${label}`)
|
||||
@@ -30,7 +44,7 @@ const step = (label, command, commandArgs, { allowFail = false } = {}) => {
|
||||
}
|
||||
|
||||
if (!args.includes('--offline')) {
|
||||
const audit = step('dependency audit (pnpm audit --prod)', 'pnpm', ['audit', '--prod', '--json', '--ignore-workspace'], { allowFail: true })
|
||||
const audit = step(`dependency audit (pnpm audit, fails on ${failing.join(' / ')}${prodOnly ? ', production tree only' : ''})`, 'pnpm', ['audit', '--prod', '--json', '--ignore-workspace'], { allowFail: true })
|
||||
let v = null
|
||||
try {
|
||||
v = JSON.parse(audit.stdout).metadata?.vulnerabilities ?? null
|
||||
@@ -41,14 +55,21 @@ if (!args.includes('--offline')) {
|
||||
console.error(` pnpm audit gave no result: ${(audit.stderr || audit.stdout).trim().split('\n')[0]}`)
|
||||
results.at(-1).ok = false
|
||||
} else {
|
||||
console.log(` production tree: ${v.critical ?? 0} critical, ${v.high ?? 0} high, ${v.moderate ?? 0} moderate, ${v.low ?? 0} low`)
|
||||
results.at(-1).ok = !(v.critical || v.high)
|
||||
console.log(` production tree: ${counts(v)}`)
|
||||
results.at(-1).ok = !fails(v)
|
||||
const dev = spawnSync('pnpm', ['audit', '--json', '--ignore-workspace'], { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })
|
||||
let d = null
|
||||
try {
|
||||
const d = JSON.parse(dev.stdout).metadata?.vulnerabilities
|
||||
console.log(` with dev tooling (reported, not failed): ${d.critical ?? 0} critical, ${d.high ?? 0} high, ${d.moderate ?? 0} moderate, ${d.low ?? 0} low`)
|
||||
d = JSON.parse(dev.stdout).metadata?.vulnerabilities ?? null
|
||||
} catch {
|
||||
// ignore
|
||||
// no JSON: the registry did not answer
|
||||
}
|
||||
if (!d) {
|
||||
console.error(' pnpm audit (with dev tooling) gave no result')
|
||||
if (!prodOnly) {results.at(-1).ok = false}
|
||||
} else {
|
||||
console.log(` with dev tooling${prodOnly ? ' (reported, not failed: --prod-only)' : ''}: ${counts(d)}`)
|
||||
if (!prodOnly && fails(d)) {results.at(-1).ok = false}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,14 @@ export const TRANSITIVE_MIN_SAFE: { major?: number; min: string; name: string; o
|
||||
severity: 'warning',
|
||||
why: 'GHSA-ghv9-86vm-4v8m (critical, command injection when spawning batch files — Windows only); comes with cross-env and eslint',
|
||||
},
|
||||
{
|
||||
name: 'esbuild',
|
||||
major: 0,
|
||||
min: '0.25.0',
|
||||
override: '"esbuild@<0.25.0": "^0.25.12"',
|
||||
severity: 'warning',
|
||||
why: 'GHSA-67mh-4wv8-2f99 (moderate, esbuild\'s dev server answers any origin); on a Postgres site it comes with @payloadcms/db-postgres → drizzle-kit → @esbuild-kit',
|
||||
},
|
||||
{
|
||||
name: 'ws',
|
||||
major: 8,
|
||||
|
||||
@@ -373,6 +373,9 @@ describe('versions', () => {
|
||||
expect(rules(csOld)).toEqual(['transitive-min:warning'])
|
||||
expect(csOld.findings[0].fix).toContain('"cross-spawn@>=7 <7.1.0": "^7.1.2"')
|
||||
expect(rules(await doctor(project({ ...base(), 'pnpm-lock.yaml': csLock('7.1.2') }), ['transitive-min']))).toEqual([])
|
||||
const esLock = (v: string) => `lockfileVersion: '9.0'\n\npackages:\n\n esbuild@${v}:\n resolution: {integrity: x}\n\nsnapshots:\n\n esbuild@${v}: {}\n`
|
||||
expect(rules(await doctor(project({ ...base(), 'pnpm-lock.yaml': esLock('0.18.20') }), ['transitive-min']))).toEqual(['transitive-min:warning'])
|
||||
expect(rules(await doctor(project({ ...base(), 'pnpm-lock.yaml': esLock('0.25.12') }), ['transitive-min']))).toEqual([])
|
||||
// no MongoDB adapter, no lexical: nothing to report
|
||||
expect(rules(await doctor(project(base()), ['transitive-min']))).toEqual([])
|
||||
const silenced = await doctor(at('8.24.1', '20.14.6'), ['transitive-min'], { config: { rules: { 'transitive-min': { off: true, reason: 'Payload upgrade booked' } } } })
|
||||
|
||||
Reference in New Issue
Block a user