Lens / Scrolloop Sentry

Security model and audit

Security model

The security document lists every control with where it lives and what verifies it. In short: Argon2id passwords with lockout and rate limits; RS256 tokens with kid and AES-256-GCM encrypted private keys; hashed, rotated refresh tokens with family revocation; cookie-only access tokens with httpOnly, Secure and SameSite=Strict; schema plus row isolation with a tenant-binding guard; IAM-style authorization with explicit deny; recursive audit redaction; HMAC-signed webhooks and SSRF defences on every outbound path.

Compliance language is deliberately careful: the controls make the platform SOC 2 and GDPR ready in the sense that an auditor can test them, but certification also needs an observation period and organisational controls outside the repository.

ASVS Level 2 pass (2026-10-20)

A structured review against OWASP ASVS produced findings across severities, each with a fix and a regression test under test/e2e/security or a named unit spec. The critical and high classes were:

• Token confusion: a half-authenticated MFA-pending token was accepted as a full access token, and some guards trusted any validly signed token as the user identity.

• Tenant boundary: any tenant member could create tenants and set a tenant's custom domain; a request body could override the request's tenant when creating an OAuth client; management routes skipped session checks so revoked sessions stayed valid for the token lifetime.

• Authentication bypass paths: magic-link login skipped an enrolled MFA factor, and suspended users could still sign in with a password.

• Privilege and redirect handling: invites could grant a role above the inviter's, and the social-login return URL was checked with a prefix match that leaked the completion token to an attacker origin.

Medium findings covered SSRF deny-list gaps (CGNAT, 0/8, hex-mapped IPv6, multicast), the LDAP API returning an encrypted bind password, GCM auth-tag length not enforced, missing log redaction, an unsigned social state, and invite and verification tokens stored in plaintext (now hashed, with a migration that backfills every tenant schema).

Foundation hardening pass

Before the audit, a hardening pass fixed a password-reset account takeover (code-only lookup, a weak random source, no limits, replayable), a hard-coded secret on a spec endpoint, health checks that needed a tenant, cookie policy drift across four controllers, audit metadata that leaked secrets nested in arrays, and 16 failing unit tests. It also added JWKS and discovery endpoints, an env contract that matches the runtime, a compose file, and the CI pipeline.

Operating it safely

Production needs NODE_ENV=production, TRUST_PROXY, a shared COOKIE_DOMAIN for subdomain tenancy, a verified database TLS configuration, Redis with auth and TLS, and the four secrets (KEYRING_MASTER_KEY, TOKEN_ENCRYPTION_KEY, JWT_SECRET, SESSION_SECRET) from a secret manager. Seed and rate-limit-disable switches must never be set in production, Swagger turns itself off, and rotating the keyring master key currently needs a re-encryption step that has no tooling yet.

Tracked hardening work

A small number of lower-severity items remain tracked with acceptance criteria rather than hidden: stricter request-body rejection, an append-only audit table with retention and pseudonymisation, tenant-namespaced rate-limit keys, dependency advisories on the frontend framework, and key-encryption refinements. Reports go through the private disclosure process in SECURITY.md.