M1 review: account rules before 2FA, the SMTP password stays with its server, the rest of the findings
M1-1 the first-user route is the plugin's own endpoint in front of Payload's; nothing is read from the path.
M1-2 the account rules are put on the collections before the 2FA package wraps them.
M1-6 the admin rule only where the roles are the plugin's; other staff collections: an account of that collection.
update / delete get the matching defaults (accounts.adminOnlyWrite); doctor rule staff-accounts-open.
M1-5 access.firstUserAdmin: false with a role below the panel role: the default panel role steps aside, an explicit one is refused.
M1-3 a save that changes the SMTP server, port, user or encryption must send the password again (secrets.reenterOnChange);
new panel field smtpRequireTls.
M1-4 a restore of a version masks the secrets (maskSecretsOnRestore).
M1-7 a refused origin is logged once with the ways to allow it; default ports are normalised.
Minors: m1 day boundary, m3 e-mail check on reset and bulk update, m4 text of 'all', m5 the mask is never kept.
The account suite runs with 2FA off and on.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
81cee02e78
commit
1141c749de
@@ -183,13 +183,34 @@ export const securityRules: DoctorRule[] = [
|
||||
group: 'security',
|
||||
source: 'deep',
|
||||
},
|
||||
{
|
||||
// A staff collection that an account of another auth collection (a customer, a member) may write to:
|
||||
// it can create a staff account, or change a staff account's password. The plugin's default rules close
|
||||
// it (accounts.adminOnlyCreate / adminOnlyWrite); this fires when they are off or a project's own rule is wider.
|
||||
id: 'staff-accounts-open',
|
||||
check: (ctx) =>
|
||||
(ctx.deep?.staffOpenToOthers ?? []).map((entry) => {
|
||||
const [slug, operation] = entry.split(':')
|
||||
return {
|
||||
fix: `give "${slug}" an access.${operation} rule that asks for a staff account (staffCreateAccess, staffUpdateAccess('${slug}'), adminOrSelfIn('${slug}')), or drop accounts: false / accounts.adminOnly${operation === 'create' ? 'Create' : 'Write'}: false`,
|
||||
message: `an account of another auth collection may ${operation} in the staff collection "${slug}"${operation === 'create' ? ': it can make itself a staff account' : operation === 'update' ? ": it can change a staff account's password" : ''}`,
|
||||
severity: 'error' as const,
|
||||
}
|
||||
}),
|
||||
docs: 'docs/access.md',
|
||||
group: 'security',
|
||||
source: 'deep',
|
||||
},
|
||||
{
|
||||
// Turnstile lets submissions through while it is misconfigured or Cloudflare fails ("degraded") — visible here.
|
||||
id: 'turnstile-degraded',
|
||||
check: (ctx) => {
|
||||
const status = ctx.deep?.turnstile
|
||||
if (!status || status.state !== 'degraded') {return []}
|
||||
const hours = status.since ? Math.floor((Date.parse(`${ctx.today}T23:59:59Z`) - Date.parse(status.since)) / 3_600_000) : null
|
||||
// "Now": the clock when the run is for today; for another date (a test, a replay) the middle of that day.
|
||||
// Not the END of the day: a state that began at 23:59 would be "a day old" a minute later.
|
||||
const now = ctx.today === new Date().toISOString().slice(0, 10) ? Date.now() : Date.parse(`${ctx.today}T12:00:00Z`)
|
||||
const hours = status.since ? Math.floor((now - Date.parse(status.since)) / 3_600_000) : null
|
||||
const long = hours !== null && hours >= 24
|
||||
return [{
|
||||
fix: 'Site integrations → Spam protection: both keys from the same Cloudflare widget; then send a test form',
|
||||
|
||||
@@ -5,7 +5,7 @@ import { readFileSync } from 'node:fs'
|
||||
|
||||
import type { DoctorStatus } from './types.js'
|
||||
|
||||
import { openSignUpCollections } from '../access/selfRegistration.js'
|
||||
import { openSignUpCollections, staffCollectionsOpenToOthers } from '../access/selfRegistration.js'
|
||||
import { countPendingCookies } from '../consent/scanner/approval.js'
|
||||
import { COOKIE_REVIEW_SLUG } from '../consent/scanner/collection.js'
|
||||
import { secondFactorPassed, SETUP_FROM_FIELD } from '../security/totp/secondFactor.js'
|
||||
@@ -68,7 +68,13 @@ export async function collectDoctorStatus(payload: BasePayload): Promise<DoctorS
|
||||
} catch {
|
||||
openSignUp = null
|
||||
}
|
||||
return { node: process.version, openSignUp, pendingCookies, plugin: pluginVersion(), turnstile, turnstileSecretFromEnv: secretFromEnv, usersSetupClosed, usersWithout2fa }
|
||||
let staffOpenToOthers: null | string[] = null
|
||||
try {
|
||||
staffOpenToOthers = await staffCollectionsOpenToOthers(payload as never)
|
||||
} catch {
|
||||
staffOpenToOthers = null
|
||||
}
|
||||
return { node: process.version, openSignUp, pendingCookies, plugin: pluginVersion(), staffOpenToOthers, turnstile, turnstileSecretFromEnv: secretFromEnv, usersSetupClosed, usersWithout2fa }
|
||||
}
|
||||
|
||||
export type DoctorEndpointOptions = {
|
||||
|
||||
@@ -65,6 +65,11 @@ export type DoctorStatus = {
|
||||
openSignUp?: null | string[]
|
||||
pendingCookies?: null | number
|
||||
plugin?: string
|
||||
/**
|
||||
* Staff collections an account of ANOTHER, non-staff auth collection may create in, update or
|
||||
* delete from: `'users:update'`. Slugs and operations only.
|
||||
*/
|
||||
staffOpenToOthers?: null | string[]
|
||||
/** The Turnstile integration's recorded state (Site integrations): never a key, only the state. null = not known. */
|
||||
turnstile?: { code?: null | string; since?: null | string; state?: null | string } | null
|
||||
/** The Turnstile secret key in use comes from the environment (the panel field is empty). Deprecated. */
|
||||
|
||||
Reference in New Issue
Block a user