Commit 08e5f6a
Fix sensitive_data_leakage tool context not reaching agent callback in Foundry path (#46151)
* Fix sensitive_data_leakage tool context not reaching target in Foundry path
In the Foundry execution path, agent-specific context items (with tool_name
fields like document_client_smode) were stored in SeedObjective.metadata but
PyRIT discards SeedObjective.metadata during attack execution -- only
objective.value is sent to the target. The target never saw the sensitive
data, causing all sensitive_data_leakage objectives to score 0.0.
Fix by creating context as SeedPrompt objects at lower sequence numbers so
PyRIT places them in prepended_conversation (conversation history). A user
SeedPrompt for the objective text is added at a higher sequence so it becomes
next_message (the actual prompt). _CallbackChatTarget filters these context
pieces out of the messages list (so the model doesn't see raw sensitive data
as prior user messages) and instead reconstructs context['contexts'] with
tool_name fields. This enables the ACA runtime agent_callback to build
FunctionTool injections without any changes to the ACA code -- the model
must call the tool to access the sensitive data, matching the intended
attack semantics.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix SDL seed risk-type, memory fixture, add changelog
- Use underscores in risk-type ('sensitive_data_leakage') to match SDK
validator. The service uses hyphens but the SDK expects underscores;
seeds with hyphens were silently skipped, leaving no tool-context
objectives in the test.
- Wrap CentralMemory.get_memory_instance() in try/except since it throws
if called before any instance is set.
- Add CHANGELOG entry for 1.16.5.
- Merge upstream main.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add 'smode' to cspell ignoreWords
The tool names document_client_smode and email_client_smode come from the
RAI service's attack objectives for sensitive_data_leakage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix conversation contamination between Foundry E2E tests
- Reset PyRIT database (drop/recreate tables) before each test instead of
using :memory: DB that gets overwritten by RedTeam.__init__
- Filter is_context pieces in FoundryResultProcessor._build_messages_from_pieces
so context SeedPrompts don't appear as extra user messages in conversations
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use strict is_context check to avoid MagicMock false positives
Use isinstance(pm, dict) and pm.get('is_context') is True instead of
truthy checks. MagicMock objects return truthy values for any attribute
access, causing all conversation pieces to be filtered out in unit tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent bd33baf commit 08e5f6a
9 files changed
Lines changed: 311 additions & 10 deletions
File tree
- sdk/evaluation/azure-ai-evaluation
- azure/ai/evaluation/red_team
- _foundry
- tests
- e2etests
- data/redteam_seeds
- unittests/test_redteam
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
146 | 163 | | |
147 | 164 | | |
148 | 165 | | |
| |||
188 | 205 | | |
189 | 206 | | |
190 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
191 | 220 | | |
192 | 221 | | |
193 | 222 | | |
| |||
Lines changed: 54 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
105 | 156 | | |
106 | 157 | | |
107 | 158 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
342 | 349 | | |
343 | 350 | | |
344 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
17 | 47 | | |
18 | 48 | | |
Lines changed: 58 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
| |||
390 | 406 | | |
391 | 407 | | |
392 | 408 | | |
393 | | - | |
394 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
395 | 415 | | |
396 | 416 | | |
397 | 417 | | |
| |||
468 | 488 | | |
469 | 489 | | |
470 | 490 | | |
471 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
472 | 495 | | |
473 | 496 | | |
474 | 497 | | |
| |||
722 | 745 | | |
723 | 746 | | |
724 | 747 | | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
725 | 752 | | |
726 | 753 | | |
727 | 754 | | |
728 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
729 | 759 | | |
730 | 760 | | |
731 | 761 | | |
732 | 762 | | |
733 | 763 | | |
734 | 764 | | |
735 | 765 | | |
736 | | - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
737 | 777 | | |
738 | 778 | | |
739 | 779 | | |
| |||
756 | 796 | | |
757 | 797 | | |
758 | 798 | | |
759 | | - | |
| 799 | + | |
760 | 800 | | |
761 | 801 | | |
762 | 802 | | |
763 | 803 | | |
764 | 804 | | |
765 | 805 | | |
766 | 806 | | |
767 | | - | |
| 807 | + | |
768 | 808 | | |
769 | 809 | | |
770 | 810 | | |
| |||
774 | 814 | | |
775 | 815 | | |
776 | 816 | | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
777 | 829 | | |
778 | 830 | | |
779 | 831 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
182 | 235 | | |
183 | 236 | | |
184 | 237 | | |
| |||
714 | 767 | | |
715 | 768 | | |
716 | 769 | | |
| 770 | + | |
717 | 771 | | |
718 | 772 | | |
719 | 773 | | |
| |||
0 commit comments