Skip to content

fix(bubblewrap): bind the chat attachment staging dirs read-only so the agent can open what the user attached - #438

Closed
teknium1 wants to merge 1 commit into
mainfrom
fix/430-attachments-ro-bind
Closed

teknium1 wants to merge 1 commit into
mainfrom
fix/430-attachments-ro-bind

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Fixes #430 (reported by @albertoprb, whose diagnosis this follows).

Bug. A file attached in the TUI, Desktop or web (file.attach) is staged at <profile HERMES_HOME>/attachments/<name> (tui_gateway/prompt_attachments.py _session_home_dir / _stage_session_file_attachment). Pasted images go to HERMES_HOME/images and large Desktop pastes to HERMES_HOME/composer-pastes. The prompt names that host path in an @file: reference. The bubblewrap sandbox hides HERMES_HOME whole and bound back only the scratch dir, the state dir and the profile home. So an attachment too large or binary to inline pointed at a path that did not exist inside the sandbox, for terminal and for the file tools alike. An operator binds entry cannot work around it, because binds into a Hermes home are refused.

Fix. staged_input_binds creates each of the three staging dirs if it is missing (core does the same for docker in get_cache_directory_mounts) and binds it read-only at its own path, among the late mounts next to the scratch dir. The dirs go through the same bind guard as the scratch dir, so a staging dir that is a symlink into the rest of the Hermes home, or into a directory a sandbox can write to, is refused with one warning. Read-only means a command cannot plant a file that a later turn would take for an upload. Everything else under HERMES_HOME stays hidden: config, .env, sessions, and the document caches from messaging platforms.

Trade-off to note. Commit ad47c61 (1.1.0) kept these dirs hidden so that one session's staged files would not show up in another session's sandbox. With this change, every sandbox of a profile can read that profile's staged chat input. Other profiles' homes stay hidden. That is the access the docker backend already gives (core mounts the same dirs read-only), and without it attachments do not work at all under bubblewrap. attachments.storage: workspace is still available for anyone who wants per-workspace staging.

Tests (real bwrap, both HERMES_HOME layouts):

  • test_a_chat_attachment_staged_in_the_hermes_home_is_readable_not_writable: the file is staged after the sandbox is built. cat and ShellFileOperations.read_file see it, a write into the dir fails, and HERMES_HOME/.env stays hidden. Fails on main in both layouts (2 failed).
  • test_a_staging_dir_linked_into_the_rest_of_the_hermes_home_is_not_bound: attachments -> HERMES_HOME/sessions does not expose the transcripts.
  • The existing listing, signature and "cached data hidden" tests are updated to the new visible set.

Plugin suite on core v0.23.2: 621 passed, 1 skipped (local real bwrap 0.11.1; base: 617 passed, 1 skipped). Version 1.5.2.

Note: on core main (502009cc) the plugin suite already fails 148 tests before and after this PR. Core changed BaseEnvironment._wrap_command(..., cwd_fallback=) and removed LocalEnvironment._recover_cwd (core 8f95f721 / e979ba31), so BubblewrapEnvironment breaks on every command there. That needs a separate fix.

…he agent can open what the user attached

Hermes stages file.attach uploads, pasted images and large Desktop pastes
under HERMES_HOME/{attachments,images,composer-pastes} and names the staged
file by its host path in the prompt (@file:). The sandbox hid HERMES_HOME
whole, so any attachment too large or binary to inline pointed at a path
that did not exist inside the sandbox, for terminal commands and file tools
alike, and an operator bind could not bring it back.

Each staging dir is now made if missing (as core does for docker) and bound
read-only at its own path among the late mounts, through the same bind
guard as the scratch dir: a staging dir that is a link into the rest of the
Hermes home or into a writable dir is refused with one warning. Read-only,
so a command cannot plant a file a later turn takes for an upload. The rest
of HERMES_HOME (config, .env, sessions, platform document caches) stays
hidden.

Version 1.5.2.

Fixes #430
@teknium1

Copy link
Copy Markdown
Contributor Author

Landed on main via #451 (tip 0beeecd). To get it now: hermes plugins install NousResearch/hermes-official-plugins#<plugin> --force; hermes plugins update follows once the catalog pin moves (in progress).

@teknium1 teknium1 closed this Nov 20, 2026
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.

[bubblewrap] Chat attachments staged in HERMES_HOME/attachments are invisible inside the sandbox

1 participant