Skip to content

Bind retained sandbox cleanup to durable identity before native-state wipe #12950

Open

Description

@rsliter

Problem Statement

Live retained-sandbox destroy checks the recorded OpenShell identity, then clears the agent's native home through the mutable sandbox name before its final identity check. If an independent OpenShell client replaces that name after the earlier check, the cleanup can clear the replacement's native state. A later identity mismatch prevents deletion but cannot undo the state loss.

This is a source-level interleaving identified in the PR Review Advisor run for docs PR #12735. It has not been reproduced against a live gateway. The current operating assumption on PR #12893 excludes independent same-name replacement during cleanup. That decision addressed the later check-to-delete race; it did not establish a durable-identity binding for the earlier native-state wipe.

Desired Behavior

Cleanup of a live retained sandbox must not clear native state or detach providers belonging to a different durable sandbox identity. When NemoClaw cannot bind a destructive step to the recorded identity or prove exclusive authority for the name, it stops before that step and preserves the recovery record. A stable matching sandbox remains eligible for cleanup when the required authority exists.

Evidence and Current Boundary

  • src/lib/actions/sandbox/destroy-execution.ts checks continuity after managed inference cleanup, then calls wipeAgentNativeHome(sandboxName, ...) before the provider and final delete-boundary identity checks.
  • src/lib/onboard/sandbox-provider-cleanup.ts detaches providers by sandbox name. Its optional identity callback is not supplied by this destroy call.
  • src/lib/actions/sandbox/destroy-retained-recovery-flow.test.ts covers identity drift at the delete boundary, but not replacement before native-home cleanup.
  • The recovery guide in PR #12735 warns operators that native state can be cleared before the final check. Documentation cannot bind the mutation to a durable identity.

Scope and Exclusions

This issue covers the retained, live-sandbox destroy path and its pre-delete destructive steps. It does not request a new integration or a general lifecycle redesign. The accepted check-to-delete risk on PR #12893 remains a separate decision. Implementation should first establish whether OpenShell offers an identity-bound mutation or an authoritative exclusion mechanism; another point-in-time identity read alone does not close the race.

Ownership and Placement

Core NemoClaw sandbox lifecycle maintainers. No implementation owner is assigned. The behavior belongs in the existing destroy and retained-recovery path, not in a community recipe.

Validation Plan

Add a deterministic destroy-flow test that changes the observed sandbox identity between the last pre-cleanup check and the native-home step. Assert that native-state wipe, provider detach, deletion, and registry clearing do not affect the replacement, and that the retained recovery record remains. Cover a matching stable identity and an inconclusive identity result. Use a live E2E only if an OpenShell boundary cannot be represented by the existing deterministic test harness.

Compatibility and Security Impact

Applies to supported agents and runtime providers that enter live retained-sandbox cleanup. No credential handling change is requested. The risk is unintended loss of sandbox native state under concurrent management of the same name; this issue does not claim an unprivileged exploit or include confidential details.

Activity

  1. added
    needs: triage
    on Oct 9, 2026
  2. ksapru commented on Oct 11, 2026

    @ksapru
    Contributor

    I looked at what OpenShell offers for this, before changing any code. Findings are from main here and OpenShell v0.0.116 (the version NemoClaw pins).

    Confirmed here: wipeAgentNativeHome runs openshell sandbox exec --name <name> before the provider detach and the final identity check, so the wipe addresses the mutable name.

    What 0.0.116 offers:

    Operation Addressing Identity-bound?
    gRPC ExecSandbox sandbox_id (durable ID) Yes
    CLI sandbox exec --name only No: it calls GetSandbox by name, then ExecSandbox with the resolved ID, so there is a gap inside the CLI
    DeleteSandbox name only No (the check-to-delete risk already accepted on #12893)
    DetachSandboxProvider name, plus optional expected_resource_version Weak: a resource version is not an identity, and a replacement could carry the same number

    I found no lock, lease, or exclusion mechanism for a sandbox name.

    Possible direction: the wipe could go through the gateway's ExecSandbox with the recorded durable sandbox ID and fail closed if that ID is gone, instead of the CLI's name-based exec. NemoClaw already calls the gateway by sandboxId elsewhere (for example getSandboxConfig in sandbox-config.ts), but its SDK exec helper in sandbox-command-sdk.ts currently takes a name. I have not yet confirmed whether the SDK exposes exec by ID or whether this would need the raw call.

    The provider detach and the final delete would still address the name. For those, the issue's fallback seems to be the only option on 0.0.116: stop before the step when identity cannot be bound, and keep the recovery record.

    Does this match the maintainers' expectations? If so, I'm happy to take a stab at an ID-bound wipe plus the deterministic destroy-flow test described in the validation plan (identity changes between the last check and the wipe, matching stable identity, inconclusive result), starting from main.

  3. added
    area: sandbox
    area: security
    and removed
    needs: triage
    on Oct 13, 2026
  4. added theissue type on Oct 13, 2026
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

    area: sandboxarea: security

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions