Skip to content

Commit 9ab2fcb

Browse files
committed
test(ci): add rootless capability regression test on ubuntu-24.04
Add a rootless-caps job to branch-checks.yml that runs the supervisor capability bounding set and drop_privileges tests as an unprivileged user on ubuntu-24.04 where AppArmor restricts PR_CAPBSET_DROP. Update architecture/sandbox.md to describe the degraded rootless mode where seccomp provides confinement when the bounding set cannot be cleared. Signed-off-by: Wayne Sun <gsun@redhat.com>
1 parent db612b1 commit 9ab2fcb

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

.github/workflows/branch-checks.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,36 @@ 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: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
184+
with:
185+
toolchain: "1.95.0"
186+
cache: false
187+
188+
- name: Run supervisor capability tests without CAP_SETPCAP
189+
run: |
190+
sudo useradd -m testuser
191+
sudo chmod a+rx /home/runner /home/runner/work /home/runner/work/OpenShell
192+
sudo chmod -R a+rX "$GITHUB_WORKSPACE"
193+
sudo cp -r /home/runner/.rustup /home/testuser/.rustup
194+
sudo chown -R testuser: /home/testuser/.rustup
195+
sudo mkdir -p /home/testuser/.cargo
196+
sudo cp /home/runner/.cargo/config.toml /home/testuser/.cargo/ 2>/dev/null || true
197+
sudo chown -R testuser: /home/testuser/.cargo
198+
sudo -u testuser env \
199+
PATH="/home/testuser/.cargo/bin:/home/testuser/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin:$PATH" \
200+
CARGO_HOME="/home/testuser/.cargo" \
201+
RUSTUP_HOME="/home/testuser/.rustup" \
202+
CARGO_TARGET_DIR="/home/testuser/target" \
203+
bash -c "cd $GITHUB_WORKSPACE && cargo test -p openshell-supervisor-process --lib -- capability_bounding drop_privileges"
204+
175205
markdown:
176206
name: Markdown
177207
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)