Security and privacy
How data is kept apart per workspace, how sign-in and public pages are protected, and what is not done yet.
Not legal advice. This page describes what the code does to keep each workspace's data apart and protected. Check your own obligations under DPDP and other law with a qualified adviser.
What it does
Workspaces are kept apart in the database
- Every table that holds workspace data has forced row-level security. Each request and each Worker job runs in one transaction that sets the workspace id first, and a query sees only that workspace's rows.
- The App, the Worker and the MCP server connect as role
ap_app, which cannot bypass row-level security and owns no tables. Sign-in and session creation use a separate role,ap_web_login, the only one allowed to read password hashes. - The audit log, consent receipts and consent events refuse updates, deletes and truncation in the database itself. Audit entries mask personal values (names, phone numbers, emails, message text) and secrets.
Sign-in and sessions
- Email and password only. Passwords are 10 to 128 characters and are hashed with scrypt and a random salt.
- A session is a random 256-bit token in an
HttpOnly,Secure,SameSite=Laxcookie. Only its SHA-256 hash is stored. Sessions last 14 days, and expired sessions are purged hourly. - Sign-in is rate limited per network address and per email address.
- Roles: the owner sees Admin (members and roles, workspace settings, the MCP key and the other admin tabs), Consent and adding events; staff do not. Admin shows the full permission matrix.
- Every form post checks that it came from this site before it checks the session.
Every page and response
- A Content-Security-Policy allows scripts only from the site with a per-request nonce, styles only from the site's own files (no inline styles), and no framing by other sites.
- HSTS,
nosniffand a strict referrer policy are sent with every response. The camera is allowed on Expo Mode pages only. - Public pages with a token (the visitor form and the receipt page) are rate limited: 60 requests a minute per network address, and 20 a minute per receipt link. The booth form is limited per address only, because every visitor shares its token. Over the limit the answer is "Too many requests. Try again in N seconds."
- Error messages are fixed texts chosen by a code. No text from the URL is ever shown on a page.
Files you upload
- The real content type is checked, whatever the file name says. Zip files are checked before anything is opened: no paths outside the folder, no zip bombs, no zip64. Media inside a WhatsApp zip is never read.
- An import's file is not kept, only the text of the chat or mails.
- An Expo Mode photo is kept until the card is confirmed on its review screen, or deleted once processed when it could not be read.
AI calls
Every AI call goes through one gateway that, in order: checks the token budget of the purpose and the workspace's daily budget, withholds text that looks like instructions aimed at the assistant (English and Hinglish rules), wraps outside text as data, and checks the answer against its schema. Quotes must appear word for word in the source. Answers that leak a secret or the system prompt are refused. Drafts are checked for sources, length, wording and numbers. The red-team cases in prompts/*/redteam run with npm run redteam.
Secrets
- Configuration is read in one place (
src/platform/config), and the App refuses to start withoutAUTH_SECRETandCONSENT_MASTER_KEYof at least 32 characters each. npm run scan:secretschecks staged files before a commit (hook H7), and the CI checks job runs it too.- Each workspace's signing key is derived from the master key, so no private key is stored.
Demo copies
Demo copies hold synthetic data only (reserved phone numbers and email domains) and are deleted after 24 hours by a database function that can delete only an expired demo copy.
Limits
- Not verified live: the AWS stack was deployed once and
/api/healthanswered on the host. Public HTTPS on the current address, sign-in on the public site and the browser pages there have not been confirmed. Amazon Bedrock has not been called; the deployed stack runs the Simulators. - Rate limits are kept in each process's memory, so they reset on a restart and are not shared between processes.
- The client address is the last
X-Forwarded-Forentry, which is right only behind exactly one proxy (Caddy in the deployed stack). - Not built yet: erasure of a person's details on request, a data retention job, signed ledger checkpoints (so removing the newest consent events is not detected), expiry of receipt links, and revoking an MCP key.
- Draft approvals and hand-overs are recorded on the draft but not in the audit log.
- Encryption at rest and TLS to the database come from the AWS setup (encrypted RDS that requires TLS, a private S3 bucket with server-side encryption), not from the App.
Troubleshooting
| What you see | What it means |
|---|---|
| "Too many tries from this address. Wait a minute, then try again." | The sign-in limit was reached. Wait a minute. |
| "Too many requests. Try again in N seconds." | A public page limit was reached. |
Sign-in is refused on a local next start | Without a proxy there is no X-Forwarded-For header. Use npm run dev, or run behind a proxy that sets it. |
| "Requests from another site are refused." | A form was posted from another site. Open the App directly and try again. |
| The App does not start and names a variable | A required setting is missing or too short. See .env.example. |
See also Consent records and the ledger.