-
Notifications
You must be signed in to change notification settings - Fork 11
07 Security
Vicky Patel edited this page Sep 14, 2026
·
1 revision
Engineering specification for authentication, authorization, data encryption, and security boundaries.
PACT OS operates on a Zero-Trust Client security model:
graph TD
Client[Untrusted Client / Web Browser] -->|HTTPS + Session Cookie| SA[Next.js Server Actions]
SA -->|1. Validate Payload| Zod[Zod Schema Layer]
SA -->|2. Verify Identity| Auth[Supabase Auth Engine]
SA -->|3. Query Database| DB[(PostgreSQL Database)]
DB -->|4. Enforce Policy| RLS[Row Level Security: auth.uid = user_id]
- Authentication tokens (
access_token,refresh_token) are managed in HTTP-only, SameSite=Lax encrypted cookies. - Server Actions derive user identity via
supabase.auth.getUser(). Client-submitteduser_idparameters in request bodies are ignored.
- Supports passwordless authentication using FIDO2/WebAuthn passkeys (Touch ID, Face ID, YubiKey).
- Server generates a 32-byte base64url challenge token stored in database table
passkey_credentials. - Prevents replay attacks by invalidating used challenge tokens upon verification.
100% of PostgreSQL tables enforce strict multi-tenant isolation through RLS policies:
- Direct access to foreign user records returns empty result sets (
0 rows affected). - Service role keys are restricted strictly to server-side background cron execution (
/api/cron/sweep-deadlines).
Unactivated consequence payloads (such as emergency reflection tasks or financial pledges) remain encrypted/masked in the database until a deadline breach occurs:
- Client queries to
consequencestable omit sensitive payload details prior tois_activated = true. - Prevents users from inspecting or tampering with consequences prior to deadline evaluation.
- Monetary amounts are represented strictly as
bigintinteger cents (amount_cents). - Eliminates IEEE 754 floating-point rounding errors and currency manipulation vulnerabilities.
User account data exports generate a sanitized archive:
- Included Data: Tasks, goals, habits, focus logs, finance transactions, weekly reviews.
- Sanitized Fields: OAuth access tokens, refresh tokens, password hashes, and session tokens are stripped prior to ZIP compression.
PACT OS incorporates automated security gates executed during CI:
-
Secret Scanner (
scratch/secret-scan.mjs): Scans codebase for leaked API keys, tokens, and credentials. -
Dependency Audit (
docs/DEPENDENCY_SECURITY.md): Automated npm audit scans enforcing zero high/critical vulnerabilities.
| 🏛️ Project Hub | 🛠️ Developer Docs | 💬 Community & Support |
|---|---|---|
| GitHub Repository | System Architecture | GitHub Discussions |
| Beginner Issue Catalog | Design System | Open Issues |
| Production Deployment | API Reference | Pull Requests |
| Project Roadmap | Testing & QA Matrix | Maintainer Governance |
- Codebase Tour
- Domain Model
- Database Architecture
- Security Model
- Financial System
- Consequence System
- External Integrations
- Discipline Intelligence
- Data Portability & Sync