Repository navigation
vendor: github.com/moby/sys/user v0.5.1 - #7508
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🔴 CRITICAL
One high-severity confirmed bug introduced by this PR requires attention before merging.
| gid: gid, | ||
| isNumeric: ok, | ||
| } | ||
| addtlGroups = append(addtlGroups, *groupArg) |
There was a problem hiding this comment.
[high] Nil pointer dereference in GetAdditionalGroups when an empty string is passed
The new implementation refactors GetAdditionalGroups to call parseGroupArg(ag) for each element of the additionalGroups slice. parseGroupArg is explicitly documented to return (nil, nil) when its input is an empty string:
// If name is empty, parseGroupArg returns "nil, nil" to indicate that no group
// argument was specified.
func parseGroupArg(name string) (*groupArg, error) {
if name == "" {
return nil, nil
}
// ...
}However, the calling code does not guard against the nil return before dereferencing:
groupArg, err := parseGroupArg(ag)
if err != nil {
return nil, err
}
addtlGroups = append(addtlGroups, *groupArg) // panics if groupArg == nilIf any element of additionalGroups is an empty string (e.g., from splitting a user-supplied group spec on a separator), this triggers a nil pointer dereference and panics at runtime.
The old code called parseNumeric(ag) directly and stored the result unconditionally — it never had this nil risk. The new code introduces the nil return path via parseGroupArg but omits the guard.
Fix: add a nil check before the dereference:
| addtlGroups = append(addtlGroups, *groupArg) | |
| groupArg, err := parseGroupArg(ag) | |
| if err != nil { | |
| return nil, err | |
| } | |
| if groupArg == nil { | |
| continue | |
| } | |
| addtlGroups = append(addtlGroups, *groupArg) |
| Confidence | Score |
|---|---|
| 🟢 strong | 100/100 |
There was a problem hiding this comment.
Yes; that's a known regression; a fix is being worked in here;
There was a problem hiding this comment.
Thanks for confirming! Good to know it's already being tracked and fixed in moby/sys#278. I'll leave this finding as-is for visibility since the vulnerable code is currently vendored in this PR.
|
|
||
| if gid != rgid { | ||
| rgid, err = toHost(gid, i.GIDMaps) | ||
| ruid, err := toHost(uid, i.UIDMaps) |
There was a problem hiding this comment.
[medium] ToHost semantic change: no longer short-circuits on the root-pair ID, may now return errors for IDs not in maps
The old ToHost implementation short-circuited for the root pair:
// OLD: skipped toHost() if uid/gid already matched the root pair
ruid, rgid := i.RootPair()
if uid != ruid {
ruid, err = toHost(uid, i.UIDMaps)
if err != nil {
return ruid, rgid, err
}
}
if gid != rgid {
rgid, err = toHost(gid, i.GIDMaps)
}The new implementation always calls toHost() for both IDs:
// NEW: always translates, no short-circuit
ruid, err := toHost(uid, i.UIDMaps)
if err != nil {
return -1, -1, err
}
rgid, err := toHost(gid, i.GIDMaps)
return ruid, rgid, errtoHost() returns an error when idMap is non-nil and the ID is not found in any mapped range. The old code would silently succeed for the root pair even when mappings were non-nil but didn't cover that specific ID; the new code will return an error in that case.
Impact: Any caller (in the Docker daemon) that relied on ToHost succeeding for the host-side root pair ID when non-nil maps are configured may now encounter unexpected "container ID %d cannot be mapped to a host ID" errors. This is worth verifying against all callers in github.com/docker/docker. The change may also be an intentional correctness improvement — the old short-circuit was arguably conflating host and container ID spaces.
| Confidence | Score |
|---|---|
| 🟡 moderate | 57/100 |
full diff: moby/sys@user/v0.4.1...user/v0.5.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Security This release includes fixes for unbounded reads when parsing user, group, and ID mapping files, which could lead to excessive resource consumption and denial of service. For details, see [CVE-2026-135844] / [GHSA-ffh6-8jcg-cjmw]. What's changed - user: stricter parsing - user: limit reads when parsing passwd and group files - user: limit reads when parsing ID mapping files - user: mkdirAs: refactor and touch-up comments for clarity full diff: moby/sys@user/v0.5.0...user/v0.5.1 [CVE-2026-135844]: https://www.cve.org/CVERecord?id=CVE-2026-135844 [GHSA-ffh6-8jcg-cjmw]: https://github.com/moby/sys/security/advisories/GHSA-ffh6-8jcg-cjmw Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This PR vendors github.com/moby/sys/user from v0.4.1 to v0.5.1, primarily as a security fix for CVE-2026-135844 (unbounded reads in user/group/ID mapping file parsing). The changes are well-structured and intentional.
Reviewed areas:
parsePartsnow returnsbooland skips malformed passwd/group entries — this is an intentional, documented alignment with glibc's behavior (not a regression).openUserFileenforces regular-file-only access with a 10 MiB cap — correct security hardening.idtools_unix.gomkdirAsrefactor looks correct.idtools_windows.goWindows path handling looks correct.lookup_unix.gochanges look correct.
Note (low severity, not verified): user.go line ~318 uses strings.Cut(userSpec, ":") instead of the old parseLine([]byte(userSpec), &userArg, &groupArg). For the unusual edge case of a user spec containing more than one colon (e.g. user:group:extra), the old code would take only the first two colon-delimited fields, yielding groupArg="group". The new strings.Cut yields grp="group:extra", which would fail group lookup. This only affects invalid/malformed inputs not conforming to the documented user[:group] format, so the practical impact is minimal.
Previously-reported findings from earlier review cycles remain open:
idtools.go:114—ToHostsemantic change (open thread, still being tracked).user.go:451— nil pointer dereference inGetAdditionalGroups(open thread; upstream fix in moby/sys#278).
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This PR vendors github.com/moby/sys/user from v0.4.1 to v0.5.1, addressing CVE-2026-135844 (unbounded reads in user/group/idmap file parsing). The core security fix — bounded reads via limitedFile, rejection of non-regular files via openUserFile, and stricter numeric field validation in parseParts — appears correct and well-structured. No high- or medium-severity bugs were found in the new + lines.
Lower-confidence findings (not posted inline)
-
[low]
vendor/github.com/moby/sys/user/user.go:349 —strings.CutreplacesparseLineforuserSpecsplitting, changing multi-colon behavior (confidence: not verified — low severity, not sent to verifier)The old
parseLinesplit took field[0] and field[1], so"user:group:extra"correctly resolved"group"as the group name. The newstrings.Cut(userSpec, ":")returnsgrp = "group:extra"for such input, causing a lookup failure. Only affects already-invalid inputs with extra colons; documented format isuser[:group]. -
[low]
vendor/github.com/moby/sys/user/user.go:505 —GetAdditionalGroupsPathnow propagates non-ErrNotExisterrors fromopenUserFile, breaking callers that relied on silent fallback (confidence: not verified — low severity, not sent to verifier)The old code used
os.Openand silently continued on any error. The newopenUserFileadditionally rejects non-regular files and stat failures, returning errors instead. Intentional hardening but a potential regression for edge-case environments (e.g.,EPERM, device nodes). -
[low]
vendor/github.com/moby/sys/user/user.go:160 —ParsePasswdFilternow silently skips entries with missing/non-numeric UID/GID fields (confidence: not verified — low severity, not sent to verifier)Previously,
parsePartsdefaulted toUid=0,Gid=0on parse errors for*intfields. Now it skips such lines entirely viaparseNumeric. Correct for security hardening but callers with unconventional passwd files relying on lenient parsing will silently lose those entries.
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues blocking the vendored dependency update.
No open issues 🎉
What changed in this PR
Updates Docker CLI’s vendored github.com/moby/sys/user from v0.4.1 to v0.5.1, incorporating security fixes that bound file reads and tighten user, group, and ID-mapping parsing.
Changes:
- Updates dependency metadata and checksums to v0.5.1.
- Adds stricter record validation and extends read limits across file-based parsing and lookup paths.
- Refactors directory creation helpers and updates identity-mapping behavior.
| File | Description |
|---|---|
vendor/modules.txt |
Records v0.5.1 and its Go 1.24 requirement. |
vendor/github.com/moby/sys/user/user.go |
Tightens parsing, bounds file reads, and refactors user/group resolution. |
vendor/github.com/moby/sys/user/user_utils.go |
Shares limited-reader construction and user/group argument helpers. |
vendor/github.com/moby/sys/user/lookup_unix.go |
Routes lookups through bounded file parsers and clarifies reader documentation. |
vendor/github.com/moby/sys/user/idtools.go |
Simplifies directory options and removes the remapped-root translation bypass. |
vendor/github.com/moby/sys/user/idtools_windows.go |
Distinguishes single-directory creation from recursive creation. |
vendor/github.com/moby/sys/user/idtools_unix.go |
Refactors directory tracking and permission application. |
vendor.sum |
Updates module checksums. |
vendor.mod |
Pins the dependency to v0.5.1. |
Review effort: Balanced
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
This PR vendors github.com/moby/sys/user v0.5.1 to address CVE-2026-135844 (unbounded reads in user/group file parsing). The core security fix (10 MiB read cap via limitedFile/openUserFile, plus stricter parseLine validation matching glibc behaviour) is sound and correct.
Previously reported finding — now fixed in this PR:
The nil pointer dereference in GetAdditionalGroups (reported in a prior review: empty string passed to parseGroupArg → nil returned → panic on dereference) has been fixed in v0.5.1: a groupArg == nil guard now returns an error instead of dereferencing.
Previously reported finding — still open (unresolved thread):
The ToHost semantic change in idtools.go (no longer short-circuits on the root-pair ID) was reported in a prior review thread on this PR and remains open. That finding is tracked separately and not re-reported here.
Three new findings in the added code are noted below.
| // Non-numeric values are expected when passing a username or group name, | ||
| // so syntax errors are ignored. The boolean indicates whether the value | ||
| // was interpreted as a numeric ID. | ||
| func parseMaybeNumeric(val string) (int, bool, error) { |
There was a problem hiding this comment.
[low] parseMaybeNumeric returns isNumeric=true with id=0 when input is an out-of-range number
parseMaybeNumeric distinguishes numeric from non-numeric inputs by checking for strconv.ErrSyntax. However, parseNumeric (called internally) translates strconv.ErrRange into a custom package-level ErrRange (fmt.Errorf("uids and gids must be in range …")), which is not wrapped with strconv.ErrSyntax. As a result, when the caller passes a syntactically valid number that is outside the UID/GID range (e.g. "99999999999"), parseMaybeNumeric returns (0, true, ErrRange) — the flag says "this was numeric", but the value is 0 (root UID) and an error is also returned.
All current callers (parseUserArg, parseGroupArg) check err != nil first and propagate the error immediately, so there is no currently exploitable path. The concern is that any future caller that queries isNumeric before checking err would silently treat an out-of-range UID as root (UID 0) instead of returning the error.
The semantically cleaner contract would be (0, false, ErrRange) for out-of-range inputs, since the value cannot be used as-is; or document that isNumeric is only meaningful when err == nil.
| Confidence | Score |
|---|---|
| 🟡 moderate | 70/100 |
| @@ -501,32 +500,55 @@ func GetAdditionalGroups(additionalGroups []string, group io.Reader) ([]int, err | |||
| // that opens the groupPath given and gives it as an argument to | |||
| // GetAdditionalGroups. | |||
| func GetAdditionalGroupsPath(additionalGroups []string, groupPath string) ([]int, error) { | |||
There was a problem hiding this comment.
[medium] GetAdditionalGroupsPath now hard-fails on non-ErrNotExist open errors — breaking behavioral change
The new implementation uses openUserFile and only treats os.ErrNotExist as a graceful fallback (falling back to numeric-only group resolution). All other errors returned by openUserFile — including os.ErrPermission, errNotRegularFile (symlink, device file, pipe), and other I/O errors — now cause GetAdditionalGroupsPath to return a hard error, aborting the caller.
The old implementation (os.Open(groupPath)) ignored ALL open errors and always fell back to numeric-only resolution regardless of the reason.
Concrete impact: Container images or deployments that use a symlink for /etc/group (e.g., pointing to a custom group file) will now encounter errNotRegularFile and fail completely, where previously they would have resolved numeric group IDs successfully. Similarly, containers where /etc/group exists but is not readable (unusual permission) would now fail rather than fall back.
The intent of this change is security hardening (rejecting non-regular files prevents device/pipe-based resource-exhaustion attacks). However, the new behaviour is a breaking change that is not signalled in the PR description or changelog, and may cause container startup failures in environments that relied on the old fallback semantics for permission errors.
Consider documenting this behaviour change, or if ErrPermission should still fall back gracefully, adding it to the allowed-fallback set alongside ErrNotExist.
| Confidence | Score |
|---|---|
| 🟡 moderate | 67/100 |
| func (s SubID) valid() bool { | ||
| return s.Name != "" && | ||
| s.SubID >= 0 && s.SubID <= maxSubID && | ||
| s.Count >= 0 && s.Count <= min(maxSubID+1-s.SubID, maxSubID) |
There was a problem hiding this comment.
[medium] SubID.valid() accepts Count=0, which shadow-utils rejects
The valid() method uses s.Count >= 0 as the lower bound for the Count field:
func (s SubID) valid() bool {
return s.Name != "" &&
s.SubID >= 0 && s.SubID <= maxSubID &&
s.Count >= 0 && s.Count <= min(maxSubID+1-s.SubID, maxSubID)
}
The comment explicitly states this follows shadow-utils validation and links to the shadow-utils source (subordinateio.c:93-127). Shadow-utils requires Count >= 1 — a subordinate ID range with zero count is semantically invalid (zero IDs are delegated). By accepting Count=0, an entry like user:100000:0 passes valid() and is returned by ParseSubIDFilter. When Docker's user namespace remapping subsequently calls newuidmap/newgidmap with a zero-length range, the kernel will return an error, breaking user namespace setup.
The lower bound should be s.Count >= 1 to match shadow-utils semantics and prevent zero-length subID ranges from silently passing validation and causing downstream kernel errors.
| s.Count >= 0 && s.Count <= min(maxSubID+1-s.SubID, maxSubID) | |
| s.Count >= 1 && s.Count <= min(maxSubID+1-s.SubID, maxSubID) |
| Confidence | Score |
|---|---|
| 🟡 moderate | 57/100 |
vendor: github.com/moby/sys/user v0.5.1
Security
This release includes fixes for unbounded reads when parsing user, group,
and ID mapping files, which could lead to excessive resource consumption
and denial of service.
For details, see CVE-2026-135844 / GHSA-ffh6-8jcg-cjmw.
What's changed
full diff: moby/sys@user/v0.5.0...user/v0.5.1
vendor: github.com/moby/sys/user v0.5.0
full diff: moby/sys@user/v0.4.1...user/v0.5.0
Summary
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)