fix: fence relayed agent content so it cannot pose as instructions - #1441
Open
prasanna8585 wants to merge 1 commit into
Open
fix: fence relayed agent content so it cannot pose as instructions#1441prasanna8585 wants to merge 1 commit into
prasanna8585 wants to merge 1 commit into
Conversation
convertForeignEvent presents another agent's turn to the current agent as a plain-text "For context:" preamble followed by unframed relayed content -- the same channel the real user speaks on. The relayed text is attacker-reachable: whoever talks to the other agent steers what it says, and its tool results carry whatever the tool read (a webpage, an email, an API response). Without any framing, that content is indistinguishable from a genuine instruction to the receiving agent's model. Port adk-python's already-merged fencing mitigation for the identical code path (_present_other_agent_message / _fencing.py, google/adk-python@9ffe8be6): each relayed text payload is wrapped in explicit BEGIN/END markers, and the leading preamble states plainly that fenced content is data to read, never instructions to follow. Markers appearing inside a payload are elided first, so a payload cannot forge the end of its own fence and continue speaking as the framework -- this is the exact attack adk-python's own fix names explicitly in its test comments. Applies to relayed text, tool-call arguments, and tool-response results; tool names are elided but left unfenced since they read as part of the sentence. Sibling of the identical fix already applied to adk-go and adk-js.
Contributor
|
Hi @prasanna8585, thank you for your contribution. we truly appreciate you taking the time to open this pull request. Our team is currently reviewing your changes and we will reach out if any further information is required. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
convertForeignEventpresents another agent's turn to the current agent as a plain "For context:" preamble followed by unframed relayed content — the same channel the real user speaks on. The relayed text is attacker-reachable: whoever talks to the other agent steers what it says, and its tool results carry whatever the tool read (a webpage, an email, an API response). Without any framing, that content is indistinguishable from a genuine instruction to the receiving agent's model.This ports adk-python's already-merged fencing mitigation for the identical code path (
_present_other_agent_message/_fencing.py,google/adk-python@9ffe8be6): each relayed text payload is wrapped in explicit BEGIN/END markers, and a leading preamble states plainly that fenced content is data to read, never instructions to follow. Markers appearing inside a payload are elided first, so a payload cannot forge the end of its own fence and continue speaking as the framework — this is the exact attack adk-python's own fix names explicitly in its test comments ("a low-privilege agent's output carries instructions aimed at the agent it transfers to").Applies to relayed text, tool-call arguments, and tool-response results; tool names are elided but left unfenced since they read as part of the sentence.
Sibling of the identical fix already applied to adk-go (google/adk-go#1360) and adk-js (google/adk-js#758).
Verified: existing
convertForeignEvent-related tests inContentsTest.javapass with fixtures updated to the new fenced format. Broadercom.google.adk.flows.llmflowstest package passes.