Skip to content

[Go 1.24] version >=v2.2 fails to create containers from images having /etc symlinked to an absolute path #13382

Closed

Description

@jasonjoo2010

Description

The openUserFile function in pkg/oci/spec_opts.go fails to resolve absolute symlinks on intermediate directory components when looking up /etc/passwd or /etc/group in a container's rootfs.

A previous fix (#12732, #12683, commit 85b5418) addressed the case where the target file itself (e.g., /etc/passwd) is an absolute symlink (common on NixOS, where /etc/passwd -> /nix/store/abcd/passwd). However, that fix only called ReadLink on the final path and did not walk intermediate directory components. This means rootfs layouts where an intermediate folder is a symlink — such as /etc -> /system/etc (common on Android emulator images) — are still broken. The openUserFile call fails with a "path escapes from parent" error or simply cannot find the file.

Steps to reproduce the issue

  1. Create a container image with a rootfs where /etc is an absolute symlink to /system/etc:
    /system/etc/passwd   (regular file)
    /etc -> /system/etc  (absolute symlink)
    
  2. Run the container with containerd using Go 1.24+.
  3. Any operation that triggers user/group lookup (e.g., WithUser, WithUserID, WithUsername, WithAdditionalGIDs) will attempt to open etc/passwd via openUserFile.

Describe the results you received and expected

Received: openUserFile fails to open etc/passwd because it only checks whether etc/passwd itself is a symlink. Since etc/passwd is not a symlink (only etc is), the ReadLink call returns an error and the function falls through, returning the original "path escapes from parent" error.

Expected: openUserFile should resolve symlinks at every component of the path. When walking etc/passwd, it should detect that etc is a symlink to /system/etc, re-anchor it to system/etc relative to the rootfs, and then open system/etc/passwd successfully.

What version of containerd are you using?

2.2.x

Any other relevant information

No response

Show configuration if it is related to CRI plugin.

No response

Activity

  1. jasonjoo2010 commented on Jun 23, 2026

    @jasonjoo2010
    Author

    Hi @fuweid
    Saw you worked on previous relevant change for this bug, could you take a look for the following fix as well?
    Thanks

  2. self-assigned this
    on Jul 17, 2026
  3. jasonjoo2010 commented on Aug 19, 2026

    @jasonjoo2010
    Author

    Hi @fuweid

    Is there any merging window that we can expect? I saw the MR has been approved by 1 reviewer but still needs 1 more.

    Thanks

  4. fuweid commented on Sep 3, 2026

    @fuweid
    Member

    Hi @jasonjoo2010 the change has been backported to 2.2 and 2.3. Please checkout the new releases (probably today). Thanks

  5. jasonjoo2010 commented on Sep 3, 2026

    @jasonjoo2010
    Author

    Hi @jasonjoo2010 the change has been backported to 2.2 and 2.3. Please checkout the new releases (probably today). Thanks

    Awesome, that's great news! We will test it once it's released, thank you for walking through it, @fuweid !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions