Linux Security / Editorial solution guide
Diagnose a service write denied across access layers
Separate resource identity, credentials, DAC/ACL, service filesystem exposure, and mandatory-policy evidence.
Read-only knowledge base · No public comments
Recognize the symptoms
A report worker can read its public inputs but fails while creating a summary. A writable-path exception appears in the proposed unit, so the operator assumes AppArmor or permissions must be wrong. Preserve the exact nonsecret operation, intended resource, reviewed unit revision, and existing diagnostic category before changing any layer. A generic permission message does not uniquely identify the cause.
Understand the likely causes
- Possible causes include a different resolved object, stale process groups, missing directory traversal, DAC or ACL limits, a read-only service view, an underlying read-only filesystem, mandatory-policy denial, or application scope. A ReadWritePaths entry does not grant DAC access. Profile-file presence does not prove attachment or mode. These are competing hypotheses until actual approved evidence distinguishes them.
Identify the actual operation and trusted context
Distinguish opening an existing file, creating a name, replacing an output, and deleting a temporary item. Each can involve different parent-directory and policy checks. Record the service identity and namespace assumptions from approved existing evidence, not from a username string in a request. Do not run host permission queries, change accounts, or make a tree writable as an exploratory shortcut. This guide uses supplied synthetic facts only. If a required observation is absent, keep that boundary unverified and identify the accountable next question.
Keep independent denial facts and uncertainty visible
The program routes declared DAC, service-view, and mandatory-policy results in a fixed diagnostic order. That order is a classroom review convention, not the kernel’s complete access algorithm. An unknown fact returns a needs-evidence category rather than silently passing. A real operation can be denied by more than one layer, and correcting the first mismatch may reveal another. Preserve the source of each fact and compare it with the protected state. The program performs no file operation or policy probe; it only organizes already supplied booleans.
def review_write(facts):
for layer in ("dac", "serviceView", "mandatoryPolicy"):
if facts.get(layer) is None:
return "needs-evidence:" + layer
if facts[layer] is False:
return "review-denial:" + layer
return "review-application-and-object-outcome"
assert review_write({"dac":False, "serviceView":True, "mandatoryPolicy":True}) == "review-denial:dac"
assert review_write({"dac":True, "serviceView":True, "mandatoryPolicy":None}) == "needs-evidence:mandatoryPolicy"
print("declared denial and missing-evidence routes checked")
declared denial and missing-evidence routes checked
The complete program checks two local routing cases. It does not obtain the facts from Linux or determine a real root cause. The diagnostic markers are invented and should not be mistaken for exact system log messages.
Prepare the narrow correction and preserve the boundary
If approved evidence confirms a missing legitimate path or effective ACL mismatch, prepare a correction limited to that requirement. If the operation is forbidden by design, repair the caller rather than weakening the policy. Do not disable AppArmor globally, remove all service restrictions, or recursively broaden modes. Review loaded configuration, overrides, profile attachment, and process lifecycle separately from desired text. No such change is applied here. Include adjacent denied resources so the repair cannot pass merely by granting broad write authority.
Verify the fix
In a separately authorized disposable environment, verify the intended summary operation and benign denied alternatives with actual object/state observations. Confirm which layer supplied each denial and record exact versions and loaded policy. Do not claim success from a unit-file edit alone. This guide executes only the synthetic routing function; no service, account, mode, ACL, mount, profile, or file operation was run.
Keep it from recurring
- Keep a role-specific access matrix, separate desired/loaded/observed states, and retain positive and negative regressions. Document group-refresh and profile-lifecycle assumptions. A narrow diagnosis should preserve least privilege while making legitimate work possible, rather than turning every access error into a broad administrative exception.