Skip to content

Container ID of ".." can lead to removal of parent directory #2074

@kevinburke

Description

@kevinburke

If an untrusted party can cause a higher-level caller of crun to invoke it with a container identifier of "." or "..", this could cause crun to recursively delete files in a parent directory.

Summary

src/libcrun/status.c validates container IDs by rejecting /, but it does not reject . or ..:

  • src/libcrun/status.c:50

That ID is then joined into state paths with append_paths():

  • src/libcrun/status.c:111
  • src/libcrun/status.c:135

The dangerous sink is the delete path:

  • src/libcrun/status.c:583

libcrun_container_delete_status() opens the directory named by id relative to the runtime state root, then recursively deletes entries through rmdirfd():

  • src/libcrun/status.c:526

Because id=".." is accepted, crun can be directed to operate on the parent of the state directory rather than the container’s own state directory.

dfd = openat (rundir_dfd, id, O_DIRECTORY | O_RDONLY | O_CLOEXEC);

Impact

This becomes a filesystem traversal in a privileged cleanup path. In the worst
case, crun may:

  • recursively unlink entries outside the intended container state directory
  • attempt umount2(MNT_DETACH) on busy mountpoints encountered during cleanup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions