Linux Security / Intermediate: service, policy, and lifecycle boundaries / Lesson 14
Verify a service authority contract
Compare declared and effective service authority using permitted and denied synthetic actions.
On this page
Lesson goals
- Define the resources a service needs.
- Compare configuration with effective process authority.
- Verify positive and negative lab actions.
Describe a service authority contract
A service’s least-privilege contract states which identity and resources it needs for a specific task. In this disposable Linux lab, a synthetic worker writes an output file in its own directory and has no reason to write an unrelated protected path. Record the service owner, unit configuration, intended user, groups, writable paths and recovery procedure before changing the lab. This is a teaching policy, not a recommendation to apply a generic configuration to a live host.
Compare declaration with the process
The configured service user is only one part of effective authority. Compare the running process identity, supplementary groups, capabilities, inherited resources and relevant sandbox settings with the approved lab contract. The first table names observations rather than commands or actual output. A process started before a configuration change may still reflect the previous setting. Record the process start time and relevant override sources, and protect environment values and credentials from diagnostic logs.
Setting | Declared | Effective observation
service user | lab-worker | inspect running process
write path | /lab/out | test synthetic write
The table is an illustrative lab model, not an executable command or result.
Test intended and unrelated actions
With synthetic files and accounts, test that the worker can perform its intended write and that a clearly unrelated protected path remains denied. Inspect the resulting file state as well as the returned error. The second table states the expected lab behavior; no operation is executed by reading it. If both writes succeed, the service task works but the least-privilege claim fails. If both fail, do not broaden access until the responsible boundary is identified.
Action | Expected
write /lab/out | permitted
write unrelated path | denied
The table is an illustrative lab model, not an executable command or result.
Investigate mismatches safely
Preserve the exact symptom and change one suspected lab setting at a time. Compare file permissions and ACLs with the service’s effective identity and mandatory policy, since different layers can independently deny access. If the declaration and running process differ, inspect unit overrides and lifecycle state before editing. Keep a separate lab recovery route and avoid commands or permission changes against a live service. Record unknown information rather than assuming it matches the baseline.
Verify and document the change
After an approved correction, verify the process identity and relevant effective restrictions again, then repeat both the intended and unrelated actions with fresh synthetic data. Record the unit and artifact references, test window and unexamined layers. A single positive write and denial support the specified lab scenario; they do not prove the service has no other excessive authority. Revisit the contract when its task, dependencies or inherited resources change.
Common errors and fixes
Trusting the configured user name alone
- Why it happens
- Groups, capabilities or an old process can change authority.
- How to fix it
- Inspect the effective process and relevant settings.
- Prevent it next time
- Verify runtime state after authorized changes.
Testing only the required write
- Why it happens
- Excessive unrelated access remains invisible.
- How to fix it
- Add a denied synthetic action.
- Prevent it next time
- Pair positive and negative cases.
Granting broad access after a denial
- Why it happens
- The responsible policy layer is unknown.
- How to fix it
- Restore the approved scope and inspect each layer.
- Prevent it next time
- Change one bounded lab input at a time.
2 practice exercises
1. The unit names lab-worker but the process started before the unit change. What should be checked?
Show worked solution
Compare the effective running identity and start time with the reviewed unit and overrides, then follow the lab’s authorized lifecycle procedure.
2. The intended write and an unrelated write both succeed. Is least privilege verified?
Show worked solution
No. Investigate the effective authority that allowed the unrelated write and correct the responsible boundary in the isolated lab.
Key takeaways
- A service declaration and effective process authority are distinct.
- Test needed and unrelated actions within an isolated lab.