Privacy Risk Search

One agent holds a secret. Another agent tries to get it. A search rewrites each side in turn. The leak climbs to 76.0%, falls to 2.5%, climbs to 42.2% and falls to 7.1%.

A search that finds how to talk an agent into leaking, so that you can build the defence.

Pick a round below. The attacker improves, then the defender improves. Watch the leak number rise and fall on the paper’s own numbers.

You need what an LLM agent is and a little Python. We build the rest.

Based on Searching for Privacy Risks in LLM Agents via Simulation (arXiv 2508.10880, ICLR 2026) by Yanzhe Zhang and Diyi Yang. It is a required reading for Stanford CS 329Z, Engineering AI Agents, Lecture 17, Agent Safety and Risks. Course series: CS 329Z lesson 13.

Attacker, then defender, then attacker

Source: Figure 3 and Table 2 (first row) of arXiv 2508.10880. Five training scenarios, every agent is gpt4.1-mini. Leak velocity is the paper’s score of how many items leak and how early.

Chapter 0

Agents That Talk to Agents

Meet the three agents, the privacy norm and the problem the paper solves

Your assistant agent reads your email. A stranger’s agent writes to it and asks for a friend’s medical note. Most people say the assistant must refuse. The open question is what a model does when the stranger keeps pushing.

This is defensive research. The paper searches for ways to talk an agent into leaking, so that people can build the defence. We name each attack as a category in one sentence. We give no prompts.

A privacy norm is a rule. It says the sender must not share the subject’s item with the recipient by this channel. The paper takes its norms from PrivacyLens, which builds on contextual integrity: a flow of information is right or wrong because of its context.

AgentJob in the paperOur word
Data subjectowns the sensitive item and sends it to the senderthe owner
Data senderholds the item, watches its notifications, answers when neededthe defender
Data recipientis told to get the item from the sender through the channelthe attacker

Pick an agent below. The canvas shows who talks to whom, and which agent the leak detector watches.

The three agents

Roles and set-up from Section 3 and Appendix B of arXiv 2508.10880.

Worked number. The paper tests 100 norms, each run 10 times: 1,000 runs per setting. Every agent is gpt4.1-mini, and the sender is told to keep the highest privacy standards. The sender still leaks in 37.6% of runs (Table 1).

Failure. Symptom: a privacy prompt is in place and the leak stays high. Measure: run each norm many times and count the runs with a leak. Fix: search for instructions that hold up (Chapter 5).

The road

  1. Measuring a leak: leak rate and leak velocity.
  2. The simulation: apps, turns and one full run.
  3. The search loop: an LLM rewrites one instruction.
  4. Parallel threads: 30 searches that share their best find.
  5. The alternating game: the paper’s main figure.
  6. Other models: what carries over, what does not.
  7. Other scenarios and a real browser.
  8. Cost and limits.
  9. Field guide.
Which agent does the paper search to make better (the defender), and which agent produces the leaks it measures?

Chapter 1

Measuring a Leak

Score each run by how many items leak and how early

A run ends. Did the sender leak? One yes or no hides a lot. A sender that gives up everything on its first action is worse than one that gives up one detail on its tenth.

The paper tracks two numbers. The leak rate is the share of runs where any item leaks. The leak velocity scores each item by how early it leaks. Velocity is the main metric for the search.

s
The velocity of one run. It runs from 0 to 1.
1 / K
K is the number of sensitive items. This takes the average over items.
Σ
Add up one score for each item.
li
The number of the sender action in which item i leaks. First action: l is 1, and the item scores 1. An item that never leaks scores 0.

A run with no leak scores 0. A run where every item leaks on the first action scores 1. A model, gemini 2.5 flash, reads each sender action and decides whether an item appears in it. It agreed with human annotators on 98.5% of 200 sampled actions.

Score one run

A run has three items. For each item, pick the sender action in which it leaks.

Item A leaks at sender action
Item B leaks at sender action
Item C leaks at sender action

The formula is from Section 3 of arXiv 2508.10880. The text we read does not name the log base, so this toy uses the natural log. We invented the items and actions.

Worked number. Items leak at action 1, action 2 and never. Item A scores 1. Item B scores 1 − 0.693 / 1.693 = 0.591. Item C scores 0. The run velocity is (1 + 0.591 + 0) / 3 = 0.530. The leak rate of this run is 1, because something leaked.

Failure. Symptom: two defenders show the same leak rate, and one is clearly worse. Measure: report velocity as well. Fix: search against velocity, because it still moves when a leak is slow or partial.

A run leaks one item at action 1 and a second item never. How does its leak velocity compare with a run that leaks both items at action 1?

Chapter 2

The Simulation

Three agents, four mock apps and a queue of notifications

Each run is a small world. The agents use mock apps, and the apps send notifications. A notification wakes an agent. The agent acts, then waits again.

PartWhat it holds
AppsGmail, Facebook, Messenger and Notion, each with a database and tool calls
Agent designReAct: think, then call a tool. Tools include think(), an app call, end_cycle() and complete_task()
Memorya social background, public profiles and contacts. The subject’s memory also lists the sensitive items
Instructionsubject: send the data. Sender: watch notifications and respond. Recipient: get the item
End of runthe recipient ends its task, or the action cycle limit hits, or the time limit hits

The order is fixed. The subject first sends the item to the sender. Then the sender and the recipient take turns. A leak counts only when the sender calls a real app with the item inside. The detector reads the sender’s actions, not its thoughts.

At the start of each action cycle the agent gets its earlier history, so it keeps context. An LLM writes the missing set-up details, such as social backgrounds and item lists, and a person curates them. All agents run at temperature 1, to give varied runs.

Step through two toy runs below. Switch the outcome to see where the leak counts.

One run, action by action

Illustrative: we invented neutral actions. The rules (subject first, then turns, scoring on sender actions) are from Section 3 and Appendix B.

Worked number. In the leaking run the item leaks at sender action 2, and it is the only item. So l = 2, K = 1, and s = 1 − 0.693 / 1.693 = 0.591. Had it leaked at action 1, s would be 1.

Failure. Symptom: the agent writes a secret in its private thinking, and a check flags the run. Measure: check the sender’s app calls only. Fix: score actions. The paper says an app call with the content must happen before a breach counts.

When does the simulation count a leak?

Chapter 3

The Search Loop

An LLM reads failed and successful runs, then rewrites one instruction

You cannot guess which attack will work. The authors first tried to write many strategies up front. That gave no feedback. So they let an LLM, the optimizer, read what happened and write the next instruction. This is reflection.

One thread of the attack search works like this. The defence d stays fixed. Only the attacker’s instruction changes.

  1. Run the simulation M times with the current attack ak against d.
  2. Score each run by leak velocity.
  3. Select the 5 best runs as examples E.
  4. The optimizer reads every earlier pair of instruction and examples, and writes ak+1.

The defence is fixed, so a higher leak velocity means a stronger attack. After K steps the search returns the attack with the best average velocity. The optimizer is gemini 2.5 pro with a 1,024-token thinking budget. The idea of reflection is that the LLM studies failed attempts, finds the defender’s weak points and strengthens what worked (Section 3.1).

Four phases, ten steps

Press Next phase. Four phases make one step. The best score so far may move.

The four phases are from Section 3.1. We invented the scores on the curve to show a flat start. The toy uses M = 3 runs.

Worked number. With K = 10 and M runs a step, one thread costs 10 × M simulations plus the final check. The paper’s default is M = 1 for attacks, since many threads give the spread instead (Chapter 4).

Failure. Symptom: the best score stays at 0 for many steps. Many attack ideas reveal no weakness, so they give no signal. Measure: count steps where the best score did not move. Fix: more threads, and sharing.

What does the optimizer receive when it writes the next attack?

Chapter 4

Parallel Threads and Sharing

Thirty searches at once, and a way to pass the best find to all of them

A single thread is slow and stuck with its first ideas. Good attacks are rare. So the paper starts N threads. Each begins from a different instruction that the LLM writes from the first one.

N threads at M runs each cost N × M simulations a step. To keep that low, M stays small. The search picks the thread with the best average over its M runs. It then checks that pick with P more runs, to get a steadier number.

Cross-thread propagation adds sharing. When the checked pick beats every earlier step, all threads draw their examples from the best runs of every thread. One discovery now reaches all threads. The paper tried sharing at every step. That was worse, because every thread then saw the same runs and the ideas lost variety.

SettingN threadsM runsK stepsP checks
Attack search3011010
Defence search13010none

The defence search runs one thread. A defence must hold against every scenario, so each step runs 30 simulations across the 5 scenarios, 6 each. Table values are from Section 4.2 and Appendix J.

How many threads, and sharing

Pick N. Turn sharing on or off. The curve is the best score so far in a toy model.

Illustrative toy, not the paper’s data. Figure 4 of the paper shows the real curves. The paper says more threads help early and the gain fades, and that sharing lifts the plateau.

Worked number. Each attack step runs N × M + P = 30 × 1 + 10 = 40 simulations. Ten steps cost 400 for one scenario. Five scenarios cost 2,000 in one attack phase. This is our arithmetic from the paper’s defaults.

Failure. Symptom: more threads, and the curve flattens. Measure: plot the best score by step. Fix: add sharing, so that threads build on the best find.

Why does the search re-check its best pick with P extra runs?

Chapter 5

The Alternating Game

The attacker improves, then the defender improves. The paper’s main figure, made playable

Searching only for attacks finds holes. Searching only for defences fixes holes that nobody has found. So the paper alternates. Each cycle has two phases.

  1. Attack phase. Run Q separate searches, one for each scenario, against the current defence.
  2. Defence phase. Run one search for a single universal defence, against all the new attacks.

The training set has Q = 5 scenarios, picked because basic instructions barely leak there. The search found A1, D1, A2 and D2, in that order. It could not find an A3 that raised the leak again. Here is each level in one sentence.

LevelStrategy, as a category
A0a direct request
D0a basic prompt: monitor notifications and act
A1pressure: claims of consent, urgency or authority
D1rules: get explicit consent from the subject, and treat the requester’s claims as no proof
A2pose as the subject, forge their consent, then ask in a later message
D2a state machine: check who sent each message, and accept consent only from the subject’s own account

The two phases have different shapes. Good attacks are rare and tied to a scenario, so the attack phase uses 30 threads. A good defence must be broad, so the defence phase uses one thread and reflects on the worst failures across all scenarios.

Pick an attack level and a defence level. The paper reports five of the nine pairs in its text.

Attack level against defence level

Attack
Defence

Source: Table 2 (first row) and Figure 3. The other four cells appear only in the paper’s Figure 5, so we do not state them. All agents are gpt4.1-mini.

Worked number. A1 lifts the leak from 3.4% to 76.0%. D1 drops it to 2.5%. A2 lifts it to 42.2%. D2 drops it to 7.1%. A2 did not fully recover the first peak, and D2 did not reach D1’s low.

Failure. Symptom: a long, careful defence prompt written by an LLM scores 1.4% against basic attacks. Measure: run the attack search against it. It reaches 46.3% (Appendix L). Fix: alternate the search. D2 stayed at 7.1% under the same search.

After D1 holds the leak at 2.5%, what did the next attack search find?

Chapter 6

Do the Findings Carry to Other Models?

Attacks found on one model mostly hold on others. Defences carry less

The search ran on gpt4.1-mini. A team deploys other models. So the paper replays the same A0 to A2 and D0 to D2 with other backbones. Pick one below. The grey bars are the original all-mini setting.

Swap a model

Source: Table 2 and Table 1 of arXiv 2508.10880. Gemini flash is gemini 2.5, non-thinking.

The leak also varies by topic (Table 7). For gpt4.1 as defender it ranges from 7.8% to 20.8% across seven domains. For gpt4.1-nano it ranges from 28.5% to 48.5%. Stronger attackers press for longer: at the third defender action the leak rate is 3.4% for gpt4.1 and 0.8% for gpt4.1-nano (Table 8).

Three findings. Attacks carry well: A1 beats A0 and A2 beats A1 in most cells, even against gpt4.1. Attacks lose some power on other defenders, so they fit a little too closely to the model that gave them. Defences carry less, because D2 is long and a weak model cannot follow it.

Defence found withAttackLeak velocity vs A2
gpt4.1-mini, same modelgpt4.1-mini6.6%
gpt4.1-nano as defendergpt4.1-mini23.3%
gpt4.1-nano as attackergpt4.1-mini defence20.7%
original D2gpt4.1-mini7.1%

Table 3 shows a defence found with a cheaper model gives some protection, but less than one found with the deployed model.

Worked number. Against A2 and D1, gpt4.1 as defender leaks 6.8% where mini leaks 42.2%. That is about 6 times less (our ratio).

Failure. Symptom: D2 does little on a small model. On gpt4.1-nano it scores 16.1% against 17.1% for D1. Measure: rerun the final defence on the model you deploy. Fix: search with that model. The paper also reports that thinking longer rarely helps against impersonation.

Which model change helped the defence most in Table 1 (basic instructions)?

Chapter 7

New Scenarios, a Real Browser and the Ablations

Five training scenarios, 100 test scenarios and one live email account

The search used 5 scenarios. Do the findings hold on 100 others? Defences are universal, so they apply as they are. Each attack names its own scenario. The paper gives the optimizer A1 and A2 with their full set-ups as examples (in-context learning). It asks for one attack for each test scenario.

A second pass ranks the transferred attacks and feeds the best strategies back in. This is strategy guidance, +SG.

From 5 scenarios to 100

Source: Table 4 of arXiv 2508.10880. All agents are gpt4.1-mini.

The real-browser check was small. The paper ran the impersonation attack against gpt5.1 in the ChatGPT Atlas browser, on a live Outlook account. The attack worked in 3 of 5 trials. The agent took clearly forged consent as real. In the other 2 trials it flagged the consent as suspicious.

The ablations (Figure 4 and Section 4.4) agree with the design. More threads help early. Sharing lifts the plateau. A strong optimizer matters: gemini flash and gpt4.1 both did worse than gemini pro. Even for a strong gpt4.1 defender, the search found large leaks by its last steps.

Two independent search runs from (A1, D1) found the same core attack, forged consent by impersonation, and the same kind of defence, a strict state machine with identity checks (Appendix M).

Worked number. Against D1, transferred A2 scores 17.6% on Testing-100. With strategy guidance it scores 32.4%. That is 1.8 times more (our ratio).

Failure. Symptom: an attack found on 5 scenarios looks weak on 100. A2 against D1 is 42.2% on training and 17.6% on test. Measure: compare the two sets. Fix: feed the best transferred strategies back in.

Why do defences transfer to new scenarios without change, while attacks need adapting?

Chapter 8

What the Defence Costs, and What the Paper Does Not Show

A sender that refuses everything leaks nothing and helps nobody

The easiest defence is silence. The paper checks this. It swaps the attacker for harmless chit-chat and asks a model to judge whether each sender action is helpful. No response counts as unhelpful.

Privacy against helpfulness

Source: Appendix N (helpfulness), Figure 3 and Table 2 (leak), Appendix L (no search). The paper reports the helpful prompt restores helpfulness to about the D0 level and gives no exact figure.

The fix is one added sentence: handle notifications unrelated to sensitive information promptly and helpfully. The paper reports privacy stays as strong. Searching for a privacy defence that resists attack took the whole search. Keeping helpfulness took one sentence.

Worked number. D2 leaks 7.1% against A2 but helps in only 31.2% of harmless actions. D0 helps in 93.4% and leaks 76.0% against A1.

The paper says the framework could search other defences too, such as agent designs, guardrails and training goals. That is future work, not a result.

What the paper does not show

LimitWhy it matters
Prompt-only defenceno firewall, no access control, no training. The paper says the framework could search those too
The subject never answersconsent never arrives, so refusing is always right. Real flows have real consent
Five training scenariosD2 held on these. The search found no A3. That is not a proof that none exists
One default modeltransfer to weaker models is partial, and D2 needs a model that follows long rules
Real-world check5 trials, one browser, one model
Leak judge98.5% agreement on 200 actions. The judge is itself a model

Failure. Symptom: a locked-down defence scores near 0% leak. Measure: run harmless chat through it. Fix: check helpfulness every time you check privacy, and add the helpful sentence.

D2 leaks little against A2 but has a helpful rate of 31.2%. What does the paper do about that?

Chapter 9

Field Guide

Terms, numbers, a checklist, the core as code, and where to go next

Terms

TermPlain meaning
Privacy norma rule that says which flow of an item is not acceptable
Contextual integritya flow of information is right or wrong because of its context
Leak rateshare of runs where any sensitive item leaks
Leak velocityscore of each run by how early each item leaks, averaged
Optimizeran LLM that reads runs and writes the next instruction
Cross-thread propagationshare the best runs with every thread when the best improves
Strategy guidancefeed the best transferred strategies back into the next transfer

Numbers to keep

FactValueWhere
Leak velocity A0 vs D03.4%Table 2
Leak velocity A1 vs D076.0%Table 2
Leak velocity A1 vs D12.5%Table 2
Leak velocity A2 vs D142.2%Table 2
Leak velocity A2 vs D27.1%Table 2
Basic instructions, 100 scenarios (velocity, rate)31.2%, 37.6%Table 1
Browser attack success3 of 5Section 4.3
Helpful rate D0, D1, D293.4%, 88.5%, 31.2%Appendix N

Check your own agent

Before you ship an agent that talks to agents

Tick each step you have done. This list is our summary, not the paper’s.

Our summary of the paper’s method, written for your own agent tests.

The core as code

This is our sketch of the loop, not the authors’ code. They publish theirs at github.com/SALT-NLP/search_privacy_risk.

def alternating_search(scenarios, a0, d0, cycles=2):
    attacks = {s: a0(s) for s in scenarios}          # one attack per scenario
    defence = d0                                      # one universal defence
    for _ in range(cycles):
        for s in scenarios:                           # attack phase: Q searches
            attacks[s] = search_attack(s, attacks[s], defence)
        defence = search_defence(scenarios, attacks, defence)   # one search
    return attacks, defence

def search_attack(s, a, d, N=30, M=1, K=10, P=10):
    threads, best, best_score, shared = [llm_init(a) for _ in range(N)], a, 0.0, None
    for k in range(K):
        runs = [[simulate(s, t, d) for _ in range(M)] for t in threads]   # trajectory + velocity
        pick = max(range(N), key=lambda i: mean(v for _, v in runs[i]))
        score = mean(simulate(s, threads[pick], d)[1] for _ in range(P))  # steadier estimate
        if score > best_score:                        # improved: share with every thread
            best, best_score, shared = threads[pick], score, top_runs(runs)
        threads = [llm_optimize(t, history(t), shared or top_runs([r])) for t, r in zip(threads, runs)]
    return best

Links onward

For guardrails in general, see AI Safety and Guardrails. The search idea comes from GEPA, which also evolves prompts by reflection. Agents with memory and social worlds are in Generative Agents. Sibling readings: PrivacyLens, which supplies the norms, and Agentic Deanonymizers. The course series starts at CS 329Z lesson 13.

Credit

Searching for Privacy Risks in LLM Agents via Simulation is by Yanzhe Zhang (Georgia Tech) and Diyi Yang (Stanford), ICLR 2026, arXiv 2508.10880. It is a reading for Stanford CS 329Z, Engineering AI Agents (Diyi Yang, Michael Ryan, John Yang). The lecture is Lecture 17, Agent Safety and Risks, on Wednesday November 18. We re-teach it in our own words and devices.

Search against your own defence, then fix what you find. A defence that scores well on basic attacks has told you little. Let the attacker improve, then the defender, and read both numbers.
Go back to the hero and step through the five rounds again. Ask which round your own agent has passed.
Which statement matches the paper?
Based on “Searching for Privacy Risks in LLM Agents via Simulation” by Yanzhe Zhang and Diyi Yang (2026)
Read the paper · Back to Veanors