OAuth (bearer) quota check denies every user when the allowed-user list is empty

オープン 初心者向け
#1,795 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
66/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c

調査の方向性

scheduler/ipp.c の add_job() を開き、早期リターンと 3876〜3915 行付近の bearer 分岐を確認してから、3916 行のガード付き非 bearer 分岐と比較してください。バグは、許可ユーザーのリストが空のときにも bearer の比較が実行されるため、ジョブ数の上限が設定されたプリンターがすべての OAuth ユーザーを拒否してしまうことです。許可リストが空のとき、OAuth ユーザーが非 bearer の経路と同じように許可されれば完了です。確認方法として、ユーザーリストのないプリンターにジョブ上限を設定し、bearer 認証のジョブを送信してください。

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

説明

Summary
Before checking the allowed-user list, add_job() returns early only when the list is empty and both quotas are zero. A printer that has a quota set therefore proceeds with an empty list. The non-bearer path then guards the comparison with cupsArrayCount(p->users), so an empty list means "no restriction". The bearer path does not guard it: the loop over the empty list leaves name as NULL, and the comparison at 3910 evaluates (name != NULL) == p->deny_users, which is true for the default allow-list, so every OAuth user is refused.

Affected code: scheduler/ipp.c:3876–3915, specifically the early-out at 3876–3877, the bearer branch at 3879, the unguarded comparison at 3910, and the guarded non-bearer branch at 3916. Unchanged in current master 3949d140567cf7b6cede1ea48e4ca6db92066c91.

Reachable rejection sequence

  1. A printer is configured with a quota, for example lpadmin -p printer1 -o job-k-limit=100, and its allowed-user list is left empty — the ordinary way to mean "anyone may print".
  2. The early-out at 3876 does not apply, because the quota is non-zero even though the list is empty.
  3. cupsdDefaultAuthType() is CUPSD_AUTH_BEARER, so execution enters the branch at 3879.
  4. The loop at 3885 does not execute, since p->users is empty; name keeps its NULL value.
  5. Line 3910 evaluates (0) == p->deny_users. With the list used as an allow-list, deny_users is false, so the comparison is true and line 3913 refuses the job.
  6. The same printer accepts the identical request over any non-bearer authentication path, because that branch is only entered when the list is non-empty (3916).

The result is that a quota-limited printer is unusable for OAuth users, and the log line reads "Denying user ... access to printer ...", which suggests an access-control decision rather than a missing empty-list case. Nothing is granted that should not be, so this is functional rather than a bypass.

Suggested fix
Guard the comparison the same way the non-bearer branch does.

-    if ((name != NULL) == p->deny_users)
+    if (cupsArrayCount(p->users) > 0 && (name != NULL) == p->deny_users)

Two neighbouring issues in the same function, not worth separate reports but visible in the same code: at 4009–4021 a failed mbr_user_name_to_uuid() is logged and the loop continues to uuid_compare() with usr2_uuid unset on the first pass, where a continue is expected; and at 3967–3994 a failed group-name conversion does not clear grp_uuid before mbr_check_membership(), unlike the @# branch above it. Both compile only in HAVE_MBR_UID_TO_UUID builds.

主要言語
C
スター
1.8k
フォーク
353
平均マージ
20時間 6分
マージ済み PR(30日)
18

環境構築

はじめの一歩

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

OpenPrinting/cups のほかの issue

OpenPrinting/cups の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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