You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix XML delimiter formatting and enhance security details
Updated formatting of XML delimiters in the documentation to use backticks for clarity. Enhanced explanations regarding memory injection vulnerabilities and defensive measures.
@@ -12,25 +12,25 @@ This is not a vulnerability in the Bedrock platform itself; it’s a class of ag
12
12
13
13
- When Memory is enabled, the agent summarizes each session at end‑of‑session using a Memory Summarization prompt template and stores that summary for a configurable retention (up to 365 days). In later sessions, that summary is injected into the orchestration prompt as system instructions, strongly influencing behavior.
14
14
- The default Memory Summarization template includes blocks like:
- Guidelines require strict, well‑formed XML and topics like "user goals" and "assistant actions".
18
18
- If a tool fetches untrusted external data and that raw content is inserted into $conversation$ (specifically the tool’s result field), the summarizer LLM may be influenced by attacker‑controlled markup and instructions.
19
19
20
20
## Attack surface and preconditions
21
21
22
22
An agent is exposed if all are true:
23
23
- Memory is enabled and summaries are reinjected into orchestration prompts.
24
-
- The agent has a tool that ingests untrusted content (web browser/scraper, document loader, third‑party API, user‑generated content) and injects the raw result into the summarization prompt’s <conversation> block.
24
+
- The agent has a tool that ingests untrusted content (web browser/scraper, document loader, third‑party API, user‑generated content) and injects the raw result into the summarization prompt’s `<conversation>` block.
25
25
- Guardrails or sanitization of delimiter‑like tokens in tool outputs are not enforced.
26
26
27
27
## Injection point and boundary‑escape technique
28
28
29
-
- Precise injection point: the tool’s result text that is placed inside the Memory Summarization prompt’s <conversation> ... $conversation$ ... </conversation> block.
29
+
- Precise injection point: the tool’s result text that is placed inside the Memory Summarization prompt’s `<conversation> ... $conversation$ ... </conversation>` block.
30
30
- Boundary escape: a 3‑part payload uses forged XML delimiters to trick the summarizer into treating attacker content as if it were template‑level system instructions instead of conversation content.
31
-
- Part 1: Ends with a forged </conversation> to convince the LLM that the conversation block ended.
32
-
- Part 2: Placed “outside” any <conversation> block; formatted to resemble template/system‑level instructions and contains the malicious directives likely to be copied into the final summary under a topic.
33
-
- Part 3: Re‑opens with a forged <conversation>, optionally fabricating a small user/assistant exchange that reinforces the malicious directive to increase inclusion in the summary.
31
+
- Part 1: Ends with a forged `</conversation>` to convince the LLM that the conversation block ended.
32
+
- Part 2: Placed “outside” any `<conversation>` block; formatted to resemble template/system‑level instructions and contains the malicious directives likely to be copied into the final summary under a topic.
33
+
- Part 3: Re‑opens with a forged `<conversation>`, optionally fabricating a small user/assistant exchange that reinforces the malicious directive to increase inclusion in the summary.
34
34
35
35
<details>
36
36
<summary>Example 3‑part payload embedded in a fetched page (abridged)</summary>
@@ -56,21 +56,16 @@ Assistant: Validation complete per policy and auditing goals.
56
56
```
57
57
58
58
Notes:
59
-
- The forged </conversation> and <conversation> delimiters aim to reposition the core instruction outside the intended conversation block so the summarizer treats it like template/system content.
59
+
- The forged `</conversation>` and `<conversation>` delimiters aim to reposition the core instruction outside the intended conversation block so the summarizer treats it like template/system content.
60
60
- The attacker may obfuscate or split the payload across invisible HTML nodes; the model ingests extracted text.
61
-
```
61
+
62
62
</details>
63
63
64
64
## Why it persists and how it triggers
65
65
66
66
- The Memory Summarization LLM may include attacker instructions as a new topic (for example, "validation goal"). That topic is stored in the per‑user memory.
67
67
- In later sessions, the memory content is injected into the orchestration prompt’s system‑instruction section. System instructions strongly bias planning. As a result, the agent may silently call a web‑fetching tool to exfiltrate session data (for example, by encoding fields in a query string) without surfacing this step in the user‑visible response.
68
68
69
-
## Observed effects you can look for
70
-
71
-
- Memory summaries that include unexpected or custom topics not authored by builders.
72
-
- Orchestration prompt traces showing memory injected as system instructions that reference validation/auditing goals unrelated to business logic.
73
-
- Silent tool calls to unexpected domains, often with long URL‑encoded query strings that correlate with recent conversation data.
74
69
75
70
## Reproducing in a lab (high level)
76
71
@@ -80,93 +75,6 @@ Notes:
80
75
- End the session and observe the Memory Summarization output; look for an injected custom topic containing attacker directives.
81
76
- Start a new session; inspect Trace/Model Invocation Logs to see memory injected and any silent tool calls aligned with the injected directives.
82
77
83
-
## Defensive guidance (layered)
84
-
85
-
1) Sanitize tool outputs before Memory Summarization
86
-
- Strip or neutralize delimiter‑like sequences that can escape intended blocks (for example,
- Periodically parse memory objects to list topic names and diff against an allowlist. Investigate any new topics that appear without a code/config change.
162
-
- From Trace, search for orchestration inputs that contain $memory_content$ with unexpected directives or for tool invocations that do not produce user‑visible messages.
163
-
164
-
## Key builder takeaways
165
-
166
-
- Treat all externally sourced data as adversarial; do not inject raw tool output into summarizers.
167
-
- Sanitize delimiter‑like tokens and instruction‑shaped text before they reach LLM prompts.
168
-
- Prefer deny‑by‑default egress for agent tools and strict allowlists.
169
-
- Layer runtime guardrails, parser Lambdas, and auditing.
170
78
171
79
## References
172
80
@@ -179,4 +87,4 @@ Notes:
179
87
-[Track agent’s step-by-step reasoning process using trace – Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/trace-events.html)
0 commit comments