googleapis / googleapis/ruby-cloud-env

Malformed identity JWT encoding raises instead of expiring the cached token

Offen Anfängerfreundlich
#111 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Ruby
Sterne
16
Forks
12
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit ComputeMetadata#determine_identity_lifetime und reproduziere den im Issue beschriebenen Fall mit ungültigem URL-safe Base64. Prüfe die bestehende Behandlung von fehlerhaftem JSON und verifiziere, dass fehlerhafte JWT-Payloads eine Lebensdauer von null ergeben, ohne den Lebensdauerpfad für gültige Tokens zu ändern. Bestätige, dass die relevante Testsuite weiterhin erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ruby
Bereich
cloud
Issue-Typ
Bug
Schwierigkeit
1/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
78/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.