From cdf80744ea850a5fd6e73094b1b68a9c08e6fba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Tue, 27 Oct 2026 21:53:22 +0100 Subject: [PATCH] 1.14.1 Version bump and CHANGELOG entry: withSecurityConfig (hide X-Powered-By), opt-in CSP through buildSecurityHeaders({ csp }) with report-only/enforce and reports, createCspReportRoute, buildAdminCspHeaders, opt-in nonces, new buildCsp flags with extra/override, ipal-audit header check; nothing required on upgrade. Co-Authored-By: Claude Opus 5.5 --- docs/CHANGELOG.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7acf374..c4f33f6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,60 @@ versions at once, go through every "Requires project changes" section in order, version you have. A new release = a new section at the top; we remove the oldest ones only once there are more than 20. +## 1.14.1 + +Response-header hardening from the intecion.com audit: hide `X-Powered-By`, and a Content-Security-Policy the project +can roll out safely (report-only first, with reports). Everything is opt-in; nothing changes until the project uses it. + +### New +- **`withSecurityConfig(nextConfig, { hidePoweredBy })`** — hides `X-Powered-By` (Next's `Next.js` and the + `Next.js, Payload` that `withPayload` adds) by setting `poweredByHeader: false` and dropping the header from + `headers()` rules. Works on either side of `withPayload`. Opt out: `hidePoweredBy: false`. +- **`buildSecurityHeaders({ csp })`** — off by default (`csp: false`). Pass `buildCsp` args to add the policy: + `mode: 'report-only'` (`Content-Security-Policy-Report-Only`) or `'enforce'`; with `reportUri` the policy gets + `report-uri` / `report-to` and the `Reporting-Endpoints` header is added (`reportGroup`, default + `csp-endpoint`). A hand-written policy in `additional` still wins. +- **`createCspReportRoute()`** — a POST route for violation reports (both the legacy `application/csp-report` and the + Reporting API format), logged as one `[csp]` line each (`onReport` to send them elsewhere, `maxBytes`); `parseCspReports` for your own handler. +- **`buildAdminCspHeaders` / `buildAdminCsp`** — a policy for `/admin/:path*` that fits Payload's admin, with the same + `mode` / `reportUri` / `extra` / `override`. +- **Nonces (opt-in)** — `createProxy(config, { csp })` creates a per-request nonce, puts the policy on the request (Next + adds the nonce to its own scripts) and the response, and exposes it as the `x-nonce` request header; + `` passes it to the theme script and the analytics tags (`ThemeScript`, `Analytics`, + `ConsentScript` take `nonce`). `strictDynamic` (default on with a nonce). Nonces need dynamic rendering, so they are + only for sites that render per request; static and ISR sites keep the header-only CSP. `createCspNonce`, + `CSP_NONCE_HEADER`. +- **`buildCsp` flags** — `metaPixel`, `linkedIn`, `tiktok`, `clarity` next to `analytics`, `turnstile`, `youtube`, + `googleMaps`, `r2Url`; `dev` (adds `'unsafe-eval'`, default `NODE_ENV === 'development'`); `extra` adds sources + to any directive; `override` replaces a directive (`null` drops it). `buildCspHeaders`, `buildReportingEndpoints`, + `cspHeaderKey`, types `CspDirective`, `CspSources`, `CspViolation`. +- **ipal-audit** — checks the response headers: `X-Powered-By` anywhere → ERROR; no CSP on the site or `/admin` → + WARNING; report-only for weeks with clean reports → WARNING (switch to enforce). + +### Changed +- `buildCsp` allowlists are slightly wider (nothing that was allowed is now blocked): `analytics` also allows the + Google Signals hosts (`https://*.g.doubleclick.net`, `https://www.google.com`) in `connect-src` and `img-src`; + `r2Url` is also added to `media-src`; in development `'unsafe-eval'` is added (`dev: false` to turn it off). + The order of the directives in the header changed (cosmetic). +- `buildSecurityHeaders({})` output is unchanged. + +### Documentation +- security.md rewritten: X-Powered-By, CSP roll-out (report-only → enforce), report route, admin policy, nonces vs + static pages. AGENT.md, ipal-setup, ipal-reference, ipal-audit, ipal-upgrade. + +### What projects must update +Nothing is required. Recommended, in this order (ipal-upgrade → 1.14.1, security.md): +1. **Hide `X-Powered-By`:** `export default withPayload(withSecurityConfig(nextConfig))`; remove a hand-written + `poweredByHeader: false`. **Check:** `curl -sI /pl | grep -i x-powered-by` → nothing (also `/admin`). +2. **CSP report-only:** `buildSecurityHeaders({ csp: { mode: 'report-only', reportUri: '/api/csp-report', r2Url: + process.env.R2_PUBLIC_URL, …flags for what the site loads } })`, the admin rule + `{ source: '/admin/:path*', headers: buildAdminCspHeaders({ mode: 'report-only', reportUri: '/api/csp-report' }) }` + and `src/app/api/csp-report/route.ts` → `export const POST = createCspReportRoute()`. Deploy and read the `[csp]` + lines in the Coolify logs. +3. **Enforce:** after a few days of clean reports, `mode: 'enforce'` in both places; redeploy and check the pages. +4. Projects that already call `buildCsp({ analytics })` or pass `r2Url`: the policy gets the wider allowlists above + after upgrading — review them if the policy is audited line by line. + ## 1.14.0 An image lightbox, a cookie scanner with a browser pre-consent check, an admin panel in English and Polish, and diff --git a/package.json b/package.json index 2136e79..b281ddc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intecion/ipal-kit", - "version": "1.14.0", + "version": "1.14.1", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "license": "MIT", "repository": {