Security audit fixes for 1.18.0: Markdown negotiation private + Vary: Accept (F3), public lists capped (F4), operator sort names refused (F5), CSP report log normalised and capped (F1), buildUrlField and the reference socials (F2), document locks for staff only

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 16:56:09 +01:00
co-authored by Claude Opus 5.5
parent d2f19095dc
commit e9f9947eb7
20 changed files with 677 additions and 49 deletions
+3 -6
View File
@@ -161,7 +161,6 @@ export const ATTACK_PROBES: AttackProbe[] = [
{
id: 'markdown-vary',
class: 'cache poisoning (content negotiation)',
finding: 'F3',
live: true,
run: async ({ fetch, page = '/' }) => {
const a = await fetch(page, { follow: true, headers: { accept: 'text/markdown' } })
@@ -169,7 +168,7 @@ export const ATTACK_PROBES: AttackProbe[] = [
const cc = a.headers.get('cache-control') ?? ''
const shared = /s-maxage|public/.test(cc) && !/private|no-store/.test(cc)
const vary = (a.headers.get('vary') ?? '').split(',').map((v) => v.trim().toLowerCase())
if (shared && !vary.includes('accept') && !vary.includes('*')) {return bad(`${page} answers Markdown to Accept: text/markdown with "${cc}" and no Vary: Accept: a shared cache stores it under the HTML URL`)}
if (shared && !vary.includes('accept') && !vary.includes('*')) {return bad(`${page} answers Markdown to Accept: text/markdown with "${cc}" and no Vary: Accept: a shared cache stores it under the HTML URL (IAPL 1.18.0's createProxy sends private + Vary: Accept; a proxy of your own must too)`)}
return ok('the Markdown answer at the HTML URL varies by Accept or is not shared')
},
title: 'the Markdown copy at an HTML URL cannot be cached as the page',
@@ -260,7 +259,6 @@ export const ATTACK_PROBES: AttackProbe[] = [
{
id: 'sort-operator',
class: 'injection (operators in sort)',
finding: 'F5',
live: true,
run: async ({ fetch }) => {
const problems: string[] = []
@@ -268,14 +266,13 @@ export const ATTACK_PROBES: AttackProbe[] = [
const a = await fetch(`/api/pages?sort=${sort}&limit=1&depth=0`)
if (a.status >= 500 || LEAK.test(a.text)) {problems.push(`sort=${decodeURIComponent(sort)} → ${a.status}`)}
}
return problems.length ? bad(`${problems.join('; ')}: an operator name reaches the database as a sort field (an error and a logged stack trace per request)`) : ok('operator names in sort are refused with a 4xx')
return problems.length ? bad(`${problems.join('; ')}: an operator name reaches the database as a sort field (an error and a logged stack trace per request; IAPL 1.18.0 refuses it unless refuseOperatorSort is false)`) : ok('operator names in sort are refused with a 4xx')
},
title: 'an operator name in ?sort= is refused, not passed to the database',
},
{
id: 'unbounded-list',
class: 'denial of service (unbounded queries)',
finding: 'F4',
live: true,
run: async ({ fetch }) => {
const a = await fetch('/api/pages?limit=100000&depth=50')
@@ -286,7 +283,7 @@ export const ATTACK_PROBES: AttackProbe[] = [
} catch {
return skip('not JSON')
}
return (body.limit ?? 0) > 1000 ? bad(`/api/pages?limit=100000 is honoured (limit ${body.limit}, ${a.ms} ms, ${a.text.length} bytes): one anonymous request reads a whole collection`) : ok(`limit capped at ${body.limit}`)
return (body.limit ?? 0) > 1000 ? bad(`/api/pages?limit=100000 is honoured (limit ${body.limit}, ${a.ms} ms, ${a.text.length} bytes): one anonymous request reads a whole collection (IAPL 1.18.0 caps it unless listLimit is false or the collection is excluded)`) : ok(`limit capped at ${body.limit}`)
},
title: 'a public list caps limit (and depth) so one request cannot read a whole collection',
},