apko /etc/passwd and /etc/group UID/GID truncation writes package-supplied entries as root
What fixes it
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
apko allows users to build and publish OCI container images built from apk packages. From version 0.2.0 to before version 1.4.5, UserEntry.Parse and GroupEntry.Parse in pkg/passwd read the UID and GID fields of /etc/passwd and /etc/group entries with strconv.Atoi and convert them to uint32 without a range check. On 64-bit platforms an out-of-range value such as 4294967296 (2^32) is truncated to 0, and negative values wrap. Because apko parses the passwd and group entries supplied by the packages it installs and writes them back into the image, an attacker who controls a package installed into the image can ship an entry that appears to declare an unprivileged UID or GID but is written into the built image as UID 0 or GID 0 (root). The truncated UID is also used when resolving the image's run-as user. This issue has been fixed in version 1.4.5.
Text from CVE List
Affected versions 2
- apkoaffected: 0.2.0 before 1.4.5CVE List
- chainguard.dev/apko, go>= 0.2.0, < 1.4.5GitHub
References 4
- github.com/chainguard-dev/apko/pull/2516Fixvia CVE List
- github.com/chainguard-dev/apko/commit/739e7ce3f675ffb232e16849b51ff93657f1570cFixvia CVE List
- github.com/chainguard-dev/apko/releases/tag/v1.4.5Fixvia CVE List
- github.com/chainguard-dev/apko/security/advisories/GHSA-rj6x-hwpv-vhvfAdvisoryvia CVE List