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

[Low] guestVolumeSource can map host paths containing ".." outside the microVM guest share

Aperta Adatta ai principianti
#2,920 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend, security

Direzione di ricerca

Inizia da guestVolumeSource in internal/ocispec/microvm.go ed esamina come la corrispondenza dei prefissi e path.Join gestiscono i percorsi relativi che contengono ... Aggiungi una convalida che mantenga i percorsi mappati all’interno della condivisione del guest e rifiuti un prefisso di staging vuoto. Controlla i test esistenti per ShapeMicroVM o guestVolumeSource, quindi aggiungi casi per il traversal e i percorsi staged validi; il lavoro è completato quando il traversal viene rifiutato e i percorsi validi continuano a essere mappati correttamente.

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

Descrizione

area/security kind/bug

Summary

In internal/ocispec/microvm.go, guestVolumeSource translates host volume bind mount sources into in-guest paths under GuestSharedDir using strings.CutPrefix followed by path.Join. It does not validate that the prefix is non-empty or check whether the trimmed relative path contains .. traversal segments, allowing paths to escape GuestSharedDir.

Details

In internal/ocispec/microvm.go#L124-L136:

func guestVolumeSource(hostPath string, actorDirs *ateworkerpb.ActorDirs, containerName string) (string, error) {
	for _, staged := range []struct{ host, guest string }{
		{actorDirs.GetDurableDirVolumeMountsDir(), path.Join(GuestSharedDir, ShareDurable)},
		{actorDirs.GetExternalVolumeMountsDir(), path.Join(GuestSharedDir, ShareCSI)},
		{actorDirs.GetSystemInfoVolumeRootsDir(), path.Join(GuestSharedDir, ShareSystemInfo)},
		{imagecache.ImageVolumeMountPath(filepath.Join(actorDirs.GetOciBundleDir(), containerName), ""), path.Join(GuestSharedDir, GuestContainerID(containerName), ShareVolumes)},
	} {
		if rel, ok := strings.CutPrefix(hostPath, staged.host+"/"); ok {
			return path.Join(staged.guest, rel), nil
		}
	}
	return "", fmt.Errorf("host path %q is not staged into the guest share", hostPath)
}

Because path.Join performs lexical path resolution via path.Clean, passing a hostPath such as staged.host + "/../../../../../dev/vda" succeeds in strings.CutPrefix and cleans the joined path to /dev/vda, escaping GuestSharedDir (/run/kata-containers/shared/containers).

Impact

At the unit level, an unvalidated OCI spec passed to ShapeMicroVM can map host bind mounts to arbitrary guest device or filesystem nodes outside the virtio-fs shared directory. However, in production, ShapeMicroVM is only called by cmd/ateworker-microvm/run.go on specs generated by ocispec.Build. Volume and container names are validated as DNS-1123 labels (validate.ShortName), and host directory paths are validated as clean absolute paths (resources.ValidateActorDirs), preventing traversal sequences from reaching guestVolumeSource. The issue is therefore a defense-in-depth and hardening defect rather than an exploitable vulnerability.

Suggested fix

Validate that the relative path does not escape the target directory using filepath.Rel and filepath.IsLocal (or path.IsLocal), and verify that staged.host is non-empty before prefix matching.

Related

  • Closed issue #1436: SystemInfoVolumeSource accepts path traversal (e.g. ../)
Lingua principale
Go
Stelle
5k
Fork
563
Merge medio
2g 12h
PR unite (30g)
493

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 agent-substrate/substrate

Tutte le issue di agent-substrate/substrate

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.