MicroFish/backend
Yo-LRK 8cb92768ae security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline)
Closes the four CRITICAL findings from the 2026-06-13 review.

C1 — Werkzeug debug RCE / dev server in prod:
  - FLASK_DEBUG defaults False (kills interactive-debugger network RCE)
  - production runs gunicorn (-w 1 --threads 8) via `npm run start`; Dockerfile
    builds the frontend and serves it with `vite preview` (host 0.0.0.0); gunicorn
    + uv.lock updated
  - Config.validate() now runs inside create_app() so the gunicorn path enforces
    SECRET_KEY (prod) / API_KEY / LLM / ZEP at boot

C2 — zero auth on all /api/* routes:
  - before_request API-key guard (X-API-Key / Bearer), constant-time bytes compare,
    /health + OPTIONS exempt
  - AUTH_ENABLED fail-closed parse (only explicit false/0/no/off disables)
  - frontend axios injects X-API-Key from build-time VITE_API_KEY, wired through
    docker compose build-arg -> Dockerfile ARG -> vite build (+ frontend/.env.example)

C3 — denial-of-wallet (no cost ceiling; OASIS_DEFAULT_MAX_ROUNDS was dead config):
  - OASIS_DEFAULT_MAX_ROUNDS now applied when max_rounds omitted (default 150, covers
    the 144-round demo); hard ceilings OASIS_MAX_ROUNDS_CAP / OASIS_MAX_AGENTS_CAP;
    runner always forwards the clamped rounds to the subprocess

C4 — no simulation deadline; env.step could wedge forever:
  - every env.step (initial / round-loop / interview) wrapped in asyncio.wait_for
    (OASIS_ROUND_TIMEOUT_SEC) across all 3 run scripts; per-loop total-deadline
    (OASIS_RUN_TIMEOUT_SEC); gather(return_exceptions=True) + single-platform
    try/except so one platform's failure can't skip env.close

New env vars documented in .env.example + README security section.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 17:19:05 +07:00
..
app security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline) 2026-06-13 17:19:05 +07:00
scripts security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline) 2026-06-13 17:19:05 +07:00
pyproject.toml security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline) 2026-06-13 17:19:05 +07:00
requirements.txt security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline) 2026-06-13 17:19:05 +07:00
run.py Add UTF-8 encoding support for Windows console in run.py and logger.py to prevent character encoding issues 2025-12-26 17:58:48 +08:00
uv.lock security: harden C1-C4 (debug-RCE, auth, denial-of-wallet, sim deadline) 2026-06-13 17:19:05 +07:00