Skip to content

fix(security): freeze CMCP_DEV_MODE at process startup (TEE-002) - #256

Merged
imran-siddique merged 2 commits into
mainfrom
fix/tee-002-dev-mode-immutable
Jun 8, 2026
Merged

imran-siddique merged 2 commits into
mainfrom
fix/tee-002-dev-mode-immutable

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Summary

  • Adds DEV_MODE: bool module-level constant to cmcp_gateway/config.py that reads CMCP_DEV_MODE exactly once at import time
  • Replaces the runtime os.environ.get("CMCP_DEV_MODE") call in load_config() with the frozen constant — no code path re-reads the env var after startup
  • Adds tests/unit/test_tee_dev_mode_freeze.py with 6 tests: constant is True/False/False for env 1/absent/0, and two immutability tests proving that mutating os.environ after import cannot change DEV_MODE
  • Updates complete_setup fixture in test_startup.py to patch the frozen constant directly (monkeypatch.setattr) rather than only setting the env var

Test plan

  • pytest tests/unit/test_tee_dev_mode_freeze.py — 6/6 pass
  • pytest tests/unit/test_startup.py tests/unit/test_tee.py — all pass
  • No remaining os.environ.get("CMCP_DEV_MODE") calls outside the one freeze line

Closes #141

🤖 Generated with Claude Code

imran-siddique and others added 2 commits June 8, 2026 08:31
…testation upgrade (AUTH-001)

Closes #163.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… at runtime (TEE-002)

Add module-level DEV_MODE constant in cmcp_gateway.config that reads
CMCP_DEV_MODE exactly once at import time. Replace the runtime
os.environ.get call in load_config() with this constant. Add tests
asserting the constant is immutable after import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imran-siddique
imran-siddique merged commit 6bbb3f3 into main Jun 8, 2026
1 of 8 checks passed
@imran-siddique
imran-siddique deleted the fix/tee-002-dev-mode-immutable branch July 29, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRITICAL: CMCP_DEV_MODE env var can be set in container to downgrade hardware attestation to software-only (TEE-002)

1 participant