Skip to content

Adopted environment upgrade mutated the source gateway state database #98

Closed

Description

@MertBasar0

Summary

During an OpenClaw release-validation run, an OCM-adopted disposable environment was upgraded to an exact beta runtime. The candidate did not remain confined to the adopted environment: it migrated the original source gateway's shared state database from schema 7 to schema 8.

The source gateway could no longer start on its original checkout after the validation attempt and required recovery. The OCM checkpoint available for rollback had been created after the migration, so it did not contain a recent schema-7 copy.

Environment

  • Host: Windows 11 with Ubuntu WSL
  • OCM: 0.2.32
  • Source OpenClaw: 2026.8.1 at f329a9489f32e6472ded5437be971609229c9451
  • Candidate: v2026.8.1-beta.2 at 8f382a202ff1e15833394b481615dcdda99b04d7
  • Source: a real gateway state directory
  • Target: an adopted OCM environment with a distinct environment name, state directory, and port

No credentials or user-specific paths are included here.

Sequence

  1. Inspect and import the real gateway into a disposable environment using the documented ocm adopt inspect, ocm adopt plan, and ocm adopt import flow.
  2. Install and verify the exact candidate runtime.
  3. The adopted environment had defaultRuntime=null, so set its runtime explicitly before continuing.
  4. Run the candidate upgrade dry-run, upgrade, and start against the adopted environment.
  5. Observe that the isolated candidate reports the exact beta version but fails readiness.
  6. Inspect the source gateway after the failed validation run.

Expected behavior

  • All candidate migrations and writes stay within the adopted environment's state directory.
  • The source gateway's configuration, databases, and schema metadata remain byte-for-byte unchanged.
  • A pre-upgrade checkpoint exists before any candidate migration and can restore the adopted copy independently of the source.

Actual behavior

  • The isolated candidate failed startup three consecutive times with:

    Gateway failed to start: Cannot read properties of undefined (reading 'values')

  • The original source gateway's state database was migrated from schema 7 to schema 8.

  • Its schema metadata recorded app_version=2026.8.1-beta.2, even though the source gateway had not been intentionally upgraded.

  • The source checkout supported schema 7 and could no longer restart against the migrated database.

  • The available OCM checkpoint was created after the migration and therefore did not provide a recent schema-7 recovery copy.

  • The exact retained path, link, or environment reference through which the candidate reached the source database has not yet been identified.

The release-facing startup failure was recorded in the shared validation ledger: openclaw/openclaw#125626 (comment)

Impact

This breaks the central safety guarantee of the release-validation workflow: a tester can follow the isolated-copy path and still mutate or disable the gateway they actively use. A failed beta upgrade can therefore affect data outside the disposable environment, while the resulting checkpoint may be too late to recover the pre-migration state.

Requested safeguards

  • Resolve and verify all candidate-writable paths after adopt/import and before upgrade.
  • Fail closed if any config include, symlink, workspace reference, database path, or resolved state path escapes the adopted environment or aliases the source gateway.
  • Create and verify a pre-migration checkpoint before starting the candidate runtime.
  • Ensure the checkpoint itself is independent of candidate-writable state.
  • Add an integration test that upgrades an adopted copy and asserts that the source state tree and database schema hash remain unchanged.
  • Surface the resolved source and target state roots in redacted diagnostic output so an isolation failure can be traced without exposing credentials.

The source gateway has since been recovered, but the isolation escape remains unexplained.

Activity

  1. added
    clawsweeper:needs-maintainer-review
    clawsweeper:no-new-fix-pr
    impact:crash-loop
    impact:data-loss
    issue-rating: 🦪 silver shellfish
    P1
    on Aug 20, 2026
  2. clawsweeper commented on Aug 20, 2026

    @clawsweeper

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 6, 2026, 5:24 AM ET / 09:24 UTC.

    Summary
    Keep open: current main retains the runtime-install environment leak, and the reporter has supplied a targeted reproduction and an open fixing PR. The newer evidence supersedes the earlier assessment that the write boundary was unidentified.

    Reproducibility: yes. for the inherited-environment defect: current source exposes caller state paths to npm, and the linked PR supplies a targeted published-package reproduction. The exact current-main schema migration was not executed here.

    Next step
    Review the existing fix at #131, including npm-settings compatibility; keep this issue open until that candidate is resolved instead of dispatching another repair PR.

    Security
    Needs attention: Current runtime installation preserves caller state paths across the candidate installation boundary.

    Review details

    Best possible solution:

    Isolate lifecycle-script state before package execution while preserving supported npm transport configuration, and verify that source database/config hashes remain unchanged throughout installation and upgrade.

    Do we have a high-confidence way to reproduce the issue?

    Yes for the inherited-environment defect: current source exposes caller state paths to npm, and the linked PR supplies a targeted published-package reproduction. The exact current-main schema migration was not executed here.

    Is this the best way to solve the issue?

    Yes: repairing the npm child-process boundary directly addresses the newly identified first write, whereas adoption-only path checks cannot protect installation that occurs before gateway startup.

    AGENTS.md: not found in the target repository.

    Remaining risk / open question:

    • Current installation scripts can resolve caller-owned OpenClaw state before an adopted environment’s upgrade checkpoint exists.
    • The linked PR reports a compatibility concern: replacing npm’s home can hide user-level .npmrc settings; its final resolution belongs in that PR’s review.
    • The reported beta schema migration was not independently rerun against current main during this read-only review.

    Codex review notes: model internal, reasoning medium; reviewed against 9d8845c7efe3.

    Label changes

    Label changes:

    • add P0: The reported operation irreversibly advanced an active gateway’s database schema beyond its runtime and left it unable to restart without recovery.
    • add impact:security: The issue concerns a writable-state isolation boundary that allows candidate installation to affect caller-owned gateway state.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.
    • remove P1: Current review triage priority is P0, so this older priority label is no longer current.
    • remove clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label.
    • remove clawsweeper:needs-info: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🦐 gold shrimp: Current issue advisory state no longer selects this label.
    • remove clawsweeper:needs-product-decision: Current issue advisory state no longer selects this label.

    Label justifications:

    • P0: The reported operation irreversibly advanced an active gateway’s database schema beyond its runtime and left it unable to restart without recovery.
    • impact:data-loss: Source state was modified outside the disposable environment, without a recent pre-migration recovery checkpoint.
    • impact:crash-loop: The source gateway could no longer start against the migrated database.
    • impact:security: The issue concerns a writable-state isolation boundary that allows candidate installation to affect caller-owned gateway state.
    Evidence reviewed

    Security concerns:

    • [high] Installation scripts can reach caller-owned gateway state — src/store/runtimes.rs:943
      The npm child inherits HOME and OpenClaw path variables, allowing ordinary lifecycle path resolution to select the source gateway’s database instead of disposable installation state.
      Confidence: 0.97

    What I checked:

    • Verified review revision and repository: The origin is https://github.com/openclaw/ocm.git and HEAD matches the supplied current-main revision. The final working-tree status was clean. (9d8845c7efe3)
    • Runtime installation still inherits caller state: The package installer constructs an npm install command and executes it without replacing HOME or OpenClaw state/config variables. Its shared environment helper only adjusts PATH; the local adapter adds workspace variables rather than isolating caller state. The companion-package installer has the same inheritance boundary. (src/store/runtimes.rs:943, 9d8845c7efe3)
    • Shared environment helper does not isolate state: CommandSpec::apply_environment returns immediately for host npm and otherwise prepends the managed toolchain to PATH. It does not sanitize HOME, OPENCLAW_HOME, OPENCLAW_STATE_DIR, or OPENCLAW_CONFIG_PATH. (src/managed_node.rs:51, 9d8845c7efe3)
    • Existing isolation contract: The README defines managed environments as isolated, states that migration leaves the source home and repository unchanged, and promises that upgrade simulation leaves the real environment untouched. (README.md:212, 9d8845c7efe3)
    • New reproduction and existing fix candidate: The reporter’s August 31 follow-up identifies inherited npm lifecycle environment during runtime installation as the first write boundary. The supplied complete body of fix: isolate runtime install lifecycle state #131 reports a published-package comparison: OCM v0.2.32 migrated synthetic source state from schema 7 to 8, while the proposed fix and explicit-path control preserved schema 7 and source hashes. The supplied GitHub closing relationship marks that same-author PR open and unmerged. These are contributor-reported results, not a reviewer-executed reproduction.
    • Merged adoption safeguard covers a different boundary: fix(migrate): reject external plugin paths during adoption #110 merged external-plugin containment. Current migration code rejects uncontained plugin records, and its regression test asserts import failure, target removal, and unchanged source database/plugin bytes. The August 28 discussion explicitly kept this issue open because that safeguard did not explain the reported migration. (tests/migrate_command_tests.rs:1243, 9d8845c7efe3)

    Likely related people:

    • Hannes Rudolph: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. MilkyWay008 commented on Aug 20, 2026

    @MilkyWay008

    An adopted env reaching the source gateway's state dir is how you get a silent schema push like that, the candidate migration just ran against whatever SQLite it found. Worth confirming the candidate runtime points at its own isolated data path and not back at the source, and take the checkpoint before the upgrade rather than after. Oh, btw, I built a portable Hermes OTG and run it on a USB stick as my rescue agent, super handy for diagnosing when an upgrade half-writes your install from a working agent on the side, https://github.com/MilkyWay008/Hermes-OTG

  4. added
    clawsweeper:fix-shape-clear
    clawsweeper:needs-info
    issue-rating: 🦐 gold shrimp
    clawsweeper:needs-product-decision
    and removed
    issue-rating: 🦪 silver shellfish
    clawsweeper:fix-shape-clear
    clawsweeper:needs-info
    on Aug 21, 2026
  5. 65 remaining items

  6. added
    P0
    clawsweeper:linked-pr-open
    clawsweeper:needs-security-review
    clawsweeper:source-repro
    impact:security
    issue-rating: 🦞 diamond lobster
    and removed
    P1
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-info
    issue-rating: 🦐 gold shrimp
    clawsweeper:needs-product-decision
    on Sep 6, 2026
  7. steipete commented on Sep 22, 2026

    @steipete
    Contributor

    Verified fixed on current main (df3bdde8cf5814e49756552fdf2a9a3c95226092, OCM 0.2.47) by #131 / 3cb61a7. The follow-up reproduction identified the missing boundary: npm lifecycle processes inherited the caller’s OpenClaw state paths. Runtime installation now gives those processes isolated lifecycle state while retaining npm configuration.

    Rechecked on isolated Linux fixtures with Node 24.18.1:

    cargo test --locked --test runtime_command_tests official_runtime_install_isolates_npm_lifecycle_from_caller_openclaw_state -- --exact
    1 passed; 0 failed
    

    The test covers both host npm and managed Node, executes the lifecycle probe, and verifies that the source state, config, and service marker remain byte-identical. Closing as fixed; thanks @MertBasar0 for identifying and fixing the write boundary.

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

    P0clawsweeper:linked-pr-openclawsweeper:needs-security-reviewclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:crash-loopimpact:data-lossimpact:securityissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions