6.5 KiB
6.5 KiB
Security Production Readiness Report
Date: 2026-03-01 Repository: /Users/bedas/Developer/GitHub/dcm Review type: Static code and configuration review (no runtime penetration testing)
Scope
- Backend API and worker:
backend/app - Frontend API client/auth transport:
frontend/src - Compose and environment defaults:
docker-compose.yml,.env
Method and Limits
- Reviewed source and configuration files in the current checkout.
- Verified findings with direct file evidence.
- Did not run dynamic security testing, dependency CVE scanning, or infrastructure perimeter testing.
Confirmed Product Security Findings
Critical
- Browser-exposed shared bearer token path (
VITE_API_TOKENfallback)
- Severity: Critical
- Why this is a product issue: The frontend code supports a build-time token fallback and injects it into all API requests. This creates a shared credential model in browser code.
- Impact: Any user with browser access can recover and reuse the token, collapsing auth boundaries and auditability.
- Exploit path: Open app -> inspect runtime/bundle or intercepted request -> replay bearer token against protected API endpoints.
- Evidence:
frontend/src/lib/api.ts:39frontend/src/lib/api.ts:98frontend/src/lib/api.ts:111frontend/src/lib/api.ts:155docker-compose.yml:123backend/app/api/router.py:25backend/app/api/router.py:37
- Production recommendation:
- Remove browser-side static token fallback.
- Use per-user server-issued auth (session or short-lived JWT) with role-bound authorization.
High
- CORS policy is effectively any HTTP/HTTPS origin, with credentials enabled
- Severity: High
- Why this is a product issue: CORS middleware enables
allow_origin_regexthat matches broad web origins and setsallow_credentials=True. - Impact: If credentials are present, cross-origin access risk increases and token abuse becomes easier from arbitrary origins.
- Exploit path: Malicious origin performs cross-origin requests with available credentials and can read API responses under permissive CORS policy.
- Evidence:
backend/app/main.py:21backend/app/main.py:41backend/app/main.py:42backend/app/main.py:44
- Production recommendation:
- Replace regex-based broad origin acceptance with explicit trusted origin allowlist.
- Keep
allow_credentials=Falseunless strictly required for cookie-based flows.
Medium
- Sensitive processing content is persisted in logs by default
- Severity: Medium
- Why this is a product issue: Pipeline logging records OCR text, extraction text, prompts, and LLM outputs into persistent processing logs.
- Impact: Increased confidentiality risk and larger data-retention blast radius if logs are queried or exfiltrated.
- Exploit path: Access to admin log endpoints or database allows retrieval of sensitive operational content.
- Evidence:
backend/app/worker/tasks.py:619backend/app/worker/tasks.py:638backend/app/services/routing_pipeline.py:789backend/app/services/routing_pipeline.py:802backend/app/services/routing_pipeline.py:814backend/app/core/config.py:45
- Production recommendation:
- Default to metadata-only logs.
- Disable persistent storage of prompt/response/raw extracted text unless temporary debug mode is explicitly enabled with strict TTL.
- Markdown export endpoint is unbounded and memory-amplifiable
- Severity: Medium
- Why this is a product issue: Export loads all matching documents and builds ZIP in-memory with
BytesIO, without hard limits on selection size. - Impact: Authenticated users can trigger high memory use and service degradation.
- Exploit path: Repeated wide
path_prefixexports cause large in-memory archive construction. - Evidence:
backend/app/api/routes_documents.py:402backend/app/api/routes_documents.py:412backend/app/api/routes_documents.py:416backend/app/api/routes_documents.py:418backend/app/api/routes_documents.py:421backend/app/api/routes_documents.py:425
- Production recommendation:
- Enforce max export document count and total bytes.
- Stream archive generation to temp files.
- Add endpoint rate limiting.
Risks Requiring Product Decision or Further Verification
- Authorization model appears role-based without per-document ownership boundaries
- Evidence:
backend/app/models/document.py:29backend/app/api/router.py:19backend/app/api/router.py:31
- Question: Is this intentionally single-operator, or should production support multi-user/tenant data isolation?
- Worker startup command uses raw Redis URL string and bypasses in-code URL security validator at startup
- Evidence:
docker-compose.yml:81backend/app/worker/queue.py:15
- Question: Should worker startup also enforce
validate_redis_url_securitybefore consuming jobs?
- Provider key encryption uses custom cryptographic construction
- Evidence:
backend/app/services/app_settings.py:131backend/app/services/app_settings.py:154backend/app/services/app_settings.py:176
- Question: Are compliance or internal policy requirements demanding standardized AEAD primitives from vetted cryptography libraries?
User-Managed Configuration Observations (Not Product Defects)
These are deployment/operator choices and should be tracked separately from code defects.
- Development-mode posture in local
.env
- Evidence:
.env:1.env:3
- Notes:
APP_ENV=developmentand anonymous development access are enabled.
- Local
.envincludes placeholder shared API token values
- Evidence:
.env:15.env:16.env:31
- Notes: If replaced with real values and reused, this increases operational risk. This is operator responsibility.
- Compose defaults allow permissive provider egress controls
- Evidence:
docker-compose.yml:51docker-compose.yml:52.env:21.env:22.env:23
- Notes: Allowing HTTP/private-network provider targets is a deployment policy choice.
- Internal service transport defaults are plaintext in local stack
- Evidence:
docker-compose.yml:56.env:11
- Notes:
http/redis://may be acceptable for isolated local dev, but not for exposed production networks.
Production Readiness Priority Order
- Remove browser static token model and adopt per-user auth.
- Tighten CORS to explicit trusted origins only.
- Reduce persistent sensitive logging to metadata by default.
- Add hard limits and streaming behavior for markdown export.
- Resolve product decisions on tenant isolation, worker Redis security enforcement, and cryptography standardization.