Skip to content

fix(harness): create session directories private to the user - #3137

Merged
gold-silver-copper merged 3 commits into
mainfrom
fix/rig24-sessdir
Nov 8, 2026
Merged

gold-silver-copper merged 3 commits into
mainfrom
fix/rig24-sessdir

Conversation

@gold-silver-copper

@gold-silver-copper gold-silver-copper commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On unix, RIG_HOME/sessions/ and every session directory were created with the default umask, usually 0755. With a traversable RIG_HOME and the default directory store, other local users could read every conversation, spill file and traffic log. auth/ was already 0700.

What users see change: on unix, sessions/ and each new session directory are now mode 0700. An existing wider sessions/ is tightened to 0700 the next time a session starts, by whichever path creates it. RIG_HOME itself, existing session directories inside it, and file modes are left as they are; a 0700 sessions/ already keeps them from other users. Windows and wasm are untouched (everything is cfg(unix)).

Both creation paths change:

  • the launcher's Home::new_session (crates/rig-harness-protocol/src/lib.rs): sessions/ is set to 0700 after create_dir_all, and the session directory is created with DirBuilder mode 0700. If sessions/ can't be made 0700 (another owner, or a filesystem that refuses chmod), it keeps its mode and the session starts, as on main; the new session's own directory is still 0700.
  • the harness started without the launcher, paths_in (crates/rig-harness/src/host/session.rs): the same two steps. Errors are still ignored there, as before, and show up as a failed log write.

The umask can only narrow the DirBuilder mode, so 0700 holds whatever the umask is. Tightening an existing directory needs set_permissions. No pub item is added or changed. The two crates can't share one helper without a new public item, so each crate has the few lines inline.

Bug Verdict Test
Architecture audit 2026-11-07, d-7: session directories created 0755 reproduced on base 63431d7, fixed rig-harness-protocol tests::a_new_session_directory_is_private_to_the_user (fresh home with sessions/ pre-made 0755: sessions/ and the new session directory end up & 0o077 == 0); rig-harness host::session::tests::a_session_directory_made_without_the_launcher_is_private_to_the_user (paths_in on a fresh home)

There is no issue or outside PR for this. This change differs from the audit's repro diff in one way: the repro had only a test, and this test also covers tightening an existing sessions/.

Changelog

  • (harness) On unix, sessions/ and every session directory under RIG_HOME are created mode 0700, and an existing wider sessions/ is tightened when a session starts, so other local users can no longer read conversations and logs.

Migration

None.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • Both tests fail on the test-only commit (mode 0755) and pass on the head, run on a Linux build machine
  • cargo xtask verify --affected --base origin/main passes at the head

Checklist:

  • I have updated READMEs and Rust docs affected by this change (new_session's # Errors)
  • I have added tests that prove my fix is effective or that my feature works
  • I did not edit CHANGELOG.md or MIGRATING.md (they are generated at release)

Notes

Line deltas: production +21 / -2 (2 files), tests +54 / -1 (2 files).

Real use: an independent tester ran real rig (launcher, interactive, and the agent alone) on main and this PR: sessions/ and session directories 755 on main, 700 here; an existing 0755/0777/0750 sessions/ tightened; RIG_HOME, files and old session directories unchanged; resume works.

Second fix commit (from review): new_session ignores a failed chmod of sessions/, as paths_in does, so a group-shared sessions/ owned by another user, or one on vfat, still starts a new session as on main.

Not verified: macOS.

Follow-ups (not in this PR): RIG_HOME itself and session directories from before this change keep their modes. A 0700 sessions/ already protects those directories. Other parts of the audit's proposal 3 (secret leaks in MCP header expansion and the cloak browser opener) are handled separately.

A sessions/ owned by another user or on a filesystem that refuses chmod
started a new session on main; keep it so, as the harness's own path
does.
@gold-silver-copper
gold-silver-copper added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 077fa0a Nov 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant