googleapis / googleapis/google-cloud-python

google-auth: Thread safety race condition during 401 client certificate rotation in transports

オープン
#17,756 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
auth priority: p2 type: bug
主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
3日 4時間
マージ済み PR(30日)
122

説明

When handling `401 Unauthorized` responses, the HTTP transport interceptors in `google.auth.transport.requests` and `google.auth.transport.urllib3` attempt to auto-rotate expired mTLS client certificates by calling `configure_mtls_channel()`.

In multi-threaded environments, if multiple threads share an authorized session and hit a 401 concurrently, they will trigger the certificate rotation at the same time. Because there is no synchronization lock, this leads to race conditions. Multiple threads will redundantly read the updated certificates and concurrently mutate the underlying session's adapter mappings (`requests.Session.adapters`) or pool managers, which is not thread-safe and can cause runtime exceptions.

We should introduce a lock (e.g., using `threading.Lock`) around the `configure_mtls_channel` reconfiguration block inside the transport handlers to ensure that certificate rotation is performed serially.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start in google.auth.transport.requests and google.auth.transport.urllib3, focusing on the HTTP transport handlers that call configure_mtls_channel after a 401 response. Trace the shared-session and pool-manager reconfiguration paths, then verify that concurrent certificate rotations are serialized and no adapter or pool-manager mutation occurs simultaneously.

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

評価

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

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

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