Security: Replace default hardcoded API key #1

Closed
opened 2026-03-10 03:45:22 +00:00 by Mark · 2 comments
Owner

Issue

The application uses a hardcoded default API key (devforge-dev-key) which is a significant security vulnerability.

Location

  • services/api/app/config.py:94
  • services/api/app/auth.py:7,17
  • docker-compose.yml:37
  • Multiple test files

Risk

  • Anyone with knowledge of the default can access the API
  • No enforcement of custom key generation
  • Documented in README as the default

Proposed Solution

  1. Generate a secure random key on first startup if not provided
  2. Log a prominent warning if default/weak key is detected
  3. Add startup validation that rejects obviously weak keys
  4. Update documentation to emphasize changing the default

Acceptance Criteria

  • Random key generation on first run
  • Validation to reject common weak keys
  • Warning logs for insecure configurations
  • Documentation updated

Priority: High
Type: Security

## Issue The application uses a hardcoded default API key (`devforge-dev-key`) which is a significant security vulnerability. ## Location - `services/api/app/config.py:94` - `services/api/app/auth.py:7,17` - `docker-compose.yml:37` - Multiple test files ## Risk - Anyone with knowledge of the default can access the API - No enforcement of custom key generation - Documented in README as the default ## Proposed Solution 1. Generate a secure random key on first startup if not provided 2. Log a prominent warning if default/weak key is detected 3. Add startup validation that rejects obviously weak keys 4. Update documentation to emphasize changing the default ## Acceptance Criteria - [ ] Random key generation on first run - [ ] Validation to reject common weak keys - [ ] Warning logs for insecure configurations - [ ] Documentation updated **Priority:** High **Type:** Security
Author
Owner

GSD VERIFY phase failed after 3 attempts.
═══ Gate: verify-passed (devforge#1) ═══
Mode: Tier 1 (functional only)

GATE OK: All gates up to 'implement' pass
── Tier 1: Functional ────────────────────────────────
Running tests...
❌ Tests failed (exit 1)
 FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > decodeTerminalMessage > should return empty Uint8Array for Blob input in sync decoder
 FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should return false when debug is not enabled
 FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should return true when debug is enabled
 FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should disable debug mode
ReferenceError: localStorage is not defined
 ❯ services/web/src/utils/terminalUtils.test.ts:12:5
 10|  beforeEach(() => {
 11|  vi.restoreAllMocks();
 12|  localStorage.clear();
 |  ^
 13|  });
 14| 

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/9]⎯

 Test Files  4 failed | 1 passed (5)
 Tests  6 failed | 4 passed (10)
 Start at  02:54:09
 Duration  642ms (transform 481ms, setup 0ms, import 129ms, tests 9ms, environment 1ms)
Running linter...
✅ Lint clean
⚠️ No type checker discovered
Previous test count: unknown

❌ GATE FAIL: verify-passed
- Tests failed with exit code 1
GATE FAIL: verify — blocked at 2026-05-21T09:54:11Z
Class: test-failure
Evidence: Verification failed: 1 failures
Git tag: devforge#1-gate-verify-fail-0d2f3edcf9f7 (use gate-retry after fixing)

GSD VERIFY phase failed after 3 attempts. ═══ Gate: verify-passed (devforge#1) ═══ Mode: Tier 1 (functional only) GATE OK: All gates up to 'implement' pass ── Tier 1: Functional ──────────────────────────────── Running tests... ❌ Tests failed (exit 1)  FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > decodeTerminalMessage > should return empty Uint8Array for Blob input in sync decoder  FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should return false when debug is not enabled  FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should return true when debug is enabled  FAIL  services/web/src/utils/terminalUtils.test.ts > terminalUtils > debug mode > should disable debug mode ReferenceError: localStorage is not defined  ❯ services/web/src/utils/terminalUtils.test.ts:12:5  10|  beforeEach(() => {  11|  vi.restoreAllMocks();  12|  localStorage.clear();  |  ^  13|  });  14|  ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/9]⎯  Test Files  4 failed | 1 passed (5)  Tests  6 failed | 4 passed (10)  Start at  02:54:09  Duration  642ms (transform 481ms, setup 0ms, import 129ms, tests 9ms, environment 1ms) Running linter... ✅ Lint clean ⚠️ No type checker discovered Previous test count: unknown ❌ GATE FAIL: verify-passed - Tests failed with exit code 1 GATE FAIL: verify — blocked at 2026-05-21T09:54:11Z Class: test-failure Evidence: Verification failed: 1 failures Git tag: devforge#1-gate-verify-fail-0d2f3edcf9f7 (use gate-retry after fixing)
Mark closed this issue 2026-05-30 15:55:05 +00:00
Author
Owner

Fixed: Removed all default fallback values for DEVFORGE_API_KEY. Now fails closed — if the env var is not set, all API requests are rejected with 401.

Changes:

  • auth.py: os.environ.get("DEVFORGE_API_KEY", "devforge-dev-key") → os.environ.get("DEVFORGE_API_KEY") with not expected check
  • main.py: Same treatment in websocket_terminal, ws_echo, _ws_auth_ok
  • orchestrator.py: Same, plus loud startup warning
  • docker-compose.yml: Removed both :-devforge-dev-key defaults
  • AGENTS.md, README.md: Updated docs
  • Test files unchanged (they explicitly set test key)
Fixed: Removed all default fallback values for `DEVFORGE_API_KEY`. Now fails closed — if the env var is not set, all API requests are rejected with 401. Changes: - `auth.py`: `os.environ.get("DEVFORGE_API_KEY", "devforge-dev-key")` → `os.environ.get("DEVFORGE_API_KEY")` with `not expected` check - `main.py`: Same treatment in websocket_terminal, ws_echo, _ws_auth_ok - `orchestrator.py`: Same, plus loud startup warning - `docker-compose.yml`: Removed both `:-devforge-dev-key` defaults - `AGENTS.md`, `README.md`: Updated docs - Test files unchanged (they explicitly set test key)
Sign in to join this conversation.
No description provided.