fix(security): remediate 2026-05-12 audit findings (Stages 2–5)
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>
This commit is contained in:
@@ -99,21 +99,23 @@ func parseTimezone(tz string) *time.Location {
|
||||
return loc
|
||||
}
|
||||
|
||||
// Try parsing as UTC offset (e.g., "-08:00", "+05:30")
|
||||
// We parse a reference time with the given offset to extract the offset value
|
||||
t, err := time.Parse("-07:00", tz)
|
||||
if err == nil {
|
||||
// time.Parse returns a time, we need to extract the offset
|
||||
// The parsed time will have the offset embedded
|
||||
_, offset := t.Zone()
|
||||
return time.FixedZone(tz, offset)
|
||||
// Try parsing as a UTC offset (e.g., "-08:00", "+05:30"). Audit H8:
|
||||
// reject absurd offsets — real timezones are within ±14h of UTC — so a
|
||||
// crafted X-Timezone header cannot shift date math arbitrarily.
|
||||
const maxOffsetSeconds = 14 * 3600
|
||||
if t, err := time.Parse("-07:00", tz); err == nil {
|
||||
if _, offset := t.Zone(); offset >= -maxOffsetSeconds && offset <= maxOffsetSeconds {
|
||||
return time.FixedZone(tz, offset)
|
||||
}
|
||||
return time.UTC
|
||||
}
|
||||
|
||||
// Also try without colon (e.g., "-0800")
|
||||
t, err = time.Parse("-0700", tz)
|
||||
if err == nil {
|
||||
_, offset := t.Zone()
|
||||
return time.FixedZone(tz, offset)
|
||||
if t, err := time.Parse("-0700", tz); err == nil {
|
||||
if _, offset := t.Zone(); offset >= -maxOffsetSeconds && offset <= maxOffsetSeconds {
|
||||
return time.FixedZone(tz, offset)
|
||||
}
|
||||
return time.UTC
|
||||
}
|
||||
|
||||
// Default to UTC
|
||||
|
||||
Reference in New Issue
Block a user