Skip to content

user: limit reads when parsing ID mapping files - #287

Merged
thaJeztah merged 2 commits into
moby:mainfrom
thaJeztah:limit_ParseIDMapFileFilter
Nov 24, 2026
Merged

thaJeztah merged 2 commits into
moby:mainfrom
thaJeztah:limit_ParseIDMapFileFilter

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

user: add GoDoc for subordinate ID and ID mapping functions

Add missing GoDoc comments to the exported ParseSubID and ParseIDMap
functions and their File and Filter variants.

user: limit reads when parsing ID mapping files

Use the existing limitedFile reader in ParseIDMapFileFilter to limit reads
to 10 MiB. Unlike other user database files, ID mapping files may be
procfs-backed, so they cannot be restricted to regular files.

Reuse the read limit introduced in bba2f13 while preserving support
for non-regular files such as /proc/self/uid_map and /proc/self/gid_map.

See: bba2f13

Add missing GoDoc comments to the exported ParseSubID and ParseIDMap
functions and their File and Filter variants.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use the existing limitedFile reader in ParseIDMapFileFilter to limit reads
to 10 MiB. Unlike other user database files, ID mapping files may be
procfs-backed, so they cannot be restricted to regular files.

Reuse the read limit introduced in bba2f13 while preserving support
for non-regular files such as /proc/self/uid_map and /proc/self/gid_map.

See: moby@bba2f13

Signed-off-by: Sebastiaan van Stijn <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the ID mapping file-read protection changes.

No open issues 🎉

What changed in this PR

Extends the user package’s file-read protections to ID mapping files, applying the existing 10 MiB limit while preserving support for procfs-backed UID/GID mappings.

Changes:

  • Applies the shared limited reader to file-based ID mapping parsing.
  • Adds GoDoc comments for subordinate-ID and ID mapping parsers.
  • Adds tests for read-limit boundaries and Linux procfs compatibility.
File Description
user/​user.go Documents parsing APIs and limits ID mapping file reads.
user/​user_utils.go Extracts a shared newLimitedFile constructor.
user/​user_test.go Tests size-limit boundaries and procfs mapping support.

Review effort: Balanced

@thaJeztah
thaJeztah merged commit a06183e into moby:main Nov 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants