Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

nvidia-cdi-hook chmod: adopt os.Root confinement like sibling hooks

Aperta
#2,147 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
security

Direzione di ricerca

Start with getPaths() in cmd/nvidia-cdi-hook/chmod/chmod.go, then compare its filesystem operations with the sibling hooks listed in the issue. Trace how run() invokes path resolution and preserve the existing skip behavior for missing or inaccessible paths. The work is done when chmod resolves and modifies paths through the confined root pattern rather than filepath.Join, os.Stat, and os.Chmod, while retaining current hook semantics.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

cmd/nvidia-cdi-hook/chmod/chmod.go (reviewed at tag v1.20.1) resolves its target
paths with plain string concatenation (filepath.Join(root, f)) and then calls
os.Stat (getPaths, chmod.go:143-147) and os.Chmod (run, chmod.go:131)
directly on the resulting string. Every other root-executed, filesystem-writing hook
in the same binary already confines its path resolution:

Hook Confinement
create-symlinks pathrs.OpenatInRoot / MkdirAllHandle (cyphar/filepath-securejoin/pathrs-lite)
enable-cuda-compat pathrs.OpenatInRoot + Openat(O_NOFOLLOW|O_EXCL) for writes
disable-device-node-modification os.OpenRoot
update-application-profile os.OpenRoot
update-ldcache pivot_root into the container root
chmod none — filepath.Join + os.Stat + os.Chmod

The chmod hook is the only hook in this family without root confinement, which makes
it structurally inconsistent with the hardening applied after CVE-2024-0132 /
CVE-2025-23359 / CVE-2026-24260.

Lab verification (no security issue observed)

To be explicit: I tested this end-to-end and found no currently-reachable security
problem.
In a real podman + crun pipeline (crun 1.30.1, toolkit v1.20.1, CDI spec
generated with --enable-hooks chmod and --path /dev/dri added to the hook args to
mirror the spec shape produced when a hooked folder is present):

  • A container image can carry an absolute symlink at /dev/dri via an ADD
    tarball (it survives into the image layer and the extracted rootfs; RUN ln -s
    does not survive, since build-time changes under /dev are not committed).
  • However, crun populates the container rootfs /dev with its own tmpfs before
    the createContainer hook runs, so the image-supplied symlink is not visible at
    hook time. The hook's own debug log confirms it skips the path:
    Skipping path ".../rootfs/dev/dri": stat ... no such file or directory.

So this is a defensive consistency request, not a vulnerability report. The
observed runtime behavior masks the issue; the request is to not rely on that
masking.

Request

Rework getPaths() to use the pattern the sibling hooks already use (the module
already pins go 1.26.0, so os.Root is available), e.g.:

root, err := os.OpenRoot(containerRoot)
if err != nil { return err }
defer root.Close()

for _, p := range paths {
    if _, err := root.Stat(p); errors.Is(err, fs.ErrNotExist) {
        continue
    }
    f, err := root.OpenFile(p, os.O_RDONLY, 0)
    if err != nil { /* skip, as today */ }
    if err := f.Chmod(mode); err != nil { /* skip, as today */ }
    f.Close()
}

This makes the hook robust against the symlink-following class of bugs by
construction, instead of relying on the runtime's /dev tmpfs masking, and keeps
this file consistent with the rest of the hook family.

Notes

  • The hook is marked deprecated; simply removing it would also resolve the
    inconsistency.
  • --mode 755 and the hooked-folder allowlist (/dev/dri, /dev/nvidia-caps) are
    hardcoded in the generator (pkg/nvcdi/workarounds-device-folder-permissions.go),
    so the current blast radius is narrow — another reason this is a consistency ask
    rather than a security fix.
Lingua principale
Go
Stelle
4.6k
Fork
605
Merge medio
7g 15h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/nvidia-container-toolkit

Tutte le issue di NVIDIA/nvidia-container-toolkit

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.