Skip to content

imcp2-deploy: run only the sync plugins the server knows - #253

Closed
raymondk wants to merge 1 commit into
deploy-5e-streamingfrom
deploy-5f-plugins
Closed

raymondk wants to merge 1 commit into
deploy-5e-streamingfrom
deploy-5f-plugins

Conversation

@raymondk

Copy link
Copy Markdown
Contributor

Stacked on #252. Last of four follow-ups preparing the hosted deploy tools for the gateway.

Why

A sync plugin is a program the bundle brings and the server runs. It runs in a sandbox (WASI, read-only access to its own deploy directory, no network) under a compute budget, but with no memory limit short of its address space, and inside the server's own process. In the gateway that process is the gateway. Until now a hosted server ran whichever plugin a bundle carried.

What changes

A hosted server runs only the plugins it knows, identified by the SHA-256 of the module. That is the same hash icp project bundle records for the plugin, and the bundler writes the plugin's bytes verbatim, so it is the hash of the released file. Name and path are never used, since the bundle chooses both.

Built-in list (KNOWN_PLUGINS):

sha256 Plugin
6deedcc2127a3bda014af9e08aff83ee58c95125050acb296676aa234906a08e static-site sync, v1.0.0
afb5d626761e891a42e5c36e8799bf521823de9f55c5102860bd3a237d3b164f static-site sync, v0.4.3
ca7cb5666c30d2875f8d5e10535f8a53f97a86c79c263f7d5bdac2fdd1bbf83c asset canister sync

The check runs twice:

  • On the upload (vet_plugins). Once the bundle has arrived the project is loaded and every canister it declares is checked, whichever environment a deploy would later name. A bundle with an unlisted plugin gets 422 and is not kept.
  • At deploy preflight (check_bundle). The modules about to run, for the canisters being deployed, are checked before anything is created. This is the authoritative check.

The refusal names the plugin's path and hash and lists what the server runs.

Configuration

DeployConfig::allowed_plugins adds hashes to the built-in list (MCP_DEPLOY_ALLOWED_PLUGINS on the bundled binary, comma- or space-separated). An entry that is not a SHA-256 makes Deploys::new fail, so the server does not start on a list it misread.

The local server is unchanged: the bundle there is the user's own, and it runs whatever the bundle brings.

Side effects worth knowing

  • Loading the project on upload means a project that does not load (a script step, a remote source, a malformed manifest) is now refused on the upload instead of at deploy.
  • A bundle built with a plugin release newer than this list is refused until the hash is added. That is the intended trade.
  • New upload outcome plugin_not_allowed in imcp2_deploy_uploads_total.

Not done here

The plugin runtime still has no memory limiter; that belongs upstream in icp-sync-plugin. With this change the question of what an unknown plugin might allocate is answered by not running it.

Testing

  • The list: built-in hashes, operator additions, malformed entries.
  • Preflight: an unlisted plugin refused with its hash and the server's list; the same bundle accepted once its hash is allowed; a server with an empty list.
  • Upload vetting: unlisted plugin, listed plugin, no plugin, a project that does not load.
  • Store and endpoint: the bundle refused on arrival and not kept, 422, and the counter.
  • Workspace and deploy-feature tests pass; clippy clean with and without the feature.
  • I have not checked the three hashes against the published plugin releases; they are as supplied.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV

A sync plugin is a program the bundle brings and the server runs: in a
sandbox and under a compute budget, but with no memory limit short of its
address space, and inside the server's own process. A server that deploys
for others had run whichever a bundle brought.

- `AllowedPlugins`: any, for a server on the user's own machine; or the
  ones known, by the sha256 of the module, which is also what `icp project
  bundle` records for it. Never by name or path, which are the bundle's.
  `KNOWN_PLUGINS` is the built-in list: the static-site sync plugin v1.0.0
  and v0.4.3, and the asset canister sync plugin.
- Held twice. On the upload (`vet_plugins`): the project is loaded once the
  bundle has arrived, and every canister it declares looked at, so the
  refusal comes then (422) and the bundle is not kept; a project that does
  not load is refused there too. And by the deploy (`check_bundle`), on the
  modules it is about to run for the canisters it is deploying, before
  anything is created. The refusal names the plugin's hash and what the
  server runs.
- `DeployConfig::allowed_plugins` (`MCP_DEPLOY_ALLOWED_PLUGINS` on the
  bundled binary) adds hashes to the built-in list; one that is not a
  sha256 stops the server from starting.
- The upload outcome `plugin_not_allowed` is counted.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
@raymondk
raymondk requested a review from a team as a code owner November 19, 2026 02:14
Copilot AI max review requested due to automatic review settings November 19, 2026 02:14

Copilot AI 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.

🟡 Changes recommended

Plugin allow-list propagation lacks regression coverage, while generated curl commands suppress plugin-refusal details and deployment guidance incorrectly recommends rebuilding for every 422 response.

2 open issues
What changed in this PR

Adds hash-based sync-plugin allowlisting to hosted deployments ahead of gateway use, while leaving local deployments unrestricted.

Changes:

  • Checks plugin module hashes during upload and deploy preflight.
  • Supports operator-added hashes through configuration, rejecting malformed entries at startup.
  • Adds refusal metrics, tests, and documentation for the hosted plugin policy.
File Description
src/​metrics/​deploy.rs Adds the plugin_not_allowed upload outcome.
src/​main.rs Parses the plugin allowlist environment variable.
src/​deploy.rs Applies hosted policy and maps refusals to HTTP 422 and metrics.
README.md Documents trusted plugins, configuration, and refusal behavior.
deploy/​native/​README.md Explains plugin policy for native deployments.
crates/​imcp2-deploy/​static/​skills/​deploy-with-mcp.md Guides agents on handling unlisted plugins.
crates/​imcp2-deploy/​src/​uploads.rs Vets uploaded plugins and discards refused bundles.
crates/​imcp2-deploy/​src/​lib.rs Exports policy types and selects hosted versus local policy.
crates/​imcp2-deploy/​src/​host.rs Defines known hashes, validates policies, and checks plugin bytes.
crates/​imcp2-deploy/​src/​deploy.rs Carries plugin policy into deploy preflight.

Review effort: Max

Comment on lines +74 to +75
on the upload (`422`) or by the deploy, and the refusal lists the hashes
the server runs. That is not something to retry or work around: tell the
Comment thread src/deploy.rs
let uploads =
Uploads::with_budget(dir.join("uploads"), config.limits(), config.stored_bytes());
Uploads::with_budget(dir.join("uploads"), config.limits(), config.stored_bytes())
.allowing(plugins);
@raymondk

Copy link
Copy Markdown
Contributor Author

Superseded by the stack #254 → #259, which carries the same code in six PRs from main, with the deploy tools living in imcp2-core instead of a separate crate. The plugin allowlist is part of #254 and #255.

@raymondk raymondk closed this Nov 19, 2026
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