Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

user: parseLine silently ignores uid/gid conversion errors, malformed ids parse as 0

オープン
#248 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go
領域
backend, security

調査の方向性

user/user.go の parseParts から始め、ParsePasswdFilter と ParseGroupFilter が解析済み ID をどのように公開しているかを追跡します。issue にある不正形式および範囲外の例を再現し、そのうえで、選択された動作が変換エラーを返すことなのか、無効なエントリをスキップすることなのかを判断します。呼び出し元が無効な ID と正当な uid 0 の値を区別できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

parseParts in user/user.go parses numeric fields with the conversion error discarded:

case *int:
	// "numbers", with conversion errors ignored because of some misbehaving configuration files.
	*e, _ = strconv.Atoi(string(p))

https://github.com/moby/sys/blob/d6b812df97ee7e0c1e16437fd4d1fa61738427db/user/user.go#L82

Two consequences for consumers that resolve container users from an image's /etc/passwd or /etc/group:

  • A malformed id field parses as 0. The line evil:x:not-a-uid:10::/:/bin/sh produces User{Name: "evil", Uid: 0}, so looking up that user silently yields root. The caller can't detect this, since uid 0 is also a perfectly legitimate value.
  • An id past the int range saturates instead of erroring. On 32-bit platforms 4294967296 comes back as 2147483647 with no error, so the caller can't range-check it either.

Context: containerd/containerd#13797 added bounds checks on ids resolved from image user databases, but both cases above are invisible to that check because the value has already been collapsed by the time ParsePasswdFilter/ParseGroupFilter return. @fuweid suggested fixing this at the parser level (https://github.com/containerd/containerd/pull/13797#discussion_r3867287873).

I understand the error was dropped deliberately to tolerate misbehaving config files, but for the id fields specifically the failure mode is "arbitrary string becomes root", which seems worth surfacing. Happy to send a PR, either returning an error from the parse functions when an id field doesn't parse, or skipping such entries, whichever direction you prefer.

主要言語
Go
スター
102
フォーク
62
平均マージ
6分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

moby/sys のほかの issue

moby/sys の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。