Skip to content

fix(containment): permit waitid so a Go program can wait for its child - #447

Merged
opieter-aws merged 1 commit into
mainfrom
feature/seccomp-waitid
Nov 13, 2026
Merged

opieter-aws merged 1 commit into
mainfrom
feature/seccomp-waitid

Conversation

@opieter-aws

Copy link
Copy Markdown
Contributor

Description

In a box on Linux, any Go program that starts a child fails. gh pr create and gh pr status stop with failed to run git: waitid: operation not permitted. Go's os/exec calls waitid before it reaps the child with wait4, and the permit filter refuses waitid.

This change adds waitid to WORKLOAD_PERMITTED, unrestricted, like wait4.

  • What the operator gets: gh (and other Go tools) can run git and other children in a Linux box.
  • Why it is safe: the kernel limits waitid to the caller's own children, as it does wait4. Its P_PIDFD form takes a descriptor from pidfd_open, which the filter already permits. No reach is added.
  • Interfaces and premises: none change.
  • Decisions: none. The containment AGENTS.md records the measurement under "Waiting for a child".
  • Docs: crates/containment/AGENTS.md. No user page lists the permit table.

Related Issues

None.

Type of Change

Bug fix

Testing

Check Without the permit With the permit
a_child_is_awaited_with_waitid_under_the_filters (P_ALL + WNOHANG, P_PIDFD, P_PID) fails, code 10 (EPERM) passes
child_waits_are_permitted_and_unmediated fails passes
gh 2.103.3 in a box: gh pr create --dry-run --head <branch> waitid: operation not permitted exit 0, prints the PR it would open
gh in a box: gh pr status waitid: operation not permitted exit 0
gh in a box: gh repo view not run exit 0
  • The box runs were on ARM64 Amazon Linux 2023 (kernel 6.18), with staging-boxy main (1152aab) and its corpus-github profile, against strands-agents/staging-boxy. Nothing was written to GitHub.
  • "Without" is Box 70eb3afc (this PR's base). "With" is the same build patched to this branch.
  • cargo test, cargo clippy --all-targets and cargo fmt --check pass for strands-box-containment with --all-features.
  • Not run locally: x86-64. CI covers it.
  • No other Go tool that starts a child is on the test host, so only gh ran in a box. The unit test covers the waitid forms Go uses.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

The Linux permit filter refuses `waitid` with `EPERM`. Go's `os/exec` calls `waitid` before it
reaps a child with `wait4`, so every child of a Go program fails. In a box, `gh pr create` and
`gh pr status` stop with `failed to run git: waitid: operation not permitted`.

## Solution

Add `waitid` to `WORKLOAD_PERMITTED`, unrestricted, like `wait4`. The kernel limits both calls to
the caller's own children, and the `P_PIDFD` form takes a descriptor from the permitted
`pidfd_open`. No interface moves. The containment `AGENTS.md` records the measurement.

## Tests

- `a_child_is_awaited_with_waitid_under_the_filters` forks a child under the filters and waits for
  it with `P_ALL` and `WNOHANG`, `P_PIDFD`, and `P_PID`. Without the permit it fails with code 10.
- `child_waits_are_permitted_and_unmediated` checks that `wait4` and `waitid` are in the permit
  table and the compiled permit filter, and not in the restriction filter. Without the permit it
  fails.
- `cargo test -p strands-box-containment --all-features` passes on ARM64 Amazon Linux 2023.
  x86-64 did not run locally.
- In a box built by staging-boxy main with this Box, `gh` 2.103.3 runs `gh pr create --dry-run`,
  `gh pr status`, and `gh repo view` and exits 0. On Box `70eb3afc` the first two fail with the
  `waitid` error.
@github-actions

Copy link
Copy Markdown

Assessment: Approve

I found no correctness, scope, or premise issues in 09facd5. I traced each kind of waitid call a workload can make to the new permit. In every case the call either reaps the caller's own child or the kernel refuses it, so the permit gives no reach that wait4 does not already give.

Checked and held
  • Go os/exec (gh → git): waitid(P_PID, pid, WEXITED|WNOWAIT) followed by wait4 is now permitted, which fixes the reported failure.
  • Go's checkPidfd probe: waitid(P_PIDFD, own pidfd) now returns ECHILD instead of EPERM. Go's next probe, pidfd_send_signal, is still not in the permit table and gets EPERM, so Go falls back to the P_PID path. The pidfd path is not enabled halfway.
  • Pidfd or ID of a process that is not a child (pidfd_open(1) on the reaper, a sibling, or a CLONE_PIDFD descriptor): the kernel returns ECHILD. The permit doesn't depend on where the pidfd came from.
  • Waiting on a traced process: ptrace is still denied in MEDIATED, so waitid has the same reach as wait4.
  • Existing wait4 users (the reaper and the failure_tests.rs refusals): unchanged.
  • Rule in crates/containment/AGENTS.md, "A new syscall stays denied until measured evidence and a compatibility rationale justify its addition": met by the new "Waiting for a child" section. The permit table is pub(crate), so no frozen surface or foundational premise changes.
  • x86-64 (not run locally, per the description): I ran the three affected tests on x86_64 (kernel 7.0) and they pass. I also removed the permit-table entry as a check: a_child_is_awaited_with_waitid_under_the_filters then fails with code 10, so the test catches the regression.
  • Unrelated failures in my run: some namespace tests (reaper, authority, view, netns) fail on this runner. They fail the same way on origin/main, so the cause is the host's AppArmor restriction on unprivileged user namespaces, not this PR.

The fix is small, the test can fail when it should, and the measurement is recorded where the containment guide asks for it.

@opieter-aws
opieter-aws merged commit 004e29d into main Nov 13, 2026
23 checks passed
@opieter-aws
opieter-aws deleted the feature/seccomp-waitid branch November 13, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Agent Containment bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants