Skip to content

fix: mcp auth TLS gate falls back to entry.url when caller omits url - #3797

Open
dylanyunlon wants to merge 1 commit into
microsoft:mainfrom
dylanyunlon:fix/mcp-auth-tls-entry-url-fallback
Open

fix: mcp auth TLS gate falls back to entry.url when caller omits url#3797
dylanyunlon wants to merge 1 commit into
microsoft:mainfrom
dylanyunlon:fix/mcp-auth-tls-entry-url-fallback

Conversation

@dylanyunlon

@dylanyunlon dylanyunlon commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Fixes #3785 — the require_tls gate in McpAuthPolicy.check() never consulted the configured entry.url when the caller-supplied url was empty (or omitted). A caller that simply omits url could bypass the TLS requirement even when the server entry had require_tls: true and a configured non-TLS entry.url.

Changes

Core fix (mcp_auth_enforcement.py)

The TLS gate now resolves an effective URL via url or entry.url before evaluating the scheme. When both sources are empty, the gate permits the connection — preserving spec S10.12 compatibility (add_server() with default url="" must remain allowed).

Before:

if entry.require_tls and url:  # caller omits url → skipped entirely

After:

if entry.require_tls:
    effective_url = url or entry.url
    if effective_url:  # only skip when truly no URL exists

Tests (test_mcp_auth_enforcement.py)

12 new tests in TestTlsGateEntryUrlFallback covering:

  • http/https/wss/ws/ftp entry.url fallback when caller omits url
  • Caller-supplied url overrides entry.url (both directions)
  • Both-urls-empty S10.12 compatibility
  • require_tls=False bypass
  • No-scheme entry.url rejection
  • Explicit empty string treated as absent
  • YAML end-to-end integration

All 29 tests pass (17 existing + 12 new).

Documentation (docs/mcp-auth-tls.md)

New doc covering URL resolution order, configuration examples (Python + YAML), allowed TLS schemes, and security considerations.

README

Added doc link under the Reference section.

Checklist

  • Follows conventional commit format
  • All existing tests pass (17/17)
  • New regression tests added (12 tests)
  • Documentation added
  • cspell clean (no new words needed)
  • Signed-off-by on all commits

Signed-off-by: dylanyunlon dogechat@163.com

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

Copy link
Copy Markdown

Welcome to the Agent Governance Toolkit! Thanks for your first pull request.
Please ensure tests pass, code follows style (ruff check), and you have signed the CLA.
See our Contributing Guide.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests size/L Large PR (< 500 lines) labels Aug 21, 2026
@github-actions

Copy link
Copy Markdown

🟡 Contributor Check: MEDIUM

Check Result
Profile MEDIUM
Credential LOW
Overall MEDIUM

Automated check by AGT Contributor Check.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor check flagged MEDIUM risk label Aug 21, 2026
…icrosoft#3785)

* fix: consult entry.url in TLS gate when caller-supplied url is empty

The require_tls gate in McpAuthPolicy.check() previously only evaluated
the caller-supplied url argument. When a caller omitted url (or passed
""), the TLS check was silently skipped even when the server entry had
require_tls=True and a configured non-TLS entry.url — a denial-of-
service vector in multi-tenant setups where the caller is untrusted.

The fix resolves an effective_url via: caller url > entry.url > empty.
When both sources are empty the gate permits the connection, preserving
spec S10.12 compatibility (add_server with default url="" must remain
allowed).

Signed-off-by: dylanyunlon <dogechat@163.com>

* test: add 12 tests for TLS gate entry.url fallback

Cover: http/https/wss/ws/ftp entry.url fallback, caller overrides,
both-empty S10.12 compat, require_tls=False bypass, no-scheme entry.url,
explicit empty string, and YAML end-to-end.

Signed-off-by: dylanyunlon <dogechat@163.com>

* docs: add MCP auth TLS gate documentation

Document URL resolution order, configuration examples, YAML config,
allowed TLS schemes, and security considerations for the entry.url
fallback behavior.

Signed-off-by: dylanyunlon <dogechat@163.com>

---------

Signed-off-by: dylanyunlon <dogechat@163.com>
@dylanyunlon
dylanyunlon force-pushed the fix/mcp-auth-tls-entry-url-fallback branch from 77da419 to d4297ad Compare August 21, 2026 03:37
@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@dylanyunlon dylanyunlon changed the title fix: MCP auth TLS gate falls back to entry.url when caller omits url fix: mcp auth TLS gate falls back to entry.url when caller omits url Aug 21, 2026
@dylanyunlon

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

documentation Improvements or additions to documentation needs-review:MEDIUM Contributor check flagged MEDIUM risk size/L Large PR (< 500 lines) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP auth: require_tls gate never consults the configured entry.url

1 participant