Skip to content

fix(proxy): keep TLS verification for .dev hosts — a public TLD, not local development - #114

Merged
BenKalsky merged 2 commits into
mainfrom
fix/mcp-proxy-dev-tld
Oct 26, 2026
Merged

BenKalsky merged 2 commits into
mainfrom
fix/mcp-proxy-dev-tld

Conversation

@BenKalsky

Copy link
Copy Markdown
Member

Fixes the two high CodeQL alerts js/disabling-certificate-validation in bin/mcp-proxy.mjs (lines 119 and 154).

The problem

The stdio proxy sets rejectUnauthorized = false for local development hosts, so that a self-signed certificate works. Over that connection it sends a WordPress Application Password.

The local-host list included .dev. That is a delegated public TLD (Google, HSTS-preloaded), so a real site at example.dev got a connection with no certificate check, and the credential was open to a man in the middle. The proxy ships in the plugin zip as the connector an operator runs.

Fix

  • The host check moves to bin/local-dev-host.mjs (isLocalDevHost). It keeps only names that cannot be a public site: loopback, .test, .localhost, .invalid (RFC 2606/6761) and .local (mDNS).
  • bin/package.json lists the new file under files.
  • Behavior is unchanged for every other host. A .dev site with a valid certificate keeps working; a .dev site with a self-signed certificate now gets a TLS error, which is correct.

Tests

  • tests/js/local-dev-host.test.mjs (node:test) failed on example.dev with the old rule (RED, not ok 2) and passes now (3/3).
  • A new CI job, Proxy (node --test), runs it.
  • bin/local-dev-host.mjs is in the zip, and tests/ stays out of it.
  • PHPUnit: 1456 green.

CodeQL will probably still flag the conditional rejectUnauthorized = false, since it cannot see that the condition is now local-only. After merge, if the alerts remain, they are dismissed as "won't fix" with that explanation.

🤖 Generated with Claude Code

…local development

bin/mcp-proxy.mjs sets rejectUnauthorized = false for "local dev" hosts so a
self-signed certificate works, and it sends a WordPress Application Password
over that connection. Its list included .dev, which is a delegated public TLD
(Google, HSTS-preloaded): a real site at example.dev got a connection with no
certificate check, open to a man-in-the-middle for the credential.

The host check moves to bin/local-dev-host.mjs (isLocalDevHost) and keeps only
names that cannot be a public site: loopback, .test, .localhost, .invalid
(RFC 2606/6761) and .local (mDNS). bin/package.json lists the new file.

Found by CodeQL js/disabling-certificate-validation (alerts on lines 119 and
154). tests/js/local-dev-host.test.mjs failed on example.dev with the old
rule and passes now; a new "Proxy (node --test)" CI job runs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T00:55:29.231706Z 0dc2c55 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0721246433

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/mcp-proxy.mjs Outdated
import { request as httpRequest } from 'node:http';
import { request as httpsRequest } from 'node:https';
import { appendFileSync } from 'node:fs';
import { isLocalDevHost } from './local-dev-host.mjs';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the documented standalone proxy installation

For users following the standalone installation instructions in README.md:180, mcp-config-examples.json, or the admin connection page, only mcp-proxy.mjs is copied to the client machine. This new relative import makes that documented workflow exit immediately with ERR_MODULE_NOT_FOUND before processing any MCP requests; copying the changed proxy alone reproduces the failure. Including the helper in the ZIP and npm package does not cover this installation path. Keep the proxy self-contained, or update all standalone installation and upgrade instructions to require copying the helper alongside it.

Useful? React with 👍 / 👎.

Codex r1: the documented standalone install copies only mcp-proxy.mjs, so a
relative import of bin/local-dev-host.mjs made it exit with
ERR_MODULE_NOT_FOUND. The host check is back inline, with .dev still
removed, and the helper module and its unit test are gone.

tests/js/proxy-tls.test.mjs now runs the shipped file copied ALONE into an
empty directory, against a local HTTPS server with a self-signed
certificate, every hostname resolved to it:
- mysite.test -> the server answers (and no ERR_MODULE_NOT_FOUND);
- example.dev -> no answer: the self-signed certificate is refused.
It fails on main (the .dev case) and on the previous commit (the
single-file case), and passes here. The CI job is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@BenKalsky

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0dc2c55206

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BenKalsky
BenKalsky merged commit 4b44521 into main Oct 26, 2026
4 checks passed
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