Skip to content

Commit 1dc253d

Browse files
committed
test(ci): add rootless capability regression test on ubuntu-24.04
Run supervisor capability unit tests on a bare GHA ubuntu-24.04 runner as an unprivileged user, where CAP_SETPCAP is unavailable and the bounding set is non-empty. This exercises the EPERM + non-empty path that caused the #2069 crash. Update architecture/sandbox.md to describe the degraded rootless mode and its reliance on seccomp when the bounding set cannot be cleared. Refs: #2069 Signed-off-by: Wayne Sun <[email protected]>
1 parent 8ee29c1 commit 1dc253d

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

‎.github/workflows/branch-checks.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,35 @@ jobs:
172172
- name: Test
173173
run: mise run test:python
174174

175+
rootless-caps:
176+
name: Rootless capability tests
177+
needs: pr_metadata
178+
if: needs.pr_metadata.outputs.should_run == 'true'
179+
runs-on: ubuntu-24.04
180+
steps:
181+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
182+
183+
- uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # v1
184+
with:
185+
toolchain: "1.95.0"
186+
187+
- name: Run supervisor capability tests without CAP_SETPCAP
188+
run: |
189+
sudo useradd -m testuser
190+
sudo chmod a+rx /home/runner /home/runner/work /home/runner/work/OpenShell
191+
sudo chmod -R a+rX "$GITHUB_WORKSPACE"
192+
sudo cp -r /home/runner/.rustup /home/testuser/.rustup
193+
sudo chown -R testuser: /home/testuser/.rustup
194+
sudo mkdir -p /home/testuser/.cargo
195+
sudo cp /home/runner/.cargo/config.toml /home/testuser/.cargo/ 2>/dev/null || true
196+
sudo chown -R testuser: /home/testuser/.cargo
197+
sudo -u testuser env \
198+
PATH="/home/testuser/.cargo/bin:/home/testuser/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin:$PATH" \
199+
CARGO_HOME="/home/testuser/.cargo" \
200+
RUSTUP_HOME="/home/testuser/.rustup" \
201+
CARGO_TARGET_DIR="/home/testuser/target" \
202+
bash -c "cd $GITHUB_WORKSPACE && cargo test -p openshell-supervisor-process --lib -- capability_bounding drop_privileges"
203+
175204
markdown:
176205
name: Markdown
177206
needs: pr_metadata

‎architecture/sandbox.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ Each sandbox workload has two trust levels:
1616
The supervisor keeps enough privilege to manage the sandbox, but the agent child
1717
loses that privilege before user code runs. On Linux, child setup clears the
1818
capability bounding set during privilege drop so later execs cannot regain
19-
container-granted capabilities. This is fail-closed: the supervisor retains
20-
`CAP_SETPCAP` solely to perform the clear, and spawning the workload or SSH shell
21-
aborts unless the bounding set ends up empty. A `setpcap` `EPERM` is tolerated
22-
only when the set is already empty; any other outcome fails the spawn.
19+
container-granted capabilities. When `CAP_SETPCAP` is available, this is
20+
fail-closed: the supervisor clears the bounding set and aborts if capabilities
21+
remain. When `CAP_SETPCAP` is unavailable (rootless Podman with AppArmor
22+
user-namespace restrictions, or similar environments), the supervisor logs a
23+
warning, emits an OCSF `DetectionFinding` alert, and continues with the
24+
bounding set intact. In this degraded mode the child process relies on seccomp
25+
to block dangerous syscalls; Landlock filesystem restrictions are applied
26+
independently and may also be active.
2327

2428
## Startup Flow
2529

0 commit comments

Comments
 (0)