Skip to content

Allow actors to opt in/out of Linux capabilities - #795

Open
Noureldin (nmn3m) wants to merge 7 commits into
agent-substrate:mainfrom
nmn3m:actor-capabilities
Open

Allow actors to opt in/out of Linux capabilities#795
Noureldin (nmn3m) wants to merge 7 commits into
agent-substrate:mainfrom
nmn3m:actor-capabilities

Conversation

@nmn3m

Copy link
Copy Markdown

Fixes #744

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add an e2e test for this, for both uVM and gvisor? plumbing it is one thing, making sure it is effective is another, atelet doesn't actually spawn the containers

Comment thread .github/workflows/pr-workflow.yaml Outdated
@@ -110,6 +110,14 @@ jobs:
E2E_TEMPLATE_NAME: counter-microvm
E2E_TEMPLATE_READY_TIMEOUT: 600s
run: hack/run-e2e-kind.sh ./internal/e2e/suites/demo -v -args --no-color

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should expand this to run the whole default suite instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to drop me a ping in the slack for follow-up when these are fixed / PR is rebased and I'll try to come back to this faster, thanks!

Comment thread cmd/atelet/oci.go Outdated
},
Bounding: capabilities,
Effective: capabilities,
Inheritable: capabilities,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – Leave Inheritable empty. It was harmless when this was three fixed, innocuous capabilities; now a template can put SYS_ADMIN, DAC_OVERRIDE, or SETUID there.

Inheritable grants the process itself nothing. It only takes effect on execve, ANDed with the file's own inheritable set — which is why containerd dropped it in the fix for CVE-2022-24769, and why CRI-O and Docker set it empty too. The exposure is a container that starts as root and then drops to an unprivileged uid (su, gosu, a setuid binary) before exec'ing something with file capabilities.

Removing it costs nothing here. The spec pins User{UID: 0, GID: 0}, and for a real-uid-0 process exec'ing a file with no file capabilities the kernel treats F(permitted) and F(inheritable) as all-ones, so P'(permitted) = P(bounding). Propagation to children rides on Bounding, not Inheritable.

The capabilities e2e already asserts only bounding, effective, permitted and an empty ambient, so it would not need to change — TestBuildActorOCISpecCapabilities in oci_test.go would.

Comment thread docs/api-guide.md Outdated

### Container Capabilities (`securityContext.capabilities`)

Each container runs with a default set of Linux capabilities. `securityContext.capabilities` adjusts that set, mirroring `securityContext.capabilities` on a Kubernetes Pod container.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – Worth naming the default set here. A reader writing add needs to know what they already have, and one writing drop needs it even more — right now the only way to find out is to read defaultCapabilities in cmd/atelet/oci.go. It is three entries: AUDIT_WRITE, KILL, NET_BIND_SERVICE.

@BenTheElder

Copy link
Copy Markdown
Collaborator

And sorry for the delay, the incoming PR volume is high 😅

@nmn3m

Copy link
Copy Markdown
Author

Benjamin Elder (@BenTheElder) TestActorCapabilities passed on gVisor (24.75s, both subtests), but the overall run failed on two tests. I’m not sure how to interpret the failures. Could you take a look and share your feedback?

I also ran make test locally, and it passed, so I’m not sure what’s causing the difference.

@BenTheElder

Benjamin Elder (BenTheElder) commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

You can search the logs for --- fail (go test output format) in github to find the actual failures, also rebasing on main picks up fixes (we might do #1029)

TestMakeCert failed in unit tests and a couple tests failed in gvisor, they look unrelated, I'm rerunning

@BenTheElder Benjamin Elder (BenTheElder) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, needs a rebase (couldn't merge before due to flaking tests it seems, rebase on main should help with that as well)

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.

Allow actors to opt-in/out of Linux capabilities

2 participants