Repository navigation
fix(comm): honour the bind host in Host validation, and let e2e CI fail (#89) - #92
Merged
Merged
Conversation
…il (Apra-Labs#89) The MCP Express app was built with no options, so the SDK assumed a 127.0.0.1 bind and accepted only localhost Host headers. An agent bound to 0.0.0.0 in a container or VM refused every request addressed by hostname or IP with 403 Invalid Host, /health included. - Pass the real bind host to createMcpExpressApp() in the express adapter and the standalone MCP server. - Add optional comm.allowedHosts / MCP_ALLOWED_HOSTS to restrict the accepted Host names on any bind. - CI: run the e2e step with shell: bash so pipefail stops tee from masking a failing suite. - e2e: run the runner with --use-aliases so the agent can reach the webhook receiver at http://e2e:9000. - e2e compose sets MCP_ALLOWED_HOSTS so CI exercises the strict path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #89.
Problem
Three stacked faults, each hiding the next:
comm/express.mjsandmcp/http.mjscalledcreateMcpExpressApp()with no options, so the SDK assumed127.0.0.1and accepted only localhostHostheaders. An agent bound to0.0.0.0(container, VM) refused every request addressed by hostname or IP with403 Invalid Host,/healthincluded.$COMPOSE run --rm e2e | tee e2e-vm.logran withoutpipefail, so the step tooktee's exit code.docker compose rundoes not register thee2eservice alias without--use-aliases.Changes
createMcpExpressApp()in the express adapter and the standalone MCP server. Localhost binds keep the strict localhost check;0.0.0.0binds rely on the authenticator, as the SDK intends.comm.allowedHosts(orMCP_ALLOWED_HOSTS=a,b): when set, only the listed hostnames are accepted on any bind. Config wins over env; a malformed value fails at startup. Helper incomm/allowed-hosts.mjs.shell: bash(-eo pipefail).run --rm --use-aliases e2ein CI,e2e:vm,e2e:durableand the compose header.docker-compose.e2e.ymlsetsMCP_ALLOWED_HOSTS: "agent-vm,localhost"so CI exercises the strict path.docs/mcp-interface.md;comm.host/comm.allowedHostsrows indocs/getting-started.md.Testing
comm-express,host-config,mcp), written first; 8 failed before the fix, all pass now.tests/*.test.mjsrun: no new failures versusmain. The remaining failures are pre-existing on Windows (exec bit, symlinks, packaging, live Fleet); one TTL pool test flaked under full-suite load and passes 5/5 on its own.npm run smoke: 10 pass, 1 skipped.agent-vm), previously 0/10:E2E_RESTART_CMD)Totals: 10 pass, 0 fail, 1 skipped.
Host: agent-vm→ 200,Host: localhost→ 200,Host: evil.example→ 403Invalid Host.Known, not fixed here
npm run e2e:vm/e2e:durabledon't run on Windows: npm usescmd.exe, where;is not a command separator. This was already the case before this change; it works on Linux/CI, andnpm run verify(Wave 0) will replace these scripts.