Skip to content

fix(security): restrict tokenless dev mode to loopback#408

Closed
danyalahmed1995 wants to merge 1 commit into
agentrust-io:mainfrom
danyalahmed1995:fix/406-tokenless-dev-loopback
Closed

fix(security): restrict tokenless dev mode to loopback#408
danyalahmed1995 wants to merge 1 commit into
agentrust-io:mainfrom
danyalahmed1995:fix/406-tokenless-dev-loopback

Conversation

@danyalahmed1995

Copy link
Copy Markdown
Member

What

Restrict tokenless development mode to loopback interfaces by default.

When CMCP_DEV_MODE=1 and CMCP_BEARER_TOKEN is unset, the runtime now defaults to 127.0.0.1:8443 and rejects wildcard or non-loopback bind addresses. Authenticated deployments may continue using non-loopback addresses.

Why

Closes #406.

Tokenless development mode previously inherited the default 0.0.0.0:8443 bind, which could unintentionally expose the unauthenticated development gateway to LAN, container, or cloud networks.

This is configuration hardening for development mode, not a production authentication bypass.

Security impact

Reduces the network exposure of tokenless development deployments.

The change:

  • allows tokenless binds only on explicit loopback hosts such as 127.0.0.1, localhost, and ::1;
  • rejects wildcard, LAN, public, and non-loopback hostname binds without a bearer token;
  • preserves non-loopback binds when CMCP_BEARER_TOKEN is configured;
  • does not modify authentication middleware, TEE boundaries, signing, audit-chain integrity, capability tokens, or trust-score inputs.

The CLI now also uses the shared validated listen-address parser, including bracketed and unbracketed IPv6 handling.

Test plan

  • pytest passes
  • ruff check passes
  • mypy passes
  • Manual test performed (describe steps below if applicable)

Validation completed:

  • Focused configuration and startup tests: 49 passed
  • Full test suite: 877 passed, 5 skipped
  • Ruff passes for all Python files changed by this PR
  • python -m compileall -q src tests passes

Repository-wide ruff check . reports pre-existing findings in unrelated scripts and experiments. Repository-wide mypy reports four pre-existing cryptography typing errors in src/cmcp_verify/tdx.py and src/cmcp_verify/sev_snp.py; neither file is modified by this PR.

DCO sign-off

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🔴 Contributor Check: HIGH

Check Result
Profile HIGH
Credential NONE
Overall HIGH

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:HIGH Contributor check flagged HIGH risk label Jul 21, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cmcp_runtime/config.py 78.37% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@imran-siddique

Copy link
Copy Markdown
Contributor

Thanks @danyalahmed1995 — merged as bc8b624 on main (via #418), with your authorship preserved. I rebased it onto current main to resolve a conflict in docs/quickstart.md (rewritten in #417); the code, docs, and your tests are unchanged and the full suite is green. Appreciate the hardening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:HIGH Contributor check flagged HIGH risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security] Restrict tokenless dev mode to loopback by default

3 participants