Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#2,920 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@jiayimeow ya está trabajando en esto.

Desde el 20/10/2026.

  • #2999 de @jiayimeow — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
backend, security

Línea de trabajo

Empieza por guestVolumeSource en internal/ocispec/microvm.go e inspecciona cómo su comparación de prefijos y path.Join gestionan las rutas relativas que contienen ... Añade una validación que mantenga las rutas asignadas dentro del recurso compartido del invitado y rechace un prefijo de staging vacío. Revisa las pruebas existentes para ShapeMicroVM o guestVolumeSource y añade cobertura para la traversal y las rutas staged válidas; el trabajo estará terminado cuando se rechace la traversal y las rutas válidas sigan asignándose correctamente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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. ../)
Lenguaje dominante
Go
Estrellas
5.7k
Forks
612
Merge medio
2 d 14 h
PR fusionados (30 d)
533

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de agent-substrate/substrate

Todos los issues de agent-substrate/substrate

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.