Legal & Trust
Security Whitepaper
Technical security architecture for reviewers and partners.
Security Whitepaper
Last updated: 2026-07-20
Audience: Security reviewers, technical partners, investors
Status: Reflects the current repository and deployed dev slice — not a certification document
This whitepaper describes Klugliv’s security architecture and controls as implemented in this codebase. It complements the user-facing Security Overview and the Trust Center.
1. Scope
In scope
- Mobile app (Expo / React Native)
- Marketing website (Vercel — static/SSR; no receipt data)
- Supabase (auth, Postgres, private object storage) — current production data plane
- AWS migration slice: API Gateway HTTP API, Lambda (OCR, media presign), S3, KMS, Secrets Manager, CloudWatch, IAM, budgets
- Third-party OCR (Google Cloud Vision) and optional analytics (PostHog)
Out of scope (today)
- Amazon Cognito mobile cutover (Terraform shell exists; app still on Supabase Auth)
- RDS / VPC data plane (planned Phase 3 migration — not active)
- Formal penetration test reports or SOC 2 Type II attestation
2. Threat model (high level)
We primarily defend against:
| Threat | Mitigation direction |
|---|---|
| Unauthorized access to another user’s receipts | Supabase RLS; session validation in Lambda; private storage |
| Secret leakage (OCR keys, service credentials) | Secrets Manager + KMS; no long-lived secrets in mobile builds |
| Public exposure of receipt images | S3 block public access; private Supabase buckets |
| Over-broad infrastructure permissions | Least-privilege IAM per Lambda role |
| Unbounded cost / abuse | API auth gate; AWS budgets; conservative log retention |
We assume clients may be compromised at the device level; server-side authorization remains authoritative.
3. Identity and authentication
Current state
| Component | Mechanism |
|---|---|
| Mobile sign-in | Supabase Auth (email/password or configured providers) |
| API authorization (OCR) | Supabase JWT validated inside Lambda (not API Gateway authorizer yet) |
| Future | Cognito user pool in Terraform; cutover deferred to a later phase |
Design note: Moving JWT validation to API Gateway authorizers is on the roadmap; in-app session validation inside Lambda is the current control.
4. Data classification
| Class | Examples | Handling |
|---|---|---|
| Account identifiers | Email, user UUID | Stored in Supabase; used for auth and data linkage |
| Receipt content | Images, OCR text, line items | Private storage; user can delete per receipt |
| Derived analytics | Spending aggregates in-app | Derived from user-controlled receipt history |
| Operational telemetry | Lambda logs, error traces | Short retention; minimize PII in log lines |
| Product analytics (optional) | PostHog events when configured | Build-time key; not receipt images by default |
5. Network and transport
- All client ↔ service traffic uses TLS.
- AWS resources for the migration slice are configured in
eu-central-1(Frankfurt). - Phase 1 architecture is serverless-first without a VPC/NAT to control cost; VPC is planned when RDS is introduced.
6. Encryption
| Location | Control |
|---|---|
| S3 receipt objects | SSE-KMS (customer-managed key in Terraform) |
| Secrets Manager | Secret encrypted with same KMS key |
| Supabase storage | Provider-managed encryption at rest |
| In transit | HTTPS/TLS end-to-end for API calls |
OCR API keys are not embedded in the mobile app. They are loaded at runtime from Secrets Manager in Lambda.
7. OCR pipeline (AWS slice)
Mobile app ──TLS──► API Gateway ──► Lambda (receipt-ocr)
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
Secrets Manager Google Vision Supabase (auth check)
(KMS encrypted) (OCR API)
Controls
- User must present a valid Supabase session for OCR requests.
- Vision API key never returned to the client.
- Receipt image may be sent as base64 in POST today; S3 presigned upload path exists for dual-write migration.
8. Media presign (S3 dual-write)
When EXPO_PUBLIC_AWS_MEDIA_PRESIGN_URL is configured:
- Mobile requests a short-lived presigned PUT URL from Lambda.
- Upload uses SSE-KMS on the receipts bucket.
- Keys align with Supabase storage paths for operational consistency.
9. Infrastructure as code and change management
- AWS resources are managed with Terraform (remote state in S3 + DynamoDB lock).
- GitHub Actions can plan/apply Terraform via OIDC (
klugliv-dev-github-deployrole) — no long-lived AWS keys in CI. - Secret values (Vision key, Supabase URLs) are set out-of-band via CLI — not committed to git.
10. Logging, retention, and monitoring
| Log type | Typical retention (configured) |
|---|---|
| Lambda / API Gateway (CloudWatch) | ~7–14 days (varies by log group in Terraform) |
| Supabase | Per Supabase project settings |
Practices
- Avoid DEBUG logging of full OCR payloads in production.
- CloudWatch alarms and AWS Budgets provide cost and error signals at dev scale.
11. Third-party and cross-border processing
See Vendor Register and Subprocessors.
Notable cross-border consideration: Google Cloud Vision may process receipt images outside the EU depending on routing and configuration. This is documented in our GDPR readiness review as an area for legal confirmation of transfer mechanisms.
12. Secure development practices
- Monorepo with typed TypeScript (mobile + web).
.envfiles with secrets are gitignored; mobile uses public env vars only where appropriate (EXPO_PUBLIC_*).- DevOps playbook documents security baseline and lessons learned under
docs/devops-playbook/.
13. Known gaps and roadmap (honest)
| Gap | Planned direction |
|---|---|
| API Gateway JWT authorizer | Move validation to edge of API |
| Cognito cutover | Phase 4 — after data plane stability |
| Formal RoPA / DPIA completion | Legal + engineering review |
| In-app consent management for analytics | Shipped — opt-in prompt + Trust & privacy toggle |
| Account deletion self-service | Shipped — Trust & privacy + delete_own_account RPC |
| GuardDuty / Security Hub | Evaluate when signal-to-noise is acceptable |
We do not represent these gaps as completed controls.
14. Related documents
15. Contact
hello@klugliv.com — security inquiries and coordinated disclosure welcome.