Skip to content

bug: an MCP URL with an unencodable host escapes mcp_validator as a raw UnicodeError (likely 500) #3909

Closed

Description

@obasilakis

Summary

validate_mcp_config lets a raw UnicodeError escape for an MCP server URL whose host the idna codec refuses (an empty label such as https://a..example.com/mcp, or a label over 63 characters). The credentials route catches only McpValidationError, so the request most likely returns 500 instead of a named 400. It fails closed: nothing is fetched.

Where

  • src/backend/services/mcp_validator.py ~line 307 catches only socket.gaierror around getaddrinfo; CPython's getaddrinfo raises UnicodeError from its own idna encode before any lookup.
  • The vendored mirror docker/base-image/agent_server/mcp_validator.py ~line 307 has the same code (Invariant Setup improvements #5, byte-identical, parity-tested).
  • src/backend/routers/credentials.py ~line 393 catches only McpValidationError.

Same class as #3322, which fixed it in utils/url_validation.py. Found while reviewing #3906.

Acceptance Criteria

  • An unencodable MCP host is refused with an McpValidationError and a 400, in both copies of mcp_validator.py.
  • The two copies stay byte-identical (parity test green).
  • Unit test covers https://a..example.com/mcp and a 64-character label.

Activity

  1. added
    priority-p3
    type-bug
    theme-security
    complexity-low
    on Oct 22, 2026
  2. added a commit that references this issue on Oct 24, 2026
    2fc5f10
  3. added
    status-in-dev
    on Oct 24, 2026
  4. removed
    status-in-dev
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowpriority-p3theme-securitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions