Merge claude/security-c-1172: form submissions over REST only for staff, the job queue for an admin or Bearer CRON_SECRET, doctor visitor-writes

Conflicts with security-a-1172 kept both sides: imports (adminSameOrigin, jobsAccess), the doctor status (originKnown and visitorWrites), its test, and the e2e:built line (A's sign-in answers spec with C's CRON_SECRET).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 11:17:51 +01:00
co-authored by Claude Opus 5.5
40 changed files with 657 additions and 187 deletions
+13 -1
View File
@@ -206,6 +206,18 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
expect(await run(cfg, ['open-signup'])).toEqual([])
})
test('visitor-writes: one warning per entity a visitor account may write, its operations named', async () => {
const cfg = "iapl({ access: { authCollection: 'users' } })"
const report = await doctor(project({ ...base(), 'src/payload.config.ts': cfg }), ['visitor-writes'], { deepStatus: { visitorWrites: ['globals/header:update', 'pages:create', 'pages:delete', 'pages:update'] } })
expect(report.findings.map((f) => `${f.severity}: ${f.message}`)).toEqual([
'warning: an account of a visitor login collection may update the global "header"',
'warning: an account of a visitor login collection may create, delete, update in "pages"',
])
expect(await run(cfg, ['visitor-writes'], { visitorWrites: [] })).toEqual([])
expect(await run(cfg, ['visitor-writes'], { visitorWrites: null })).toEqual([])
expect(await run(cfg, ['visitor-writes'])).toEqual([])
})
test('staff-accounts-open: a staff collection an account of another collection may write to is an error', async () => {
const cfg = "iapl({ access: { authCollection: 'users' } })"
expect(await run(cfg, ['staff-accounts-open'], { staffOpenToOthers: ['agents:delete', 'agents:update', 'users:create'] })).toEqual(['staff-accounts-open:error', 'staff-accounts-open:error', 'staff-accounts-open:error'])
@@ -542,7 +554,7 @@ describe('security and deep status', () => {
}
const status = await collectDoctorStatus(payload as never)
expect(status).toMatchObject({ pendingCookies: 4, usersWithout2fa: 2 })
expect(Object.keys(status).sort()).toEqual(['mail', 'node', 'openSignUp', 'originKnown', 'pendingCookies', 'plugin', 'staffOnOwnRoles', 'staffOpenToOthers', 'turnstile', 'turnstileSecretFromEnv', 'usersSetupClosed', 'usersWithout2fa'])
expect(Object.keys(status).sort()).toEqual(['mail', 'node', 'openSignUp', 'originKnown', 'pendingCookies', 'plugin', 'staffOnOwnRoles', 'staffOpenToOthers', 'turnstile', 'turnstileSecretFromEnv', 'usersSetupClosed', 'usersWithout2fa', 'visitorWrites'])
expect(status.usersSetupClosed).toBeNull() // no setup window in this config
expect(status.mail).toBeNull() // no Site integrations global in this config
})