Security Overview

Simcha DB Studio executes SQL and DDL against production databases and custodies live credentials for every managed connection. The threat model is accordingly a privileged one: the application is both an authenticated multi-user surface and a secret store. Controls are layered so that a failure in any single control does not collapse the whole posture.

Control Layers

LayerMechanismProperty enforced
AuthenticationStateless JWT (HS256), bcrypt(12) credential hashing, optional TOTP MFAIdentity assurance; no server-side session store to compromise or exhaust
AuthorizationRBAC middleware (extractUser / requireAuth / requireRole) over 5 roles; license-tier route gatingLeast privilege; separation of duties across the change-management workflow
Secret confidentialityAES-256-GCM at rest with per-record PBKDF2-SHA512 key derivationConnection passwords, MFA secrets, and sensitive settings unreadable at rest
Transport / header hardeningHelmet-managed headers incl. HSTS and CSP; strict CORS allowlistDowngrade, framing, MIME-sniff, and cross-origin abuse mitigated
Abuse controlTiered rate limiting (general vs. DB DevOps bulk windows)Credential stuffing, brute force, and API flooding throttled
AccountabilityGlobal audit middleware writing a DB-sealed, append-only hash chainNon-repudiable, tamper-evident record of every state change

Trust Boundaries

The browser never speaks to Express directly. Requests traverse Next.js API routes (pages/api/*) which forward to the Express backend, propagating Authorization, X-Request-Id, and the non-prod X-QA-Bypass-Key header. Auth, RBAC, license gating, encryption, and audit all execute server-side; the frontend holds a bearer token and nothing else of consequence. The bypass headers (X-QA-Bypass-Key, X-Agent-Key) that inject a virtual admin are hard-gated to NODE_ENV !== 'production', leaving them enabled in production is a critical finding.

HTTP Header Posture (Helmet)

HeaderValueRationale
Strict-Transport-Securitymax-age=31536000Pins HTTPS once seen over TLS; forecloses SSL-strip on repeat visits
Content-Security-Policyself + 'unsafe-eval'unsafe-eval is required by the Monaco editor's AMD loader; the remainder of the policy constrains script/style origins to defeat inline injection
X-Frame-OptionsSAMEORIGINClickjacking / UI-redress defense
X-Content-Type-OptionsnosniffBlocks MIME confusion on responses
X-DNS-Prefetch-ControloffSuppresses side-channel DNS leakage of embedded origins

CSP intentionally retains unsafe-eval. This is a known, scoped exception for Monaco, not blanket permissiveness, treat any additional CSP relaxation as a reviewable change.

Secrets Handled by the Application

Deployment Prerequisites (fail-loud, not fail-open)

ControlSeverityRequirement
JWT_SECRETCritical≥64 chars of CSPRNG output, from a secrets manager. Compromise = universal token forgery across all roles.
ENCRYPTION_KEYCriticalHigh-entropy; required. If unset, EncryptionService no-ops and stores connection passwords and MFA seeds in plaintext (warn-logged only). Never deploy without it.
TLS terminationCriticalTLS 1.2+ at the edge; HTTP→HTTPS redirect. HSTS is emitted by Helmet once served over TLS.
Datastore isolationCriticalThe changeops/DevOps Postgres in a private subnet; ingress only from the app.
Non-prod bypass headers offCriticalConfirm NODE_ENV=production so X-QA-Bypass-Key / X-Agent-Key are inert.
Managed-DB TLSHighsslmode=require or verify-full to target databases.
Secret rotationHighJWT_SECRET annually / on suspicion; DB passwords quarterly; repo tokens per provider policy.
Image scanningHighBlock critical/high CVEs pre-deploy; pin immutable tags.