Skip to content

fix: reject malformed mcp header templates#482

Open
HwangJohn wants to merge 1 commit into
langchain-ai:mainfrom
HwangJohn:fix/mcp-header-template-validation
Open

fix: reject malformed mcp header templates#482
HwangJohn wants to merge 1 commit into
langchain-ai:mainfrom
HwangJohn:fix/mcp-header-template-validation

Conversation

@HwangJohn

Copy link
Copy Markdown
Contributor

Summary

  • parse MCP HTTP header values containing ${...} as env templates
  • reject malformed, invalid, missing, or unresolved template fragments instead of sending them literally
  • keep valid env-backed header values and literal secret rejection behavior working

Why

MCP connector headers are allowed to reference credentials through env templates. Malformed templates like Bearer ${TOKEN should fail closed rather than being passed through as literal header values.

No dedicated issue; found during MCP connector hardening.

Testing

  • corepack pnpm exec vitest run test/mcp-client.test.ts passed
  • corepack pnpm run format:check passed
  • corepack pnpm run lint:check passed
  • corepack pnpm run typecheck passed
  • git diff --check passed
  • corepack pnpm test was attempted on Windows and still fails outside this change in existing test/env-behavior.test.ts HOME/permission assertions plus timeout-prone Mermaid/jsdom tests

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.

1 participant