Skip to content

fix: isolate workspace tmp directories#3

Open
ayomidelog wants to merge 1 commit into
mainfrom
fix/workspace-tmp-isolation
Open

fix: isolate workspace tmp directories#3
ayomidelog wants to merge 1 commit into
mainfrom
fix/workspace-tmp-isolation

Conversation

@ayomidelog

Copy link
Copy Markdown
Owner

Summary

This PR fixes workspace /tmp isolation.

Before this change, workspaces had isolated /home mounts but still shared the same /tmp inherited from the sandbox rootfs. That meant one workspace could observe temporary files created by another workspace inside the same sandbox.

This PR gives each workspace its own private /tmp tmpfs during session bootstrap.

Problem

The current runtime model isolates:

  • user namespace
  • PID namespace
  • mount namespace
  • network namespace
  • /home

But /tmp was still coming from the shared sandbox rootfs, so it behaved like shared sandbox state rather than per-workspace runtime state.

In practice, that meant:

  • a file created in /tmp by workspace A could be visible in workspace B
  • temporary data was not isolated to a single workspace
  • /tmp semantics did not match expected workspace isolation

What Changed

Per-workspace /tmp tmpfs mount

During workspace bootstrap, Enclave now mounts a private tmpfs at /tmp for each workspace session.

The mount is configured with the expected temporary-directory semantics:

  • private to the workspace runtime
  • sticky-bit permissions (mode=1777)
  • not shared through the sandbox rootfs

This change is separate from the existing runtime tmpfs mounts used for:

  • /run/enclave/auth
  • /run/enclave/env

User-Facing Impact

After this change:

  • workspaces no longer share /tmp
  • temporary files created in one workspace stay private to that workspace
  • /tmp now behaves more like users expect from an isolated workspace environment

Tests Added

Added a root integration test:

  • start two workspaces inside the same sandbox
  • write a file into /tmp from workspace A
  • verify workspace B cannot see that file

This is implemented as:

  • integration::tmp_isolation::workspaces_do_not_share_tmp_directory_contents

Verification

Build and static checks

  • cargo clippy --all-targets -- -D warnings

Default test suite

  • cargo test --all-targets -- --skip integration:: --skip stress::

Root integration validation

  • sudo env ... cargo test --test integration_suite -- --ignored --test-threads=1

The new tmp-isolation integration test passed. A later failure in the same ignored suite was due to an unrelated stale host-side veth collision during another network-heavy integration test, not due to the /tmp isolation change itself.

Why This Matters

/tmp is runtime state, not shared base-environment state.

If workspaces are meant to be isolated execution contexts, they should not be able to observe each other's temporary files just because they share a sandbox rootfs. This PR closes that gap and makes workspace filesystem behavior more coherent.

Mount a private tmpfs on /tmp for each workspace session so temporary files are no longer shared through the sandbox rootfs.

Before this change, workspaces had isolated /home mounts but still inherited the same /tmp from the shared sandbox rootfs. That allowed one workspace to observe temporary files created by another workspace, which breaks expected workspace isolation semantics.

The workspace bootstrap path now mounts a per-workspace tmpfs at /tmp with the expected sticky-bit permissions, while keeping the existing runtime tmpfs mounts for /run/enclave/auth and /run/enclave/env.

Add an ignored root integration test that starts two workspaces in the same sandbox, writes a file into /tmp in one workspace, and verifies that the second workspace cannot see it.

Verification:

- cargo test --all-targets -- --skip integration:: --skip stress::

- cargo clippy --all-targets -- -D warnings

- sudo env ... cargo test --test integration_suite -- --ignored --test-threads=1 (the new tmp isolation test passed before an unrelated stale-veth host-network collision later in the suite)
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