Skip to content

net: seal inherited fds before executing pasta - #297

Open
soul-sol wants to merge 1 commit into
google:masterfrom
soul-sol:harden-pasta-fd-inheritance
Open

net: seal inherited fds before executing pasta#297
soul-sol wants to merge 1 commit into
google:masterfrom
soul-sol:harden-pasta-fd-inheritance

Conversation

@soul-sol

Copy link
Copy Markdown

Summary

  • fall back to enumerating /proc/self/fd when close_range(CLOSE_RANGE_CLOEXEC) is unavailable
  • mark every descriptor above stderr close-on-exec before launching the pasta helper
  • abort helper execution if neither sealing method succeeds

Security rationale

pastaProcess() previously ignored the result of util::makeRangeCOE(). On kernels without
close_range(), or when an outer seccomp policy denies it, non-CLOEXEC descriptors inherited
by nsjail could survive into the external pasta helper. Those descriptors can expose files,
directories, sockets, or other parent-process capabilities outside the intended jail boundary.

This is separate from #275: that change constrains how the helper executable and environment are
selected, while this change prevents unrelated parent descriptors from crossing the helper
execve.

Validation

  • reproduced on current master with fd 123 open on a sentinel file and an outer seccomp filter
    returning ENOSYS for close_range; a test helper read the sentinel before this patch
  • repeated the same fault-injection test after the patch; the helper executed but fd 123 was absent
  • verified the normal close_range() path also executes the helper without fd 123
  • unmounted /proc while denying close_range() and confirmed nsjail fails closed without
    executing the helper
  • clean Linux build with make clean && make -j2
  • basic /bin/true and /bin/false jail smoke tests
  • git diff --check

Signed-off-by: solim <7576268+soul-sol@users.noreply.github.com>
@google-cla

google-cla Bot commented Jul 28, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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