Skip to content

fix(security): remove privileged mode from gpu-feature-discovery #5646

Not planned

Description

@devops-cli-service

Split from #5640.

Problem: k8s/gpu-feature-discovery/daemonset.yaml runs the gpu-feature-discovery container with privileged: true. Trivy config reports KSV-0017 at HIGH for this file. The privileged mode gives the container access to NVIDIA GPU devices and sysfs. Why deferred: GFD v0.16.2 needs this access. A change to remove privileged: true now would break GPU feature discovery. The fix waits on an upstream GFD release that supports a non-privileged manifest, or on a device-mount design that keeps GPU access. Acceptance criteria: - The container runs with privileged: false. - The container sets allowPrivilegeEscalation: false and drops all capabilities. - The container keeps GPU device and sysfs access through a supported mechanism. - Trivy config reports no KSV-0017 finding for k8s/gpu-feature-discovery/daemonset.yaml. - The kustomization builds and the GPU feature discovery workload passes a smoke test on a GPU node.

Proposed design

Problem statement

k8s/gpu-feature-discovery/daemonset.yaml runs the gpu-feature-discovery container with privileged: true, and Trivy config reports KSV-0017 at HIGH for the file. The .trivyignore.yaml entry that hides the finding expires on 2026-11-21, so the finding returns. The manifest pins nvcr.io/nvidia/k8s-device-plugin:v0.20.2, while its version labels and the ignore statement still say v0.16.2. The change removes privileged mode and gives the container its GPU devices through the node's NVIDIA container runtime.

Acceptance criteria

Requirement: Non-privileged GFD container

The gpu-feature-discovery container SHALL set privileged: false, set allowPrivilegeEscalation: false and drop all capabilities, and the manifest SHALL keep only the kube-linter suppressions that still hold.

Scenario: kube-linter accepts the container security context

  • WHEN uv run devops ci --check --only k8s runs on the change
  • THEN The command reports no privileged-container, privilege-escalation-container or drop-all-capabilities finding for k8s/gpu-feature-discovery/daemonset.yaml

Requirement: GPU access without privileged mode

The container MUST keep NVIDIA GPU access with no privileged mode, through NVIDIA_VISIBLE_DEVICES=all, NVIDIA_DRIVER_CAPABILITIES=utility and the device injection of the node's NVIDIA container runtime.

Scenario: gpu-feature-discovery runs on a GPU node

  • WHEN The DaemonSet rolls out on the GPU nodes and kubectl rollout status daemonset/gpu-feature-discovery -n default --timeout=300s runs
  • THEN The command exits 0 and prints daemon set "gpu-feature-discovery" successfully rolled out, and kubectl logs -n default -l app.kubernetes.io/name=gpu-feature-discovery --tail=-1 shows no permission denied and no NVML error

Requirement: Kustomization renders

The change MUST keep the k8s/gpu-feature-discovery kustomization buildable.

Scenario: kustomize renders the DaemonSet

  • WHEN kubectl kustomize k8s/gpu-feature-discovery runs on the change
  • THEN The command exits 0 and prints one DaemonSet named gpu-feature-discovery

Requirement: Version labels match the image

The DaemonSet MUST set app.kubernetes.io/version to 0.20.2, the version of its image tag.

Scenario: kustomize renders the version label

  • WHEN kubectl kustomize k8s/gpu-feature-discovery runs on the change
  • THEN The command prints app.kubernetes.io/version: 0.20.2 in the DaemonSet metadata and in its pod template labels, and prints no 0.16.2

Requirement: KSV-0017 finding and entry are gone

The change MUST remove the KSV-0017 entry of .trivyignore.yaml, and the manifest MUST not trigger KSV-0017.

Scenario: IaC scan finds no KSV-0017

  • WHEN trivy config . runs on the change after the KSV-0017 entry is removed
  • THEN The command prints no KSV-0017 finding for k8s/gpu-feature-discovery/daemonset.yaml

Existing Tool Considered

No alternatives check has run. The open, maintained NVIDIA k8s-device-plugin project ships gpu-feature-discovery, the program this manifest runs, at the pinned v0.20.2. It covers GPU feature discovery and lacks only the device grant: its static manifest runs privileged. The change follows the NVIDIA GPU Operator, which runs gpu-feature-discovery with NVIDIA_VISIBLE_DEVICES=all and NVIDIA_DRIVER_CAPABILITIES=utility and lets the node's NVIDIA container runtime inject the devices. The change adds no code of its own, so it has no build cost.

Key questions

  • Which mechanism keeps NVIDIA GPU and sysfs access when the container drops privileged mode?: Set NVIDIA_VISIBLE_DEVICES=all and NVIDIA_DRIVER_CAPABILITIES=utility on the container, as the NVIDIA GPU Operator does for gpu-feature-discovery. The node's NVIDIA container runtime injects the /dev/nvidia* nodes and their device cgroup rules. NVML then works with no privileged mode and no nvidia.com/gpu allocation. Keep the /sys hostPath mount for the PCI labels. (best practice) [sources: k8s/gpu-feature-discovery/daemonset.yaml, k8s/README.md]
    • Chosen: Device injection of the NVIDIA container runtime (NVIDIA_VISIBLE_DEVICES=all, NVIDIA_DRIVER_CAPABILITIES=utility). The GPU Operator runs gpu-feature-discovery this way. The repository already runs the non-privileged GPU ollama tiers on the same nodes. It holds no GPU allocation and adds no code. If a node does not default to the NVIDIA runtime, the pod sets runtimeClassName: nvidia.
    • Rejected: Request nvidia.com/gpu: 1 in the DaemonSet. The request holds one GPU on each node, and it takes a GPU from the ollama tiers.
    • Rejected: Mount the /dev/nvidia* nodes with hostPath and no privileged mode. The runtime sets the device cgroup allow-list from the device injection or the device plugin, so the open of the nodes fails with permission denied.
    • Rejected: Wait for an upstream release with a non-privileged manifest. No such release is shown, and the KSV-0017 entry expires on 2026-11-21, so the finding returns before any release lands.
    • Rejected: Write a local device-injection design. It adds code that the project must keep and fix, and the runtime already gives the devices.
  • Which gpu-feature-discovery version does the manifest run?: The image is nvcr.io/nvidia/k8s-device-plugin:v0.20.2. The app.kubernetes.io/version labels and the .trivyignore.yaml statements say 0.16.2, so they are stale. The change sets both version labels to 0.20.2 and removes the stale statement with its entry. [sources: k8s/gpu-feature-discovery/daemonset.yaml, .trivyignore.yaml]
  • Which kube-linter annotations does the change make untrue?: The privileged-container and privilege-escalation-container annotations become untrue, so the change removes them with the privileged setting. The run-as-non-root and sensitive-host-mounts annotations stay true, because the container still runs as root and still mounts host /sys. Their text names fix(security): remove privileged mode from gpu-feature-discovery #5646, so the change states their reason without the closed item. (best practice) [sources: k8s/gpu-feature-discovery/daemonset.yaml]
    • Chosen: Remove the two untrue annotations. An annotation that no finding needs hides the next regression of the same check. kube-linter reports the finding again if the setting returns.
    • Rejected: Keep all four annotations. The two privileged annotations would state a reason that the manifest no longer holds.
  • Does the change remove the KSV-0017 entry of .trivyignore.yaml?: Yes. The entry expires on 2026-11-21, so it hides nothing after that date. An entry that no finding needs hides the next regression of the same rule. ADR 0005 keeps each suppression to one reason and one expiry. (best practice) [sources: .trivyignore.yaml, docs/adr/0005-review-findings-come-from-tools-not-models.md]
    • Chosen: Remove the entry in this change. The manifest no longer triggers the rule, so the entry has no finding to hide.
    • Rejected: Let the entry expire. The expired entry stays in the file and the finding reopens with no owner.
    • Rejected: Keep the entry with a new expiry date. A suppression that hides nothing covers the next regression of the same rule.
  • Does the change also clear the KSV-0121 and KSV-0118 entries of this file?: No. The container still mounts host /sys for the PCI labels, and it still runs as root to write the NFD features file. Both entries stay with their annotations. This item removes privileged mode only. (best practice) [sources: k8s/gpu-feature-discovery/daemonset.yaml, .trivyignore.yaml]
    • Chosen: Keep both entries out of scope. The item fixes KSV-0017. Its acceptance criteria name no sysfs or root user change.
    • Rejected: Clear them in this change. Clearing KSV-0121 needs the /sys hostPath mount gone, and gpu-feature-discovery reads the PCI devices from it.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/security
    status/new
    value/high
    effort/medium
    on Nov 14, 2026
  2. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    ContributorAuthor
  3. dan-petty commented on Nov 17, 2026

    @dan-petty
    Owner

    The KSV-0017 entry for k8s/gpu-feature-discovery/daemonset.yaml in .trivyignore.yaml has expired_at: 2026-11-17, so Trivy no longer applies it from 2026-11-17 00:00 UTC. The KSV-0121 entry of the same file expires on 2026-11-18. CI run 43983603905 shows no failed security check for these entries, so the effect is a reopened Trivy-config alert in code scanning, not a red check. Found while working on #6079.

  4. dan-petty commented on Nov 17, 2026

    @dan-petty
    Owner

    Pull request #6112 (for #6068) runs kube-linter in CI. DaemonSet default/gpu-feature-discovery holds the annotations ignore-check.kube-linter.io/privileged-container, privilege-escalation-container, run-as-non-root and sensitive-host-mounts, each with the reason "until #5646". Remove each annotation that this item makes untrue. The missing NetworkPolicy of the pod is #6109.

  5. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: An upstream gpu-feature-discovery release that runs the container without privileged mode; the KSV-0017 suppression expires on 2026-11-17 and the code-scanning alert reopens from that date.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: k8s/gpu-feature-discovery/daemonset.yaml, .trivyignore.yaml.

  6. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: An upstream NVIDIA gpu-feature-discovery release that runs the container without privileged mode; the KSV-0017 ignore entry expires on 2026-11-21 and the code-scanning alert reopens from that date.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  8. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  9. dan-petty commented on Nov 25, 2026

    @dan-petty
    Owner

    gpu-feature-discovery is removed from the cluster and from deploy-stack (#7252). No workload runs this manifest any more.

    The Trivy findings stay open only because the copy k8s/gpu-feature-discovery/daemonset.yaml is still in this repository: the freeze check refuses a deletion until step 17 of #5134. The 3 ignore entries that name this item expire on 2026-11-26. After that the findings show again as alerts, and the daily alert job can file them again. Do not change the workload. Close this item and the findings on that path when step 17 deletes the file.

  10. dan-petty commented on Nov 26, 2026

    @dan-petty
    Owner

    Closed: no privileged gpu-feature-discovery pod is left to change.

    #7252 is complete, and dan-petty/homelab removed the DaemonSet (dan-petty/homelab#234). The copy in k8s/gpu-feature-discovery/ deploys nothing, and step 17 (#7290) deletes it. #5371 tracks the open privileged-mode alert 217 until it shows fixed.

  11. removed
    status/new
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/securitysource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions