0.2.26: security hardening from audit (P2/P3 fixes)
Address the security-auditor findings the user selected (items 2, 3, 4): Default admin credentials (P2): remove the fixed `Ten31` default. First boot now generates a strong random admin password (secrets.token_urlsafe), records it 0600 at /data/.admin-password, and surfaces it once via a new "Show Initial Admin Password" StartOS action (CLI `show-admin-password`). The stored password is cleared when the admin is reset (CLI reset-password) or self-changes it (change-password endpoint). Login hardening (P2): add a per-IP in-memory sliding-window rate limiter (10 failures / 5 min -> 429 + Retry-After) in ratelimit.py; run a dummy argon2 verify when the user is unknown so timing can't enumerate usernames; keep a single generic 401 for unknown-user and wrong-password. Hardening (P3): server process now runs unprivileged -- Dockerfile adds uid 10001 appuser; start.sh (still root) chowns the mounted /data then drops via `setpriv` before exec'ing uvicorn. Spreadsheet imports are size-capped via storage.read_capped (413 past MAX_UPLOAD_SIZE) in the schedule, capital preview, and batch paths. batch_import no longer returns raw exception text (generic per-file messages). Verified in the packed amd64 container: PID1 uvicorn runs as uid 10001, /data owned 10001 with 0600 secrets; generated admin password retrievable via CLI and logs in (200); 11th bad login -> 429; admin reset clears the stored password. Tests: test_auth_hardening.py (4). Full suite 21 passed; frontend tsc + StartOS bundle clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
025aff4fac
commit
69f12b0519
@@ -214,6 +214,44 @@ const listUsersAction = Action.withoutInput(
|
||||
},
|
||||
)
|
||||
|
||||
// ============================================
|
||||
// Action: Show Initial Admin Password
|
||||
// ============================================
|
||||
const showAdminPasswordAction = Action.withoutInput(
|
||||
'show-admin-password',
|
||||
{
|
||||
name: 'Show Initial Admin Password',
|
||||
description:
|
||||
'Reveal the randomly-generated admin password created on first boot. Sign in with it, then change your password — after which this no longer shows it.',
|
||||
warning: null,
|
||||
allowedStatuses: 'only-running',
|
||||
group: null,
|
||||
visibility: 'enabled',
|
||||
},
|
||||
async ({ effects }) => {
|
||||
try {
|
||||
const result = await runCli(effects, ['show-admin-password'], 'show-admin-password-task')
|
||||
if (result.exitCode !== 0) {
|
||||
return errorResult(result.stderr?.toString() || 'Failed to read the admin password')
|
||||
}
|
||||
return {
|
||||
version: '1' as const,
|
||||
title: 'Initial Admin Password',
|
||||
message: 'Sign in as "admin" with this password, then change it from the portal.',
|
||||
result: {
|
||||
type: 'single' as const,
|
||||
value: (result.stdout?.toString() || '').trim() || 'No stored password.',
|
||||
copyable: true,
|
||||
qr: false,
|
||||
masked: true,
|
||||
},
|
||||
}
|
||||
} catch (e: any) {
|
||||
return errorResult(`Failed to read the admin password: ${e.message || e}`)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// ============================================
|
||||
// Action: Delete User
|
||||
// ============================================
|
||||
@@ -379,6 +417,7 @@ const resetHoldingsAction = Action.withInput(
|
||||
export const actions = sdk.Actions.of()
|
||||
.addAction(createUserAction)
|
||||
.addAction(resetPasswordAction)
|
||||
.addAction(showAdminPasswordAction)
|
||||
.addAction(listUsersAction)
|
||||
.addAction(deleteUserAction)
|
||||
.addAction(dedupeAction)
|
||||
|
||||
Reference in New Issue
Block a user