Skip to content

Follow-ups from the #4116 review: a cache volume deleted inside the 5-minute ready window comes back root-owned and unlabelled #4123

Closed

Description

@yannickmonney

Root merged #4116 at 08:20:54Z as d5453d02f, with no review on record. Agent #2's post-merge source review (record 5967320911) finds one MEDIUM on main. It was found from source, relying on Docker's documented creation of a missing named volume on run; nothing was executed.

MEDIUM: a cache volume deleted inside the 5-minute "volume ready" window comes back root-owned and unlabelled, and is never repaired

Where:

  • the cache early-return at volume.ts:162-163;
  • :178-182, which reads any existing volume as ready, with no label or permission check;
  • docker-session-args.ts:346-353 (--mount type=volume,…).

Scenario:

  1. A create marks an organization's three cache volumes ready until T0+5m.
  2. The organization's sessions stop.
  3. An operator runs docker volume prune -a or volume rm.
  4. The next create inside the window skips the ensure, and docker run --mount lets Docker create the volume: no tale.sandbox-cache label, root-owned, mode 0755.
  5. Session processes run as 10001/65534 with every capability dropped, so writes to /cache/{pip,npm,bun} fail with EACCES.
  6. After the window, the ensure finds the volume, never applies chmod 1777 and never adds the label. The damage is permanent.

Knock-on effects:

  • The unlabelled volume is invisible to listCacheVolumeOrganizations and refused by removeCacheVolumes, so platform teardown sweeps can answer 502.
  • The code's own comment (volume.ts:138-142, "made ready again once this has passed") is wrong.

LOW

  • Teardown can leave the cache marking a deleted volume ready. It clears the entry (volume.ts:100) before it removes the volume (:101-125), and an ensure already in flight sets it ready again.
  • A destroy can miss workspace data after a root change. The no-colour-directories shortcut (docker-session-backend.ts:153) skips the docker inspect mount lookup for destroy too. After a change to SANDBOX_HOST_SESSION_ROOT or a device's stateDir, destroy reports hadWorkspace=false and leaves the data. Keep the lookup on destroy.
  • INFO: mutants of the boundary check, the set-before-await, and the dot-directory and lost+found filters would survive.

Acceptance

  • Labels: the ensure checks the label. If it's missing, remove the volume and recreate it with its label and mode. If it's in use, at least chmod and warn.
  • Test: a fake run that creates an unlabelled volume when one is missing, then a session write and a teardown that both succeed.
  • The LOWs: fixed with tests, or recorded as explicit decisions.
  • An independent review by a distinct agent.

Related: #4116, #4094 (trash paths never touch caches).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions