OpenTerminalUI is a financial trading and market data platform. This document describes the security architecture, threat model, and reporting procedures.
| Category | Description | Mitigation |
|---|---|---|
| Spoofing | Unauthorized actors impersonating users or services | JWT-based auth with short TTLs, token rotation, dev-bypass restricted to dev environments |
| Tampering | Modification of data in transit or at rest | HMAC-signed cache blobs, CSRF double-submit cookies, parameter validation |
| Repudiation | Users denying actions taken | Audit logging for all OMS orders, restricted list changes, and system events |
| Information Disclosure | Exposure of sensitive data (API keys, tokens, PII) | Ephemeral dev secrets, env-var based secret management, no secrets in code |
| Denial of Service | Service degradation via resource exhaustion | Rate limiting with exponential backoff, circuit breakers on external providers, request timeouts |
| Elevation of Privilege | Unauthorized privilege escalation | Role-based access control (Viewer/Trader/Admin), token type validation, auth exempt allowlist |
Client Browser/App
│
▼
┌─────────────────────────────────────────┐
│ API Layer (FastAPI) │
│ ├─ AuthMiddleware - JWT validation │
│ ├─ CsrfProtectMiddleware - CSRF token │
│ └─ Rate limiting (shared/rate_limiter) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Business Logic │
│ ├─ OMS - Pre-trade checks, kill switch│
│ ├─ Alerts - Expression sandbox │
│ ├─ Screener - AST-based formula eval │
│ └─ Strategy - Code execution sandbox │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ External Providers │
│ ├─ Alpaca (market data, trading) │
│ ├─ Yahoo Finance (historical data) │
│ └─ FMP / other providers │
│ Circuit breaker pattern on all calls │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Data Storage │
│ ├─ PostgreSQL (primary) │
│ ├─ Redis (L2 cache, optional) │
│ └─ SQLite (L3 cache fallback) │
└─────────────────────────────────────────┘
- Authentication: JWT (HS256) with short-lived access tokens (15 min default) and refresh tokens (1 day default).
- Authorization: Role-based access with three tiers:
Viewer(rank 1): Read-only accessTrader(rank 2): Trading and order managementAdmin(rank 3): Full system access
- Dev Bypass: Development environments with
OPENTERMINALUI_ENVset to dev values andE2E_DEV_AUTH=1allow a persisteddev-user. This is strictly disabled in production. - Auth Exempt Paths: Explicit allowlist of public endpoints (
/health,/docs, auth routes). No blanket prefix exemptions.
- Implemented via
shared/rate_limiter.pyusing exponential backoff with jitter. - Applied to external API calls (Alpaca, Yahoo, FMP) to prevent throttling.
- Rate limit scheduler resets on success; intervals double on rate-limit response up to a configurable maximum.
- API keys (Alpaca, FMP, etc.) are stored exclusively in environment variables.
- No hardcoded secrets in source code.
- Development ephemeral secrets are automatically generated and cannot leak to production.
- Redis cache values are HMAC-sha256 signed before serialization.
- Alert Expressions: Custom alert expressions use a restricted
eval()with only whitelisted field names and comparison operators. No function calls or attribute access. - Strategy Runner: Code execution is sandboxed with timeout, dunder attribute traversal blocked, and
__globals__/__class__access denied. - Formula Engine: AST-based validation before evaluation. Only arithmetic operations and allowed fields are permitted. No
import,eval(), orexec()calls.
- Double-submit cookie pattern for all state-changing endpoints.
- Exempt paths explicitly listed (health, docs, auth routes, WebSocket endpoints).
- Tokens use
secrets.compare_digest()for constant-time comparison. - Token rotation on every response.
- HMAC-verified pickle blobs prevent deserialization of tampered data.
- Redis is optional; graceful fallback to in-memory + SQLite.
- Cache key signing prevents cache poisoning attacks.
- Kill switch prevents all order submission.
- Restricted symbol list blocks trading on compliance-blocked securities.
- Position notional limits (default: 5M) prevent oversized orders.
- ADV participation limits (default: 10%) prevent market impact.
- All orders and fills are audit-logged.
We take security vulnerabilities seriously. If you discover a security issue, please follow these steps:
- Do NOT create a public GitHub issue.
- Email security@openterminalui.com with:
- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if any)
- We will acknowledge receipt within 48 hours and provide a timeline for remediation.
- Please allow at least 90 days for a fix before public disclosure.
- Include proof-of-concept attachments if helpful (videos, code).
- We will not take legal action against researchers following this process.
- All API responses include standard security headers via FastAPI middleware configuration.
- HTTPS is enforced in production environments.
SameSite=strictandHttpOnlyon CSRF cookies.