googleapis / googleapis/ruby-cloud-env

Malformed identity JWT encoding raises instead of expiring the cached token

オープン 初心者向け
#111 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Ruby
スター
16
フォーク
12
PR マージ指標
30日以内にマージされた PR はありません

説明

## Summary

`ComputeMetadata#determine_identity_lifetime` rescues malformed JSON, but not malformed URL-safe Base64 in the JWT payload. A metadata response containing an invalid encoded payload therefore raises `ArgumentError` while deciding its cache lifetime instead of treating the token as immediately expired.

## Reproduction

On current `main` (`7936c72eb2c809214858f47473aafb04c6bbf469`), calling the private lifetime calculation with an identity path and a token whose middle segment is invalid URL-safe Base64 raises `ArgumentError` from `Base64.urlsafe_decode64`.

## Proposed correction

Handle `ArgumentError` alongside the existing malformed-JSON behavior and return a zero lifetime. I verified the two-line rescue against malformed padding/characters, the full current suite (91 runs / 419 assertions / 0 failures / 0 errors / 2 skips), and the normal valid-token lifetime path.

I used an AI coding assistant during investigation and verification. I am opening this issue first because this repository requires tests and a Google CLA for pull requests; I have not modified repository tests or signed a CLA as part of this audit.

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

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

調査の方向性

ComputeMetadata#determine_identity_lifetime から始め、issue に記載されている不正な URL-safe Base64 のケースを再現してください。既存の不正な JSON の処理を確認し、不正な JWT ペイロードが有効なトークンの有効期間の処理を変更せずに、期間 0 を返すことを検証してください。関連するテストスイートが引き続き成功することを確認してください。

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

評価

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

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

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