advanced27 min studyLesson 345 in Engineering

Capabilities: remove authority from the right sets at the right time

Distinguish effective, permitted, inheritable, bounding, and ambient capability sets and verify the final post-exec privilege state.

On this page

What you’ll understand

  • Explain the distinct roles and subset invariants of Linux capability sets.
  • Show why removing a bounding-set bit does not immediately clear an effective capability.
  • Plan privilege reduction without dropping setup authority too early or assuming no_new_privs removes existing privileges.

A container capability configuration is not one bag of root-like powers. Linux maintains several per-thread sets with different roles during permission checks and exec transitions. A workload can still hold an effective capability after its bounding set was reduced, while an ambient capability can survive an ordinary nonprivileged exec under its rules. We focus on the Linux 6.12 set relationships and OCI Runtime Specification v1.3.0 fields. Securebits, UID transitions, file capabilities, and user namespaces can alter the complete transition, so a final audit must observe the actual executed workload.

Name each set before changing it

The effective set supplies capabilities used for relevant permission checks. The permitted set bounds what the thread can make effective through the allowed operations. The inheritable set participates in exec capability derivation, while the bounding set limits certain capabilities gained through executable file capabilities. Ambient capabilities support carrying selected authority across a nonprivileged exec and must remain within both permitted and inheritable sets. These roles cannot be summarized accurately by counting how many capability names appear in a configuration file.

Capability checks also occur in a user-namespace context. A capability held in a child namespace does not automatically satisfy an initial-namespace check. Some capabilities are broad and cover many operations, while others are narrower; least privilege means reviewing required actions, not merely minimizing a numeric count. Inspect supported capability names on the actual kernel and runtime, because the available set has expanded over time. A runtime's accepted schema is not evidence that an impossible privilege was successfully granted.

E⊆P,A⊆P∩IE\subseteq P,\qquad A\subseteq P\cap I
E, P, I, and A denote effective, permitted, inheritable, and ambient capability sets for one thread under the documented Linux invariants. Set elements are capability identities, not interchangeable privilege units. This does not state a universal subset relation between effective and bounding sets.↔ Scroll wide equations horizontally.

Irreversible reduction needs a dependency order

Dropping a bit from the bounding set changes a future-gain restriction; it does not automatically erase the bit from the thread's existing permitted or effective sets. Dropping from permitted can be irreversible for that running thread under the applicable rules, and adjusting the bounding set itself requires the appropriate authority. Therefore a setup process must finish operations such as configuring groups, changing IDs, preparing mounts, or dropping bounding bits before discarding the capabilities those operations need. The correct sequence depends on the runtime's user-namespace and securebits design.

Clear unwanted ambient and inheritable state as part of the final policy, then verify permitted and effective sets after the intended UID and exec transitions. no_new_privs prevents exec from granting additional privileges under its contract and is inherited; once set, it cannot simply be unset by the task. It does not remove capabilities already held, close a privileged descriptor, or make current filesystem access harmless. Treat it as one constraint on future transitions, not a replacement for actively reducing existing authority.

B′=B∖D⟹̸E′=E∖DB'=B\setminus D\quad\not\Longrightarrow\quad E'=E\setminus D
B is the bounding set and D the dropped capability identities. A bounding-set drop alone does not perform the separate effective-set change shown on the right. This logical distinction concerns Linux capability operations; all quantities are sets without physical units.↔ Scroll wide equations horizontally.

Audit transitions rather than trust startup intent

Record the intended capability sets at setup, before exec, and in the actual application. Include supplementary groups, no_new_privs, securebits where relevant, and user-namespace identity. Test that a required narrow operation succeeds and an unrelated operation remains denied under the same mount and LSM context. A failed privileged operation alone does not identify which layer denied it. A broad runtime flag can restore several mechanisms at once and obscure the minimal permission actually required.

The probability lab illustrates why sampled permission tests do not prove a complete privilege policy. Reset, explicitly set p=0.20 and n=5, interpret success as detecting a hypothetical unwanted authority path, predict the zero-success bar, then Play or Step. For another independent toy run Reset and explicitly set p=0.20 and n=10. These assumed independent detections are not kernel capability checks. The lab neither represents the five sets nor validates exec transitions; inspect actual identities and set membership for that evidence.

A bounding drop is not an effective drop

In an illustrative permitted setup, bounding set B has five capability identities. Effective and permitted sets each contain three of them. The final policy needs only one of those three. Assume the process still holds the authority needed to change the relevant sets.

  1. Removing four unwanted identities from the bounding set leaves one bounding identity. By itself this operation does not clear the already held effective and permitted identities, so their counts can still be three.

  2. Complete required setup operations before removing their needed authority. Then explicitly reduce effective and permitted sets to the one required identity, and remove unwanted inheritable and ambient membership under the runtime's valid sequence.

  3. Inspect the application's post-exec state. A one-element bounding set is not sufficient evidence that effective authority is one element, and one retained identity is not automatically a suitably narrow privilege without reviewing what it permits.

The result

Different sets require different transitions and evidence. Dropping future-gain permission is not the same operation as removing authority already active in the thread.

Explore the model

Interactive lab

Interactive lab · probability

Passing permission samples is not a set audit

For separate hypothetical detection runs use Reset → explicitly set both p and n → predict → Play or Step. Compare (0.20,5) with Reset plus (0.20,10). The model assumes independent detection trials; it has no capabilities, exec, securebits, user namespaces, or no_new_privs.

Passing permission samples is not a set auditThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA successful sampled test does not establish every privilege transition. Inspect the actual post-exec capability identities and relevant constraints.

Check your understanding

A setup process drops a capability from its bounding set while it remains in its effective and permitted sets. What follows from that drop alone?

Try it yourself

A policy starts with eight bounding identities and removes six, while an audit still observes four effective identities. Is the observation necessarily inconsistent? What must be checked before declaring the final process reduced to two privileges?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Do not impose a universal effective-subset-of-bounding relation. Follow the actual set changes and exec transition.

Compare with the solution

The observation is not inherently inconsistent: a bounding drop does not immediately remove capabilities already effective. Inspect which four identities remain, their permitted membership, inheritable and ambient state, and the intended final post-exec credentials. Explicitly apply the valid final reduction rather than inferring it from the two remaining bounding bits. Also examine user-namespace context, no_new_privs, supplementary groups, file capabilities, and existing privileged object references relevant to the intended authority boundary.

Take it with you

  • Capability sets have different current-check and exec-transition roles.
  • Reduce privileges in an order that preserves only the setup dependencies still needed.
  • no_new_privs constrains future exec gains but does not erase existing authority.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.