c77ff07ce9
Remediation of the 2026-05-12/13 audits (78 findings + cluster gaps), tracked in deploy-k3s/SECURITY.md, plus fixes from two independent post-remediation reviews. Auth & sessions: - SHA-256 hashed auth-token storage (C1); prior-token cache eviction on re-login (MEDIUM-1) - local Google JWKS verification, iss/aud/exp checks (C2/C3) - constant-time login + generic errors (L1/LIVE-L11/LIVE-L13) - per-account login lockout keyed on distinct source IPs (M5/MEDIUM-3) - verified-email gating, login rate limiting (LIVE-L19, H1-H3) IAP & webhooks: - Apple/Google cross-account replay protection (C5/C6/C10/C13, H5/H6) - migrations 000003-000006 (token hashing, IAP replay, audit_log + webhook_event_log table creation, append-only audit log) Authorization & races: - file-ownership owner-OR-member fix (C7), atomic share-code join (C9/H9), device-token reassignment (C8/LOW-3) Secrets & deploy: - secrets file-mounted at /etc/honeydue/secrets, not env (F8); Redis password out of the ConfigMap (HIGH-1); B2 keys reconciled - digest-pinned images, admin ingress hardening, CSP/HSTS, /metrics lockdown; kubeconfig 0600, etcd secrets-encryption, fail2ban + unattended-upgrades at provision; secret-rotation runbook Build, vet, and the full test suite (incl. -race) pass; the goose migration chain is verified against PostgreSQL 16. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
31 lines
1.4 KiB
SQL
31 lines
1.4 KiB
SQL
-- +goose Up
|
|
-- Audit H6 follow-up. The Apple/Google webhook handler now fails CLOSED on a
|
|
-- deduplication-store error: if it cannot consult webhook_event_log it returns
|
|
-- 500 rather than risk processing a replayed event. That makes the presence of
|
|
-- the webhook_event_log table mandatory.
|
|
--
|
|
-- Like audit_log, this table was never created by a goose migration — only by
|
|
-- GORM AutoMigrate in tests — so a from-scratch redeploy would come up without
|
|
-- it and 500 every subscription webhook. CREATE TABLE IF NOT EXISTS brings it
|
|
-- under migration control: a no-op where the table already exists, and a
|
|
-- correct build (matching repositories.WebhookEvent) on a fresh database.
|
|
CREATE TABLE IF NOT EXISTS webhook_event_log (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
event_id VARCHAR(255) NOT NULL,
|
|
provider VARCHAR(20) NOT NULL,
|
|
event_type VARCHAR(100) NOT NULL,
|
|
processed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
payload_hash VARCHAR(64)
|
|
);
|
|
|
|
-- (provider, event_id) is the dedup key — matches the
|
|
-- uniqueIndex:idx_provider_event_id GORM tags on repositories.WebhookEvent.
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_provider_event_id
|
|
ON webhook_event_log (provider, event_id);
|
|
|
|
-- +goose Down
|
|
-- The table is intentionally NOT dropped — it may hold deduplication history
|
|
-- that predates this migration, and dropping it would let already-processed
|
|
-- webhook events be replayed. Down is a documented no-op.
|
|
SELECT 1;
|