Skip to content

[29.x backport] vendor: github.com/moby/sys/user v0.5. - #7545

Open
thaJeztah wants to merge 2 commits into
docker:29.xfrom
thaJeztah:29.x_backport_bump_user
Open

thaJeztah wants to merge 2 commits into
docker:29.xfrom
thaJeztah:29.x_backport_bump_user

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

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

  • 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

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)

full diff: moby/sys@user/v0.4.1...user/v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a2a9fec)
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>
(cherry picked from commit 21c1b43)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thaJeztah
thaJeztah requested a review from vvoland November 24, 2026 13:56

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION


if gid != rgid {
rgid, err = toHost(gid, i.GIDMaps)
ruid, err := toHost(uid, i.UIDMaps)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] ToHost no longer short-circuits on the mapped root pair, changing behavior for empty non-nil ID maps

The old ToHost implementation had an explicit short-circuit: if the requested uid already equalled the remapped root UID (ruid := i.RootPair()), it skipped calling toHost and returned the root pair directly. The new implementation unconditionally calls toHost(uid, i.UIDMaps) for every UID.

The difference matters when UIDMaps (or GIDMaps) is a non-nil but empty slice ([]IDMap{}). In toHost, the nil-map case explicitly returns the input as-is (identity), but a non-nil empty slice falls through the range loop and returns (-1, error):

func toHost(contID int, idMap []IDMap) (int, error) {
    if idMap == nil {         // nil → identity ✓
        return contID, nil
    }
    for _, m := range idMap { // non-nil empty → loop never runs → falls through
        ...
    }
    return -1, fmt.Errorf("container ID %d cannot be mapped to a host ID", contID)
}

The new doc comment says "An empty mapping is treated as identity", but the implementation only treats nil as identity — a non-nil empty slice causes an error. Any caller that constructs IdentityMapping{UIDMaps: []IDMap{}, GIDMaps: []IDMap{}} (e.g. via JSON unmarshalling of {"UIDMaps": [], "GIDMaps": []}) would have gotten (0, 0, nil) from the old code but now gets (-1, -1, error).

Consider aligning the implementation with the comment by treating a non-nil empty slice the same as nil inside toHost:

func toHost(contID int, idMap []IDMap) (int, error) {
    if len(idMap) == 0 {   // nil or empty → identity
        return contID, nil
    }
    ...
}
Confidence Score
🟡 moderate 67/100

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants