# Product and Application Security Policy

Version 1.0 · Last reviewed 2026-10-26 · Owner: Delora Legal (security@deloralegal.com)

Status: Draft v1.0. Describes controls in place today. Adoption date to be set.

## Purpose

This policy sets out how Delora Legal builds, protects, tests and fixes the Delora application so that the case data US immigration law firms put into it stays confidential, accurate and available. It covers sign-in and multi-factor authentication, audit logging, data security inside the product, how outsiders report vulnerabilities, penetration testing, and how code reaches production.

It is the customer-readable counterpart of Delora's internal drafts. Where this document says a control is *proposed*, the internal draft says so too.

## Scope

- The Delora web application (Next.js on Vercel), its Postgres database (Neon), file storage (Amazon S3, planned for when document upload goes live; document upload is not live and no production bucket exists yet), the AI intake assistant, and the Android apps that call the same API (in development, not yet released to customers).
- The source repository and the continuous integration (CI) pipeline on GitHub.
- Staging, which runs on a separate Vercel environment and Neon branch with synthetic data only.
- Everyone who writes, reviews or deploys Delora code. Today that is the owner alone.

Company-wide access to consoles, laptops and offboarding is covered by the access control and personnel drafts listed under Related documents. Encryption, retention and breach notification are in the Data Security and Privacy Policy.

## Roles and responsibilities

- **Owner and security officer (Delora Legal).** Delora is run by its owner, who holds every role today: engineering, security, support and sales. The owner approves this policy, approves exceptions, triages vulnerability reports, commissions penetration tests and decides what ships. When Delora hires, the owner appoints a named security officer; until then the owner is that person.
- **Engineers.** Follow this policy and the project's written engineering rules (tenant isolation, no real client data outside production, no personal data in logs, sealed identifiers, attorney approval of AI output).
- **Firm administrators (customers).** Choose their firm's multi-factor authentication policy and manage their own members.
- **Security researchers.** Report issues through the channel under Responsible disclosure.

## Policy

### 1. Authentication and multi-factor authentication

1. Users must sign in with an email address and a password of 12 to 128 characters, and must confirm their email address before use.
2. Sessions must expire after 7 days, and a password reset must revoke existing sessions. Password-reset links must expire after one hour.
3. Sign-in, sign-up, password reset, two-factor and demo-request attempts must be rate limited, with limits that hold across serverless instances.
4. The product must support two-factor authentication with an authenticator app (TOTP) and ten one-time backup codes. SMS and email codes must not be offered as a second factor.
5. Each firm must be able to set its own policy: `optional`, `staff` (admins and attorneys must enrol; the default for new firms) or `all` members. A member covered by the firm's policy must be blocked from every firm page and action until they have enrolled, and must not be able to turn two-factor off while the firm requires it.
6. A firm admin must be able to reset a member who lost their phone. The member is signed out everywhere and enrols again.
7. Five wrong codes must end a two-factor challenge, and ten in a row must lock the second factor for 15 minutes. Enrolling or disabling two-factor must revoke the user's other sessions and email the account.
8. Authentication calls must go through rate-limited server actions (web) or the mobile API; the Better Auth HTTP write endpoints must stay unexposed (`/api/auth` is read-only).
9. Mobile bearer tokens must be issued only by the mobile sign-in path and bound to a registered device record.
10. Roles (admin, attorney, paralegal) must be enforced in code and, for form approvals, by a database trigger. Only attorneys and admins may approve a USCIS form.

### 2. Audit logging

1. Each firm's `audit_log` must record key actions by identifier only: firm creation, intake actions, case profile and form actions and approvals, document links, data exports, MFA and policy changes, and deletions. It must never hold names, chat text or identifiers.
2. The `security_events` table must record sign-ins and failures, rate-limit lockouts, two-factor challenges and outcomes, sign-out, password resets, email confirmation, MFA changes and admin resets, policy changes and account deletion, with user id, actor id, IP address and a capped user agent. It must never hold an email address, password, token or code.
3. The application's database role must have INSERT and SELECT only on both tables, with no UPDATE or DELETE grant, so the application cannot edit or remove entries.
4. Users must be able to see their own security events, and firm admins their members' events.
5. Security events must be kept for one year and purged daily. The audit log is kept for the life of the firm today; the proposed target is the life of the firm plus one year.
6. Application logs must not contain personal data. Text that may quote what a person typed must be redacted before it is logged.

### 3. Data security in the product

1. Every tenant table must have a `firm_id`, composite `(firm_id, id)` foreign keys, and row-level security that is both enabled and forced. A query without a firm context must return zero rows.
2. All tenant reads and writes must go through the tenant context (`requireTenant().run()` or `withTenant()`), which verifies membership first.
3. The application's database role must never be a superuser and must never bypass row-level security. In production the application must refuse to start if it would.
4. Social Security numbers, A-Numbers, passport and travel document numbers and USCIS online account numbers must be sealed with AES-256-GCM before storage, bound to the firm, shown masked, and decrypted only when a USCIS form is filled. They must never be logged or sent to any AI service.
5. Delora staff must not sign in to customer firms. Support that needs to see firm data happens through the firm's own account at the firm's written request.
6. Generated USCIS forms must be streamed to the user and never stored.
7. Staging, tests, demos and the repository must use synthetic data only.
8. Every response must carry the security headers listed in the Current implementation table.

### 4. Responsible disclosure

1. Delora welcomes reports of security issues. Reporters must email **security@deloralegal.com** with what they found, the affected URL or component, and steps to reproduce. They must not include real client data and should redact anything sensitive.
2. Delora must acknowledge a report within 2 business days, keep the reporter updated, and tell them when it is fixed.
3. Reporters must test only against their own account, must not access other people's data, and must not run denial-of-service, spam or social-engineering tests.
4. Safe harbour: Delora will not pursue good-faith research that follows these rules.
5. The same contact is published in machine-readable form at `https://deloralegal.com/.well-known/security.txt` (RFC 9116), which names the address above, English and Spanish as preferred languages, and the policy page at `https://deloralegal.com/trust#report`. Its expiry date must be renewed before it lapses; the current file expires on 2027-10-01.
6. Every report must be recorded and handled under the incident process when it shows a real weakness.

### 5. Application penetration testing

1. An independent external penetration test must be carried out at least once a year, and again after a major change to the architecture, authentication or tenant isolation.
2. Tests must run against staging, never production, using synthetic data and the test accounts and scope in the penetration test scope document.
3. The first test is planned. It has not yet been carried out and no testing firm has been named in this policy.
4. After each test, staging test data must be cleaned up and the staging secrets rotated.
5. Findings must be fixed or mitigated within these service levels, counted from discovery. They are proposed and take effect when the owner approves them:

| Severity | Fix or mitigate within |
|---|---|
| Critical (CVSS 9.0 or higher) | 7 days |
| High (7.0 to 8.9) | 30 days |
| Medium (4.0 to 6.9) | 90 days |
| Low | Next planned work, or accepted in the risk register |

6. Critical and high findings from the first test are to be fixed before the planned SOC 2 Type I audit. Each finding is tracked until it is closed.
7. Between tests, the owner must run dependency scans (`pnpm security:deps`), secret scans (`pnpm security:secrets`) and, on staging only, the OWASP ZAP baseline (`pnpm security:zap`, which refuses to run against production).

### 6. Secure development and code review

1. Every change to production must be made through a pull request into `main`. Changes must not be pushed directly.
2. Every pull request must pass these CI checks before merge: type checking, linting, unit tests that run the real database migrations against an in-process Postgres, the USCIS form-fill suites, end-to-end tests in a browser (including the exact security headers on every page), a Trivy scan of dependencies and committed secrets that fails on fixable high or critical findings, and SonarCloud analysis once its token is configured.
3. New tenant tables must follow the tenancy checklist; a schema guard test fails otherwise. The project's written engineering rules are checked by an automated repository test.
4. Database changes must be migrations applied before the new code serves traffic. Destructive migrations need a restore point noted in the pull request.
5. GitHub Actions must be pinned to commit hashes, and Dependabot must propose npm and Actions updates weekly, with security updates handled separately.
6. Preview and staging deployments must never use production data or production secrets.
7. **Review while Delora has one engineer.** A change must be reviewed before merge using three controls together: all required CI checks green; a written self-review checklist completed in the pull request (tenant isolation, authorization, input validation, no personal data in logs or AI prompts, tests added, migration safe); and an AI-assisted review of the diff. The owner reads the full diff before merging. AI-assisted review is an additional check and never replaces the owner's own review. This arrangement is recorded as an approved exception in Vanta.
8. **Two-person review becomes mandatory when a second engineer joins.** From that day, every pull request must be approved by someone other than its author, a code owners file must be added, and the exception in item 7 must be closed.
9. Emergency changes are allowed only to stop an active incident. They still go through a pull request and CI, and review happens within one business day.
10. Branch protection on `main` requires the `lint-and-unit`, `e2e-playwright` and `unit-forms` checks on an up-to-date branch, for admins too, and blocks force pushes. Required pull request review, `security-scan` as a required check and protection of `staging` are open owner steps; see the table below.

## Current implementation

| Control | State |
|---|---|
| Email and password sign-in (12 to 128 characters), email confirmation, 7-day sessions | In place |
| Rate limits on sign-in (20 per IP and 10 per email per 15 minutes), sign-up, reset, two-factor, demo | In place |
| TOTP two-factor with ten backup codes, lockouts, admin reset | In place |
| Firm MFA policy (optional, staff, all) enforced before any firm page | In place; new firms default to `staff` |
| MFA on every company admin console | Not yet; open owner step |
| Single sign-on and passkeys | Not yet; no date committed |
| Append-only `audit_log`, ids only | In place; kept for the life of the firm (proposed: plus one year) |
| Append-only `security_events`, one-year retention, visible to users and firm admins | In place |
| Log drain with one-year retention and alerts on error and failed sign-in spikes | Not yet; planned |
| Uptime monitoring every 3 minutes (home, login, database health) | In place since 2026-10-26 |
| Row-level security forced on every tenant table; composite foreign keys; start-up role check | In place |
| Sealed identifiers (AES-256-GCM), masked display, never sent to AI | In place |
| Security headers: CSP, HSTS (two-year max-age), nosniff, frame denial, referrer and permissions policies, COOP | In place; CSP still allows inline scripts and HSTS lacks `includeSubDomains` and `preload` |
| Vulnerability reporting address and acknowledgement in 2 business days | In place |
| `security.txt` | In place |
| External penetration test | Not yet; planned against staging |
| Fix service levels (7, 30, 90 days) | Proposed; effective on owner approval |
| CI on every pull request and every push to `main` and `staging` | In place |
| SonarCloud analysis | Partial; wired into CI and runs once the token is set |
| Dependabot weekly; SHA-pinned Actions; local dependency, secret and ZAP scans | In place |
| Branch protection: required checks, admins included, no force push | In place on `main` (checked 2026-10-27); required review, `security-scan` and `staging` are open owner steps |
| Required reviewer approval | Not yet; zero approvals while there is one engineer, by design |
| Self-review checklist in the pull request | Proposed; no pull request template exists yet |
| AI-assisted diff review before merge | Proposed as a compensating control; adopted with this policy |
| Two-person review | Takes effect when a second engineer joins |

## Exceptions

An exception to this policy must be requested in writing to the owner, with the risk, the compensating controls and an end date. Approved exceptions are recorded in Vanta and reviewed at least quarterly. The sole-engineer review arrangement in item 6.7 is the one standing exception today.

## Enforcement

Breaking this policy may lead to loss of access and, for employees and contractors, disciplinary action up to termination. A suspected violation is handled as a security incident. The safe harbour in the Responsible disclosure section covers only research that follows the rules stated there.

## Review

The owner reviews this policy at least once a year, and after any major change, security incident or penetration test, and records the review in Vanta. Next review due: 2027-10-26.

## Related documents

- [Information security policy (draft)](../../soc2/policies/information-security.md)
- [Access control policy (draft)](../../soc2/policies/access-control.md)
- [Change management and secure development policy (draft)](../../soc2/policies/change-management.md)
- [Logging and monitoring policy (draft)](../../soc2/policies/logging-monitoring.md)
- [Incident response policy (draft)](../../soc2/policies/incident-response.md)
- [Risk management policy (draft)](../../soc2/policies/risk-management.md)
- [Data security and privacy policy](02-data-security-and-privacy.md)
- [AI governance policy](03-ai-overview-and-governance.md)
- [Trust Center](https://deloralegal.com/trust)
- [Subprocessor list](https://deloralegal.com/subprocessors)
