From 20e2aed29df609b0bc36cb47758bfe3ccf9b058a Mon Sep 17 00:00:00 2001 From: Vishal Bulbule Date: Sat, 26 Sep 2026 00:16:21 +0530 Subject: [PATCH 1/2] fix(cli): require a boolean email_verified claim in GoogleOidcVerifier The allowlist check in GoogleOidcVerifier tested the email_verified claim with Python truthiness, so any non-empty string such as "false" counted as verified when the email was on the allowlist. OpenID Connect defines email_verified as a JSON boolean, so the check now requires the value to be exactly True. Google-issued ID tokens already carry a boolean; this closes the gap for any other claim shape. Fixes #7289 --- src/google/adk/cli/trigger_routes.py | 2 +- tests/unittests/cli/test_trigger_routes.py | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/google/adk/cli/trigger_routes.py b/src/google/adk/cli/trigger_routes.py index 2468f8306b1..722c37fb0fe 100644 --- a/src/google/adk/cli/trigger_routes.py +++ b/src/google/adk/cli/trigger_routes.py @@ -256,7 +256,7 @@ async def __call__(self, request: Request) -> None: ) if self._allowed_emails: if ( - not claims.get("email_verified") + claims.get("email_verified") is not True or claims.get("email") not in self._allowed_emails ): raise HTTPException( diff --git a/tests/unittests/cli/test_trigger_routes.py b/tests/unittests/cli/test_trigger_routes.py index d48e8c051bb..35c67bbf5e6 100644 --- a/tests/unittests/cli/test_trigger_routes.py +++ b/tests/unittests/cli/test_trigger_routes.py @@ -544,6 +544,33 @@ def _ok(token, request, audience): ) assert resp.status_code == 403 + @pytest.mark.parametrize("endpoint,payload", _TRIGGER_ENDPOINTS_AND_PAYLOADS) + @pytest.mark.parametrize("email_verified", ["false", "true", 1]) + def test_rejects_non_boolean_email_verified( + self, client_oidc_emails, monkeypatch, endpoint, payload, email_verified + ): + """The claim must be the boolean True; a truthy non-boolean is not verified.""" + + def _ok(token, request, audience): + return { + "aud": audience, + "email": "allowed@project.iam", + "email_verified": email_verified, + } + + monkeypatch.setattr( + trigger_routes_module.google_id_token, + "verify_oauth2_token", + _ok, + ) + resp = client_oidc_emails.post( + endpoint, + json=payload, + headers={"Authorization": "Bearer some.jwt.value"}, + ) + assert resp.status_code == 403 + assert "Untrusted token principal" in resp.json()["detail"] + @pytest.mark.parametrize("endpoint,payload", _TRIGGER_ENDPOINTS_AND_PAYLOADS) def test_accepts_allowed_email( self, client_oidc_emails, monkeypatch, endpoint, payload From aaa1a3965bef90f436055bb6772768d0c08d1c79 Mon Sep 17 00:00:00 2001 From: Vishal Bulbule Date: Mon, 28 Sep 2026 12:57:10 +0530 Subject: [PATCH 2/2] test(cli): cover a missing or null email_verified claim in GoogleOidcVerifier --- tests/unittests/cli/test_trigger_routes.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/unittests/cli/test_trigger_routes.py b/tests/unittests/cli/test_trigger_routes.py index 35c67bbf5e6..2b823a76afd 100644 --- a/tests/unittests/cli/test_trigger_routes.py +++ b/tests/unittests/cli/test_trigger_routes.py @@ -571,6 +571,42 @@ def _ok(token, request, audience): assert resp.status_code == 403 assert "Untrusted token principal" in resp.json()["detail"] + @pytest.mark.parametrize("endpoint,payload", _TRIGGER_ENDPOINTS_AND_PAYLOADS) + @pytest.mark.parametrize( + "email_verified_claim", + [{}, {"email_verified": None}], + ids=["missing", "none"], + ) + def test_rejects_missing_or_null_email_verified( + self, + client_oidc_emails, + monkeypatch, + endpoint, + payload, + email_verified_claim, + ): + """An absent or null email_verified claim is not verified.""" + + def _ok(token, request, audience): + return { + "aud": audience, + "email": "allowed@project.iam", + **email_verified_claim, + } + + monkeypatch.setattr( + trigger_routes_module.google_id_token, + "verify_oauth2_token", + _ok, + ) + resp = client_oidc_emails.post( + endpoint, + json=payload, + headers={"Authorization": "Bearer some.jwt.value"}, + ) + assert resp.status_code == 403 + assert "Untrusted token principal" in resp.json()["detail"] + @pytest.mark.parametrize("endpoint,payload", _TRIGGER_ENDPOINTS_AND_PAYLOADS) def test_accepts_allowed_email( self, client_oidc_emails, monkeypatch, endpoint, payload