Skip to content
Toolkit

Security Checklist

File paths below are relative to apps/api/internal/ unless noted.

Transport

ItemStatusNotes
TLS termination✅ Caddy handles TLSCerts auto-renewed via ACME
HSTS✅ Caddy sets Strict-Transport-Security1-year max-age
Redirect HTTP → HTTPS✅ Caddy global redirect

Authentication

ItemStatusNotes
Password hashing✅ bcrypt (cost 10 — bcrypt.DefaultCost)golang.org/x/crypto/bcrypt
JWT expiry✅ 24 h access tokengolang-jwt/jwt/v5
2FA (TOTP)✅ Setup + verify + disable endpointsservices/totp.go
API key validation✅ Bearer token fallbackmiddleware/auth.go
Login lockout✅ 6 attempts / 10 min per IPmiddleware/ratelimit.go → AuthLimiter
Register lockout✅ Same as loginSame middleware
Lost-password lockout✅ Same as loginSame middleware
OAuth state✅ HMAC-SHA256 signed state with 10 min TTL, verified on callbackhandlers/oauth.go → signOAuthState / verifyOAuthState
Session invalidation on password change✅ Password reset invalidates old API keyhandlers/account.go

Input Validation

ItemStatusNotes
Open-redirect guard✅ Allows only http/https destinationshandlers/redirect.go → isSafeRedirectURL
Email validation✅ net/mail.ParseAddressAll auth endpoints
UTF-8 length limits✅ Name ≤ 64, password ≤ 64handlers/auth.go
SQL injection✅ Parameterised queries throughoutpgx/v5, no string interpolation in SQL
File upload MIME check✅ Byte-sniffed via http.DetectContentType and required to agree with the declared typehandlers/uploads.go → sniffMimeType, file_links.go, static_pages.go
SVG uploads✅ Rejected (SVG can carry script); /uploads/* also served with Content-Security-Policy: default-src 'none'; sandbox + nosniffservices/storage.go, cmd/server/main.go
JWT weak-secret guard✅ Boot refuses known-weak/example secrets (case-insensitive, substring); .env.example value is length-invalidconfig/config.go → weakJWTSecrets

CSRF

ItemStatusNotes
X-Requested-With header guard✅ Applied globallymiddleware/security.go → CSRFGuard
Frontend sends X-Requested-With✅ Set as default Axios headerapps/web/src/services/api.ts
Exempt paths✅ GET/HEAD/OPTIONS, /webhook/*, /api/v1/auth/oauth/* (matched via strings.HasPrefix)Same middleware

Security Headers

ItemStatusNotes
X-Content-Type-Options: nosniff✅middleware/security.go → SecurityHeaders
X-Frame-Options: DENY✅Same
Referrer-Policy✅ strict-origin-when-cross-originSame
Content-Security-Policy✅ default-src 'self'; script-src 'self'; frame-ancestors 'none'; object-src 'none'Same. Style-src allows 'unsafe-inline' (design-system inline styles / CSS custom properties); img-src allows https + data:.
CORS allow-list✅ Explicit origin allow-listmain.go CORS config
X-Requested-With in CORS exposed✅main.go
User HTML sanitization✅ Client-side allowlist sanitizer used by RichTextEditor + biolink custom_html blockapps/web/src/lib/sanitizeHtml.ts

Rate Limiting

ItemStatusNotes
Rate limits✅ 60 req/min per principal (API_RATE_LIMIT_PER_MINUTE) on authenticated /api/v1 and /admin-api/v1; 300 req/min per IP on all public routes (redirects, public biolinks, webhooks)middleware/ratelimit.go, cmd/server/main.go
Auth endpoint lockout✅ 6 attempts/10 min per IPmiddleware/ratelimit.go → AuthLimiter
AI quota✅ 50 AI generations/hour per usermiddleware/ratelimit.go → AIQuotaLimiter

Admin Security

ItemStatusNotes
Admin role gate✅ RequireAdmin middlewaremiddleware/auth.go
Admin audit log✅ Every POST/PUT/PATCH/DELETE logged to admin_logsmiddleware/admin_audit.go + migration 000017
Admin bypass maintenance/blacklist✅ Admins exemptmiddleware/maintenance.go

Webhook Security

ItemStatusNotes
HMAC-SHA256/512 verification✅ All gateways with secret supportservices/gateway_*.go
Fail-closed on missing secret✅ In production, an enabled gateway with no webhook secret rejects events (dev skips); startup warns which secrets are unsetservices/webhook_security.go, cmd/server/main.go
Amount verification✅ Webhook total asserted against the server-computed plan price before activating a planhandlers/webhooks.go, handlers/checkout.go → PlanPriceForFrequency
Duplicate rejection✅ webhook_logs unique (gateway, external_id)Migration 000014
Replay window✅ Event processing is idempotent (secondary check on payments table)handlers/webhooks.go

Data Protection

ItemStatusNotes
Blacklist (IP / country / domain)✅ Middleware reads from admin settingsmiddleware/maintenance.go → Blacklist
Maintenance mode✅ Admin-configurable 503middleware/maintenance.go → MaintenanceMode

Observability

ItemStatusNotes
Request ID on every log line✅ X-Request-ID header + contextmiddleware/logging.go
User ID on authenticated requests✅middleware/logging.go
/metrics endpoint✅ Prometheus text formathandlers/observability.go
/ready probe✅ DB pinghandlers/observability.go

Outstanding / Deferred

ItemPriorityNotes
Hashed / scoped / revocable tokens✅ADR-0002: api_tokens (migration 000024) stores a digest only; scopes are checked by middleware
Safe Browsing API check on new link URLsP2Would reject known malware/phishing URLs at creation time
Content-Security-Policy header✅ shipped v1.0.0middleware/security.go
GDPR export✅ shipped v1.0.0GET /api/v1/account/export returns a full per-user data dump
Encrypted gateway secret storageP3Gateway secrets currently in env vars — adequate for single-host deploy
SQLi sweep (automated)P3No dynamic query building found in codebase audit; parameterised throughout

Source: docs/SECURITY.md

Library