Skip to content

Guard against nil Root in apparmor check#811

Open
arpitjain099 wants to merge 1 commit into
opencontainers:masterfrom
arpitjain099:fix-apparmor-nil-root
Open

Guard against nil Root in apparmor check#811
arpitjain099 wants to merge 1 commit into
opencontainers:masterfrom
arpitjain099:fix-apparmor-nil-root

Conversation

@arpitjain099

Copy link
Copy Markdown

CheckProcess builds the apparmor profile path from v.spec.Root.Path whenever a process sets apparmorProfile, but root is optional in the OCI runtime spec. Running oci-runtime-tool validate on a config.json that has process.apparmorProfile and no root panics with a nil pointer dereference instead of returning a validation result.

The sibling check a few lines up (the executable-in-rootfs check on the Args path) already guards this case with v.spec.Root != nil before touching Root.Path. This applies the same guard to the apparmor branch, so the profile-path check is skipped when there is no root to resolve it against, matching the existing behavior on the Args path.

Added a TestCheckProcess case with apparmorProfile set and no root. Before the guard it panics:

--- FAIL: TestCheckProcess (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation]

With the guard it passes. gofmt -s and go vet ./validate/ are clean.

CheckProcess dereferences v.spec.Root.Path when a process sets
apparmorProfile, but root is optional in the runtime spec. A config with
process.apparmorProfile and no root makes oci-runtime-tool validate panic
with a nil pointer dereference.

The sibling executable-in-rootfs check on the Args path already guards
this with v.spec.Root != nil; apply the same guard here so the apparmor
check is skipped when there is no root to resolve the profile path
against.

Adds a CheckProcess case covering apparmorProfile with no root.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099
arpitjain099 requested a review from a team as a code owner July 23, 2026 16:43
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