Skip to content

fix(mcp): load plugin MCP bundles when the Paca host resolves to a private IP - #831

Merged
pikann merged 2 commits into
Paca-AI:masterfrom
sebathi:fix/mcp-plugin-loader-trust-base-host
Nov 27, 2026
Merged

pikann merged 2 commits into
Paca-AI:masterfrom
sebathi:fix/mcp-plugin-loader-trust-base-host

Conversation

@sebathi

@sebathi sebathi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On a self-hosted Paca whose hostname only resolves inside the LAN (split-horizon DNS, e.g. paca.example.lan → 192.168.x.x), the MCP server never registers any plugin tool. resolveImportUrl resolves every https:// plugin entry via DNS and rejects private addresses (SSRF guard). Every plugin's path-only remoteEntryUrl (/plugins-mcp/<id>/mcp.js) resolves against the operator's own PACA_GATEWAY_URL / PACA_API_URL host, so all of them fail:

[plugin-loader] Failed to load plugin "com.paca.bdd" from /plugins-mcp/com.paca.bdd/mcp.js:
Error: Plugin entry URL hostname "paca.example.lan" resolves to private/internal IP "192.168.18.72"

Core tools keep working, so from the agent's point of view the BDD / checklist / dashboard / time-logging plugins simply look "not active". Reproduced with the published @paca-ai/[email protected] against a v0.22.0 instance: 85 core tools, 0 plugin tools, 4 plugins failed with the error above.

Fix

The http:// branch already trusts the configured base/gateway host. Apply the same rule to https://: skip the private-IP check only when the entry's hostname equals the configured base host. Any other https:// host is still resolved and rejected if it is private, and redirects are still refused, so the SSRF guard is unchanged for third-party URLs. The baseURL hostname parsing is hoisted so both branches share it.

Verification

  • vitest run src/__tests__/plugin-loader.test.ts: 15 tests pass (2 new: trusted base host over https, private non-base https host still rejected). biome lint and tsc --noEmit clean.
  • Patched build against the same LAN instance: all 4 plugins load, 117 tools including bdd_list_scenarios, bdd_create_scenario, checklist_*, dashboard_*, time_logging_*.

Checklist

  • Scoped to one concern
  • Tests added for changed behaviour
  • apps/mcp/CHANGELOG.md updated under Unreleased / Fixed; resolveImportUrl doc comment updated

…ttps

resolveImportUrl rejects any https:// plugin entry whose hostname resolves
to a private/internal IP (SSRF guard). On a LAN or split-horizon-DNS
deployment the operator's own Paca host resolves to a private address
(e.g. paca.example.lan -> 192.168.x.x), and every plugin's path-only
remoteEntryUrl (/plugins-mcp/<id>/mcp.js) resolves against exactly that
host, so every plugin failed with "resolves to private/internal IP" and
no plugin tool (bdd_*, checklist_*, dashboard_*, time_logging_*) was ever
registered. Core tools kept working, which made the failure look like the
plugin was simply not active.

The http:// branch already trusts the baseURL / gateway host. Apply the
same rule to https://: skip the private-IP check only when the entry's
hostname equals the configured base host; any other https:// host is
still resolved and rejected if private. Hoist the baseURL hostname
parsing so both branches share it, and cover both cases with tests.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one defense-in-depth note and a stale doc line.

Approach: sound — the https:// branch now trusts the operator-configured base/gateway host exactly as the http:// branch already did, so path-only plugin entries load on LAN/split-horizon deployments without weakening the guard for third-party hosts.

Reviewed changes

  • Trust the configured host over https:// — resolveImportUrl hoists the baseURL hostname parse and skips assertNotPrivateHost only when the entry's hostname matches it; every other https:// host is still resolved and rejected if private, and fetchAsDataUrl still uses redirect: "error".
  • Tests — two new cases cover the trusted base host over https:// (no DNS lookup) and a private non-base host still being rejected.
  • Docs — the resolveImportUrl doc comment and apps/mcp/CHANGELOG.md describe the new exception.

ℹ️ docs/plugins/skills-plugin-system.md still describes the old https:// rule

The comparison section says the MCP loader allows https:// "unless the hostname resolves to a private/internal IP" and only http:// trusts the configured gateway host. This PR adds the same gateway-host exception to https://, so that sentence is now stale. It is a hand-maintained doc with no CI check, so it will not be caught elsewhere.

Technical details
# Update the MCP loader's SSRF allowlist description

## Affected sites
- docs/plugins/skills-plugin-system.md:136 — describes the `https://` allowlist without the base-host exception.

## Required outcome
- The sentence matches the new behavior: `https://` is allowed unless the hostname resolves to a private/internal IP, except for the configured gateway/base host; `http://` is allowed only for localhost or that host.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread apps/mcp/src/plugin-loader.ts Resolved
Comparing only the hostname made https://<base-host>:<any-port>/... skip
the private-IP guard, so a manifest could point at another TLS service
on the same machine. Compare URL.host (hostname plus effective port)
instead, for both the https:// and http:// branches. URL.host omits a
default port, so a path-only entry resolved against https://paca.lan
still matches while https://paca.lan:8443 does not, and an internal
gateway such as http://paca-gateway.paca-ns.svc:8080 keeps matching its
own port. Full origin is not compared because the scheme is already
fixed by the branch.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound — scoping the trust to URL.host keeps the LAN/split-horizon fix while narrowing the skipped SSRF check to the configured host and port.

Reviewed changes

  • Port-scoped host trust — isBaseURLHost now compares URL.host (hostname plus effective port) instead of hostname alone, so https://<base-host>:<other-port> goes back through assertNotPrivateHost and http://gateway:<other-port> is no longer treated as the configured gateway.
  • Tests — added cases for a different port on the base host over both schemes, and for an explicit-port gateway host resolving a path-only entry over http://.
  • Changelog — the [Unreleased] entry now states the trusted host comparison includes the port.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 9a56916 into Paca-AI:master Nov 27, 2026
2 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.

2 participants