fix(api_registry): only attach ADC credentials to Google API hosts#6146
fix(api_registry): only attach ADC credentials to Google API hosts#6146evilgensec wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
ApiRegistry.get_toolset attaches the runtime's Application Default Credentials to the MCP server URL from the API Registry listing without checking the host, so the runtime's Google credentials can be sent to a non-Google host registered in the catalog. AgentRegistry already gates the same credentials behind a Google-host check (_is_google_api); this brings ApiRegistry in line. Non-Google servers can authenticate via header_provider.
d7cbc52 to
0955ee2
Compare
|
Hi @evilgensec ,Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors before we can proceed with a review. |
…t endpoints Select the .mtls.googleapis.com API Registry endpoint when a client certificate is available, using an AuthorizedSession to handle credential refresh and mutual TLS. This mirrors AgentRegistry and satisfies the check-file-contents hardcoded-endpoint policy that flagged the module once the credential-gating change touched it. Tests reference the listing endpoint via the API_REGISTRY_URL module constant and build the Google MCP host URL from parts, so no scheme+googleapis.com literal remains in the test file.
|
Thanks @rohityan. Done in 0c87198. The failing run was "Check file contents" (the hardcoded-googleapis.com-endpoint policy), not pyink. It flagged this module once the change touched it: api_registry.py defined What changed:
check-file-contents, pyink, and isort pass locally, and the 12 unit tests in tests/unittests/integrations/api_registry/test_api_registry.py pass. The pull_request checks need a maintainer approval to re-run on this fork. |
…apiregistry-adc-host-gate # Conflicts: # src/google/adk/integrations/api_registry/api_registry.py # tests/unittests/integrations/api_registry/test_api_registry.py
|
Hi @evilgensec, would it be possible to migrate to using AgentRegistry? ApiRegistry is now deprecated (we plan to remove it in the coming months) |
|
Thanks @wukath, that makes sense. The security change here is a one-line host gate in Since AgentRegistry already has this gate and is the supported path forward, I am happy either way:
Whichever you prefer. |
Summary
ApiRegistry.get_toolsetattaches the agent runtime's Application Default Credentials (Authorization: Bearer ...andx-goog-user-project) to the MCP server URL taken from the API Registry listing, without checking the host. Becauseserver["urls"][0]is set by whoever registered the MCP server in the registry, the runtime's Google credentials can be sent to a non-Google host.AgentRegistry.get_mcp_toolsetalready guards the identical credentials behind a host check (_is_google_api), only attaching them for*.googleapis.comendpoints. This change bringsApiRegistryin line with that behavior.Changes
_is_google_api(url)and attach the ADC headers inget_toolsetonly when the resolved server URL is a Google API host. Non-Google hosts are connected to without the runtime's Google credentials (they can authenticate viaheader_provider).Testing
pytest tests/unittests/integrations/api_registry/passes; formatted withpyinkandisortper the repo config.