Skip to content

connect refuses its own state directory under umask 002 (cloud_credential_store_unsafe) #5137

Done

Description

@t0tl

Problem

On 0.22, connect fails when the process umask is 002. It fails before it contacts the provider:

{"code":"COMMAND_FAILED","message":"The cloud connection cannot serve this command.","details":{"reason":"cloud_credential_store_unsafe"}}

The state directory that connect refuses is one that agent-device created itself in the same command. With umask 002 it is drwxrwxr-x. admitCloudStateRoot in src/cli/connection/cloud-connection-record.ts then refuses it, because it requires (mode & 0o022) === 0.

umask 002 is common: it is the default for user-private-group Linux setups, and GitHub-hosted runners use it. A user on such a host cannot connect, and the hint ("Run agent-device disconnect in this session to recover it, then reconnect") does not fix it.

Reproduce

Seen on 0.22.0-nightly-0-22.20261126.252 (branch 0.22, still the same check at 3340ed0) with the @run-cloud/[email protected] provider plugin, macOS, Node 24. The provider does not matter: the refusal happens before any provider call.

umask 002
export HOME=$(mktemp -d) AGENT_DEVICE_STATE_DIR=$HOME/state AGENT_DEVICE_SESSION=umask-repro RUN_CLOUD_API_KEY=dummy
npx -y [email protected] plugins add @run-cloud/agent-device@next
npx -y [email protected] connect runcloud --platform ios --json
# -> COMMAND_FAILED, details.reason "cloud_credential_store_unsafe"
stat -f '%Sp' "$AGENT_DEVICE_STATE_DIR"   # drwxrwxr-x

With umask 022, the same steps create state as drwxr-xr-x, and connect reaches the provider (here a 401 for the dummy key, as expected).

Cause

The state root is created by a mkdirSync without a private mode. Candidates on 0.22 are packages/remote/src/remote-connection-state.ts:412 and packages/host-kit/src/internal/host-file.ts:111 (both recursive: true, no mode). The process umask then decides the mode. The cloud credential check later requires a mode that the umask did not give.

Expected

One of these:

  • agent-device creates the state root privately (0o700, or an explicit chmod after creation), so its own directory always passes its own check. Private writes for credentials and client state #4669 ("the state root is verified once and created privately") describes this rule.
  • Or, if a group-writable state root that the user owns is acceptable, the check allows it, or the error says what to change (for example, chmod 700 <stateDir>).

A test that runs connect under umask 002 would catch a regression.

Activity

  1. added
    bug
    on Nov 27, 2026
  2. thymikee commented on Nov 27, 2026

    @thymikee
    Member

    Triage: bug on 0.22. The connection lock can create the state root before the credential check runs, so umask 002 makes a fresh directory fail the next check. The fix should create that root privately before locking and keep the existing ownership and mode checks for directories already on disk. The repro has enough detail to start.

  3. added 3 commits that reference this issue on Nov 28, 2026
    94cbfa3
    504ce8a
    b7fb7d8
  4. thymikee commented on Nov 30, 2026

    @thymikee
    Member

    Fixed on 0.22 in #5157. Connect creates the state root privately before taking its lock, including under umask 002. #4669 tracks the wider private-write audit.

  5. added 2 commits that reference this issue on Dec 1, 2026
    cf72177
    276bc73
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

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions