Skip to main content

Security Architecture

This page describes controls present in the review release and the limitations that remain. It is an implementation summary, not a certification of OWASP compliance or a penetration-test report.

System boundaries​

The React frontend runs on Cloudflare Workers. API traffic passes through the Cloudflare proxy to Caddy on one EC2 host. FastAPI and PostgreSQL run as containers on that host.

Figure 1. Current request and data boundaries. Cloudflare's Full TLS mode encrypts the origin connection without validating the origin certificate.

The security group admits port 443 only from Cloudflare's configured IPv4 ranges; operators use SSM rather than SSH. PostgreSQL publishes no host port. The API and database share a Compose network: this internal connection is not an RDS private-subnet or managed-database control. See Deployment Architecture for the deployment and recovery limits.

Authentication strategy​

The API uses bcrypt password hashing (cost 12) and HS256 JWTs. Access tokens expire after 15 minutes by default. Refresh tokens rotate on use; revoked-token hashes and account lockouts are persisted in PostgreSQL.

ControlImplemented behavior
Self-registrationCreates an unverified Admin and a new workspace; no session is issued until verification.
Account privacyAn existing verified email receives the same registration response shape as a new email; password-reset requests also use a generic response.
VerificationSix-character alphanumeric code, stored hashed; five-minute self-registration expiry and 24-hour member-invitation expiry.
Password resetHashed, single-use code with a 30-minute expiry; password reset increments the user's token version to invalidate existing refresh tokens.
Login failuresFive failed attempts in the configured window trigger account lockout; repeated failures can increase its duration.
SessionsRefresh lifetime slides from the last refresh: 24 hours normally, seven days with rememberMe.
Password policyThe API requires at least eight characters, a letter, and a digit; the web password-setting form asks for a stricter combination.

Browser sessions​

The web app opts into cookie mode with X-Session-Mode: cookie and a trusted Origin. Login and refresh return the access token in JSON and the refresh token only in the oph_refresh_token cookie. The web app holds the access token in application memory.

The production refresh cookie is HttpOnly; Secure; SameSite=Lax; Path=/v1/auth. Cookie-mode refresh rejects body credentials and untrusted origins. Non-browser clients use the body-token contract instead; see the API Contract.

Logout revokes the refresh credential and clears the browser cookie. A previously issued access token can remain usable until its short expiry; refresh revocation does not retrospectively remove that token.

Authorization model​

The API resolves the caller's user, role, and workspace from verified token claims. The workspace is never chosen by an untrusted request field.

ActorAccess
AdminWorkspace client/project/story operations, refinement, personal API keys, and team/workspace administration.
MemberWorkspace client/project/story operations, refinement, and personal API keys.
Anonymous clientOne project's approved stories and phase, using its project access code.

Protected routes use authentication and role dependencies; tenant-scoped repository operations receive the caller's workspace. Requests for another workspace's records return 404. These are application controls: PostgreSQL Row-Level Security is not enabled.

Public Client Review route​

GET /v1/viewer/{accessCode} exposes approved stories for one project without requiring an account. Its credential is PRJ- plus eight characters from a 32-symbol alphabet, generated securely and unique across the instance.

Unknown and malformed codes return the same 404. An Admin or Member can regenerate a code, revoking the previous link. The route has a 30-requests-per-minute IP limit; the in-memory limiter is not shared across workers.

Anyone holding the code can view the project. Codes do not expire automatically, identify individual readers, or support revocation for one stakeholder. Sharing a code therefore shares access to the approved backlog.

Data protection and secrets​

  • Passwords and one-time codes are stored as bcrypt hashes; revoked refresh tokens are represented by hashes.
  • User-owned AI keys are encrypted with AES-256-GCM. The owning user ID is associated data; API responses expose a mask, never the plaintext key.
  • Runtime secrets are stored in SSM Parameter Store and loaded during deployment. They include database credentials, the JWT secret, and the API-key encryption key.
  • Database data resides on the host's encrypted EBS volume. There are no automated database backups in this review deployment.
  • Markdown exports are generated in memory; there is no application file-storage bucket or stored export history.
  • Browser/API traffic uses HTTPS. The origin-certificate validation limitation is shown in Figure 1.

Changing the master API-key encryption key without a data-migration procedure makes existing stored keys unreadable. A key_version field exists, but an operational rotation procedure is not established; see ADR-018.

AI refinement controls​

Discovery notes are sent to the selected external provider. The platform-credit path uses Gemini; users can select Gemini, OpenAI, or DeepSeek with their own saved key. The selected provider is a validated API field, not an instruction embedded in the notes.

Figure 2. Implemented refinement controls. Drafts remain outside the database until explicit approval.

Sanitization neutralizes known instruction-override phrases and strips markup and prompt-boundary markers. It does not reject every matching input: a sufficiently long sanitized note still reaches the provider, and the response reports redactionCount.

The prompt instructs the model to treat the delimited notes as data. Provider adapters request and parse structured output. Approval validates the submitted story content and project workspace before persistence. These controls reduce exposure; they do not prove resistance to every prompt-injection technique.

Dedicated OpenAI Moderation calls, configured cross-provider harm thresholds, toxicity checks, and system-prompt-leak detection are not implemented controls in this release. Human approval remains necessary before drafts become shared backlog content.

API and operational controls​

The API applies typed request validation, parameterized ORM queries, configured CORS, security headers, and request identifiers. Authentication, code issuance, API-key validation, and public review have additional throttling controls. The global IP limiter defaults to 100 requests per minute; it is process-local, while account and key-validation counters are persisted.

Application logs are structured JSON in the container. Backend Sentry is active in production and scrubs request URLs and headers before sending. There are no deployed alarms, distributed rate-limit service, or continuously staffed incident-response process documented for this release.

The repositories contain authentication, route-policy, workspace-isolation, and sanitizer tests. Their presence establishes available verification coverage, not a current passing result or independent security assessment. Refer to the repository CI results and a recorded test run when evaluating release readiness.

Known limitations​

LimitationReview implication
One API/database host; no failover or database backupsHost or volume loss can cause downtime and permanent data loss.
Cloudflare Full TLS modeThe origin connection is encrypted, but the origin certificate is not validated.
Application workspace isolation; no RLSCorrect route and repository scoping remains essential.
Process-local IP throttlingLimits reset on restart and do not coordinate across workers.
Short-lived bearer access tokensLogout or password reset prevents future refreshes; an issued access token can survive until expiry.
Shared project access codesA leaked code reveals the approved backlog until regenerated.
External AI processingSubmitted notes leave the application boundary; provider availability and policies affect the workflow.
No independent security/compliance assessment recordedOWASP alignment is a design objective, not a certification.

MFA, social login, backup automation, stronger origin verification, and additional AI-output safeguards remain future work rather than release capabilities.

References​

Last Updated: 2026-10-19