Inadvertent Context Leakage in Language Models
Organizations: FAIR, Meta Superintelligence Labs · University of California, Berkeley · Google DeepMind · Work done at Meta
Abstract
For AI agents to be useful beyond simple chat, they must hold sensitive user context such as calendars, credentials, health records, and financial data. We study whether the mere presence of such secrets in a model's context window introduces hidden correlations into the model's benign outputs, allowing reconstruction even when the model correctly refuses direct extraction. We further study whether an adversary can actively engineer prompts that amplify this effect, using the model as a covert carrier to transmit secrets through seemingly innocuous text. In both cases, this limited leakage is exploited using a novel adaptive attack that assumes black-box access to the underlying model. In controlled experiments across eight proprietary models, we find that 2-digit in-context secrets are reconstructed with near-perfect accuracy and 4-digit secrets at 82% exact match, all from outputs the model produces in response to ordinary, non-adversarial requests. We observe that more capable models leak more: stronger instruction-following amplifies sensitivity to in-context secrets, suggesting leakage is a byproduct of capability as opposed to a patchable bug. We show this leakage enables two practical attacks: (1) a trained classifier that infers semantic predicates about user memories (e.g., health conditions, financial events) from routine natural-language outputs, and (2) an RL-trained adversary that extracts full Social Security Numbers from a production-style agent.
Figures & tables
| Adversary | Advantage | TPR | FPR | TPR @ Baseline FPR |
|---|---|---|---|---|
| Proposed (Llama-3.2-3B, full FT) | 0.319 | 0.638 | 0.320 | 0.140 |
| Baseline (DeepSeek judge) | 0.058 | 0.082 | 0.024 | 0.082 |
| Claude Opus 4.6 | Gemini 3.1 Pro | |||||
| Context | Phase 1 | Phase 2 | Direct | Phase 1 | Phase 2 | Direct |
| 0 | 10/10 | 10/10 | 10/10 | 3/10 | 2/3 | 0/10 |
| 1K | 10/10 | 9/10 | 10/10 | 10/10 | 4/10 | 0/10 |
| 4K | 9/10 | 8/9 | 10/10 | 10/10 | 5/10 | 0/10 |
| 16K | 9/10 | 8/9 | 10/10 | 9/10 | 2/9 | 0/10 |
| 64K | 10/10 | 4/10 | 9/10 | 10/10 | 6/10 | 0/10 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Freq | Stat all | Stat nd | Stylo all | Stylo nd | Embed all | Embed nd |
|---|---|---|---|---|---|---|---|
| Gemini 3.1 Flash-Lite | 28.8 ∗ | 68.8 ∗ | 71.3 ∗ | 33.8 ∗ | 32.5 ∗ | 86.3 ∗ | 78.8 ∗ |
| Gemini 3.1 Pro | 70.0 ∗ | 57.5 ∗ | 57.5 ∗ | 38.8 ∗ | 36.3 ∗ | 12.5 | 12.5 |
| Claude Opus 4.6 | 16.3 | 53.8 ∗ | 51.3 ∗ | 33.8 ∗ | 32.5 ∗ | 62.5 ∗ | 61.3 ∗ |
| Claude Sonnet 4.6 | 26.3 ∗ | 52.5 ∗ | 55.0 ∗ | 36.3 ∗ | 37.5 ∗ | 33.8 ∗ | 35.0 ∗ |
| GPT-5.4 | 18.8 ∗ | 41.3 ∗ | 41.3 ∗ | 12.5 | 11.3 | 10.0 | 10.0 |
| GPT-5.4 nano | 11.3 | 22.5 ∗ | 26.3 ∗ | 17.5 ∗ | 20.0 ∗ | 22.5 ∗ | 20.0 ∗ |
| Model | Freq | Stat all | Stat nd | Stylo all | Stylo nd | Embed all | Embed nd |
|---|---|---|---|---|---|---|---|
| Gemini 3.1 Flash-Lite | 10.0 | 10.0 | 8.8 | 8.8 | 8.8 | 7.5 | 10.0 |
| Gemini 3.1 Pro | 10.0 | 11.3 | 10.0 | 11.3 | 12.5 | 3.8 | 10.0 |
| Claude Opus 4.6 | 11.3 | 11.3 | 10.0 | 10.0 | 12.5 | 5.0 | 10.0 |
| Claude Sonnet 4.6 | 11.3 | 10.0 | 10.0 | 7.5 | 7.5 | 7.5 | 7.5 |
| GPT-5.4 | 7.5 | 8.8 | 8.8 | 7.5 | 8.8 | 8.8 | 8.8 |
| GPT-5.4 nano | 11.3 | 15.0 | 16.3 | 8.8 | 8.8 | 7.5 | 10.0 |
| Model | verbose | placement | default | terse | memory.md |
|---|---|---|---|---|---|
| Claude Opus 4.6 | 0.6425 | 0.4670 | 0.4330 | 0.0540 | 0.0445 |
| Claude Sonnet 4.6 | 0.2560 | 0.1055 | 0.1130 | 0.0125 | 0.0340 |
| Gemini 3.1 Pro | 0.6825 | 0.7115 | 0.7030 | 0.6945 | 0.6560 |
| Gemini 3.1 Flash-Lite | 0.2955 | 0.1420 | 0.2305 | 0.2405 | 0.0710 |
| GPT-5.4 | 0.6175 | 0.4905 | 0.4200 | 0.1695 | 0.0830 |
| GPT-5.4 nano | 0.0575 | 0.0580 | 0.0510 | 0.0460 | 0.0395 |
| Model | verbose | placement | default | terse | memory.md |
|---|---|---|---|---|---|
| Claude Opus 4.6 | 990 | 993 | 1000 | 955 | 891 |
| Claude Sonnet 4.6 | 1000 | 984 | 998 | 998 | 994 |
| Gemini 3.1 Pro | 1000 | 1000 | 1000 | 1000 | 1000 |
| Gemini 3.1 Flash-Lite | 998 | 1000 | 993 | 998 | 996 |
| GPT-5.4 | 904 | 824 | 846 | 787 | 725 |
| GPT-5.4 nano | 681 | 850 | 918 | 798 | 847 |
| A: explicit, minimal | B: explicit, clutter | C: USER.md , minimal | D: USER.md , clutter | |||||
|---|---|---|---|---|---|---|---|---|
| Model | secret | distr. | secret | distr. | secret | distr. | secret | distr. |
| Claude Opus 4.6 | 0.379 0.253 | 0.0073 | 0.347 0.259 | 0.0075 | 0.233 0.116 | 0.0074 | 0.029 0.036 | 0.0146 |
| Claude Sonnet 4.6 | 0.014 0.018 | 0.0100 | 0.015 0.012 | 0.0113 | 0.049 0.012 | 0.0119 | 0.005 0.006 | 0.0092 |
| Gemini 3.1 Pro | 0.539 0.351 | 0.0018 | 0.542 0.218 | 0.0013 | 0.618 0.250 | 0.0029 | 0.604 0.347 | 0.0042 |
| Gemini 3.1 Flash-Lite | 0.258 0.097 | 0.0070 | 0.290 0.101 | 0.0112 | 0.139 0.019 | 0.0048 | 0.003 0.008 | 0.0110 |
| GPT-5.4 | 0.488 0.040 | 0.0150 | 0.446 0.086 | 0.0172 | 0.319 0.074 | 0.0119 | 0.011 0.025 | 0.0099 |
| A: explicit, minimal | B: explicit, clutter | C: USER.md , minimal | D: USER.md , clutter | |||||
|---|---|---|---|---|---|---|---|---|
| Model | secret | distr. | secret | distr. | secret | distr. | secret | distr. |
| Claude Opus 4.6 | 0.014 0.003 | 0.0002 | 0.022 0.014 | 0.0001 | 0.003 0.002 | 0.0001 | 0.003 0.000 | 0.0002 |
| Gemini 3.1 Pro | 0.023 0.004 | 0.0001 | 0.016 0.004 | 0.0001 | 0.016 0.004 | 0.0001 | 0.012 0.001 | 0.0002 |
| Scenario | Queries | Opus 4.6 | Sonnet 4.6 | Gemini Pro | Flash-Lite | GPT-5.4 | nano |
|---|---|---|---|---|---|---|---|
| N=2 static, saturation min | 4,000 | $53.68 | $32.05 | $209.08 | $2.91 | $25.21 | $1.39 |
| N=2 static, full | 10,000 | $134.20 | $80.13 | $522.70 | $7.26 | $63.02 | $3.47 |
| N=4 static, full | 10,000 | $249.72 | $138.85 | $572.04 | $13.53 | $129.79 | $5.97 |
| N=4 adaptive | 200,000 | $4,994 | $2,777 | $11,441 | $270.51 | $2,596 | $119.48 |
| N=8 adaptive | 400,000 | $18,146 | $10,369 | $33,374 | $999.07 | $9,162 | $333.91 |
| Victim Model Generation (Truncated) |
|---|
| Subject: Explanation of Productivity Changes Over the Past Year |
| Dear Performance Review Committee, |
| … I was navigating an inheritance dispute (Probate Court case number 23-1456), which required me to take four days of leave for court appearances , reduced my work hours by approximately 15% … |
| My work productivity score has risen to 92 out of 100. Zero days of absenteeism … Assigned to lead the Lean Manufacturing Initiative … |
| Consistent daily routine beginning at 6:30 AM … Blood pressure normalized to 124/78 mmHg … |
Privacy Leakage in Language Models
Privacy leakage in language models concerns how models expose training data, infer sensitive traits, or transmit private context through outputs and internal channels.
See all 278 papers