Skip to content

Restrict mount/pivot_root/userns to nsjail via AppArmor profile transition - #371

Draft
mertbozfakioglu wants to merge 3 commits into
mertbozfakioglu/seccomp-profile-generatorfrom
mertbozfakioglu/apparmor-nsjail-profile-transition
Draft

Restrict mount/pivot_root/userns to nsjail via AppArmor profile transition#371
mertbozfakioglu wants to merge 3 commits into
mertbozfakioglu/seccomp-profile-generatorfrom
mertbozfakioglu/apparmor-nsjail-profile-transition

Conversation

@mertbozfakioglu

@mertbozfakioglu mertbozfakioglu commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the broad retool-executor AppArmor profile with a two-profile design using a mandatory exec transition (px)
  • The container's main profile (retool-executor) no longer grants mount, pivot_root, umount, or userns — Node.js and all other processes in the container cannot call these syscalls
  • Only /usr/bin/nsjail gets these permissions, via automatic AppArmor profile transition to retool-executor//nsjail on exec
  • Removes the old standalone usr.bin.nsjail profile (which was flags=(unconfined), effectively unrestricted)

Before

retool-executor         → mount, pivot_root, userns (entire container)
/usr/bin/nsjail         → flags=(unconfined) (no restrictions at all)

After

retool-executor         → network, capability, file only (no mount/pivot_root/userns)
  └─ px on exec nsjail  → retool-executor//nsjail → adds mount, pivot_root, umount, userns

Stacked on

Test plan

  • Deploy to balloon instance with AppArmor profile installer enabled
  • Verify JS executor can run sandboxed code (nsjail gets elevated permissions via profile transition)
  • Verify that a direct mount() syscall from Node.js is denied by AppArmor

🤖 Generated with Claude Code

mertbozfakioglu commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5

The PR is not safe to merge until the AppArmor installer and integration tests are updated for the two-profile design.

The removed ConfigMap entry causes the installer to exit before loading profiles, which prevents executor pods from starting, and the repository's AppArmor integration test retains two assertions that directly contradict the new profile behavior.

Files Needing Attention: charts/retool/templates/apparmor_nsjail_configmap.yaml

Important Files Changed

Filename Overview
charts/retool/templates/apparmor_nsjail_configmap.yaml Introduces the scoped nsjail child profile, but removes an installer-required ConfigMap key and does not update integration tests for the new policy contract.

Reviews (1): Last reviewed commit: "Restrict mount/pivot_root/userns to nsja..." | Re-trigger Greptile

Comment thread charts/retool/templates/apparmor_nsjail_configmap.yaml
Comment thread charts/retool/templates/apparmor_nsjail_configmap.yaml
mertbozfakioglu and others added 3 commits September 11, 2026 10:51
…ition

Replace the broad retool-executor AppArmor profile (which granted mount,
pivot_root, umount, userns to the entire container) with a two-profile
design using a mandatory exec transition (px):

- retool-executor: container's main profile — network, capability, file
  only. No mount/pivot_root/userns. Node.js cannot call these directly.
- retool-executor//nsjail: child profile entered only when exec'ing
  /usr/bin/nsjail. Adds mount, pivot_root, umount, userns.

The old standalone usr.bin.nsjail profile (flags=unconfined) is removed
— nsjail now runs under the scoped child profile with the same deny
rules as the parent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove usr.bin.nsjail copy/load from DaemonSet — the child profile
  retool-executor//nsjail is defined inside the retool-executor entry
  and loaded by apparmor_parser together with it.
- Update test to check for retool-executor//nsjail in kernel instead of
  /usr/bin/nsjail.
- Flip the unshare assertion: under the parent profile, unshare --user
  --mount must now FAIL (mount/userns restricted to nsjail via px).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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