Skip to content

Plugin execution integrity: verify the recorded content hash at activation (detect swapped bytes on load and rollback) #3522

Description

@cad0p

The workflow

I run a security-sensitive plugin — the client-side crypto endpoint of a "sealed mode" scheme: it intercepts HTTP(S) requests in bb's embedded browser and HPKE-seals them to pinned origin keys, so the CDN edge in between only sees ciphertext. The plugin is the trust anchor. Independent of provenance work (companion issue), the cheapest meaningful hardening is: the bytes that execute are the bytes the installer validated, checked at every activation.

What happens today (main @ 9b4f273)

  • hashInstallDir already exists — a deterministic sha256 over the whole plugin tree (names, contents, modes, symlinks) — and is recorded per artifact in the DB.
  • It is re-checked on install/promote/dedup paths (managed-plugin-artifacts.ts, e.g. :723/:997/:1189/:1432) — install-time bookkeeping, not activation.
  • The load path never compares: plugin-runtime.ts loadOne() (called on server start, enable, reload, and rollback) only stats the directory, reads the manifest, and executes.
  • plugin-activation.ts reloads the previous artifact on failure — if that directory drifted since it was recorded, rollback silently re-executes drifted code.
  • Plugins are full-trust in the bb server process: any plugin can write into another plugin's directory and wait for a reload.

What a load-time check would close

  • Another plugin patching this one (see above).
  • path: drift — bad merge, build leftovers, an agent editing files, a crash mid-update leaving the DB and disk disagreeing.
  • Sync/backup/restore putting a modified copy back under the same rootDir.
  • Rollback trusting drifted bytes — the exact moment you most want the check.

What it does not solve (so triage is honest)

What you would expect

  • Compare disk to the recorded hash at loadOne; on mismatch, refuse to activate (or load with a loud drifted state, policy per source kind) and reuse the existing failed-load surface (PREVIOUS_INSTANCE_KEPT — "the previous instance is still running").
  • A drifted signal in bb plugin list and logs, so it is visible without reading DB rows.
  • Tests covering: patched directory, post-install drift, rollback into drifted bytes, and the path: allow/warn path.

Context and alternatives

Checks

  • I searched open and closed issues for the same request.
  • If an agent wrote this, the body ends with > AGENT GENERATED.

AGENT GENERATED

Activity

  1. added
    plugins
    security
    on Sep 11, 2026
  2. bb-slop-cop commented on Sep 11, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied Type: Feature, Priority: Medium, Effort: Medium, and labels: plugins, security. No existing classification values were present.

    This adds activation-time integrity enforcement, source-specific policy, and drift visibility to existing installation checks. Final Type verified as Feature; reproduction report and fix steps skipped. No PR opened because this requires new policy and security behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pluginssecurity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions