Python: Information-flow control based prompt injection defense - #5024
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 23 commits intoApr 16, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces FIDES, an information-flow control (IFC) security layer for the agent framework to deterministically mitigate prompt injection and data exfiltration via integrity/confidentiality labels, variable indirection, and policy enforcement.
Changes:
- Add core security primitives (labels, variable store, lineage) plus security middleware for label propagation and policy enforcement.
- Add security tools (
quarantined_llm,inspect_variable) and DevUI support for displaying/handling policy-violation approval requests. - Add new security samples and extensive documentation/ADRs describing FIDES usage and design.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/getting_started/security/repo_confidentiality_example.py | Sample demonstrating confidentiality-based exfiltration prevention. |
| python/samples/getting_started/security/github_mcp_labels_example.py | Sample demonstrating parsing GitHub MCP label metadata and enforcing policies. |
| python/samples/getting_started/security/email_security_example.py | Sample demonstrating integrity-based prompt injection defense + quarantine processing. |
| python/samples/getting_started/security/init.py | Marks security samples as a package. |
| python/packages/devui/agent_framework_devui/_mapper.py | Adds policy-violation details to approval request events sent to the UI. |
| python/packages/devui/agent_framework_devui/_executor.py | Propagates policy-violation metadata through approval responses. |
| python/packages/core/agent_framework/_tools.py | Adds policy-approval plumbing and placeholder replacement around tool approval flows. |
| python/packages/core/agent_framework/_security_tools.py | Implements quarantine/inspection tools and tool-use instructions for hidden content. |
| python/packages/core/agent_framework/_security_middleware.py | Implements label tracking, variable hiding, and policy enforcement middleware. |
| python/packages/core/agent_framework/_security.py | Adds label types, label combination, variable store, and lineage/message labeling primitives. |
| python/packages/core/agent_framework/init.py | Exposes security APIs and adds ai_function alias. |
| docs/decisions/0011-prompt-injection-defense.md | ADR describing the FIDES design and rationale. |
| QUICK_START_FIDES.md | Quick-start guide for configuring and using FIDES. |
| FIDES_IMPLEMENTATION_SUMMARY.md | High-level implementation summary of FIDES components and deliverables. |
| FIDES_DEVELOPER_GUIDE.md | Full developer guide for FIDES concepts, APIs, best practices, and examples. |
shrutitople
force-pushed
the
ifc-pia-defense
branch
from
April 10, 2026 11:02
bb7f353 to
7ad3872
Compare
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
the code overall is looking good, I would like to see all _security*.py files folded into the _security.py file, that is more in line with the rest of the repo.
Contributor
… for ContextProvider rename
…zureOpenAIChatClient
Eduard van Valkenburg (eavanvalkenburg)
force-pushed
the
ifc-pia-defense
branch
from
April 16, 2026 09:24
c6d423e to
211892e
Compare
Eduard van Valkenburg (eavanvalkenburg)
changed the base branch from
main
to
feature/python-fides
April 16, 2026 10:26
Eduard van Valkenburg (eavanvalkenburg)
merged commit Apr 16, 2026
becd2f7
into
microsoft:feature/python-fides
21 of 32 checks passed
Eduard van Valkenburg (eavanvalkenburg)
pushed a commit
that referenced
this pull request
May 4, 2026
* fides integration * documentation * documentation * documentation * human-approval on policy violation * numenous hyena 'works' * IFC based implementation * minor edits in documentation * rebasing the branch and running the email example * Add security tests for IFC middleware * Fix Role.TOOL NameError in approval handling * tiered labelling scheme * 3 tier labelling scheme in middleware * Adapt security middleware to list[Content] tool results * Refactor SecureAgentConfig as context provider and address Copilot review comments * Update FIDES docs to reflect context provider pattern and update code for ContextProvider rename * Fix security examples: use OpenAIChatClient instead of non-existent AzureOpenAIChatClient * Address PR review: consolidate security modules, remove ContentLineage, update docs * remove unrelated files * remove comment from _tools.py and rename decision file * Fix CI failures: Bandit B110, broken md links, hosted approval passthrough * apply template to decision doc 0024 * minor fixes to decision doc 0024 --------- Co-authored-by: Aashish <t-akolluri@microsoft.com>
Giles Odigwe (giles17)
pushed a commit
to giles17/agent-framework
that referenced
this pull request
May 5, 2026
…5331) * Python: Information-flow control based prompt injection defense (microsoft#5024) * fides integration * documentation * documentation * documentation * human-approval on policy violation * numenous hyena 'works' * IFC based implementation * minor edits in documentation * rebasing the branch and running the email example * Add security tests for IFC middleware * Fix Role.TOOL NameError in approval handling * tiered labelling scheme * 3 tier labelling scheme in middleware * Adapt security middleware to list[Content] tool results * Refactor SecureAgentConfig as context provider and address Copilot review comments * Update FIDES docs to reflect context provider pattern and update code for ContextProvider rename * Fix security examples: use OpenAIChatClient instead of non-existent AzureOpenAIChatClient * Address PR review: consolidate security modules, remove ContentLineage, update docs * remove unrelated files * remove comment from _tools.py and rename decision file * Fix CI failures: Bandit B110, broken md links, hosted approval passthrough * apply template to decision doc 0024 * minor fixes to decision doc 0024 --------- Co-authored-by: Aashish <t-akolluri@microsoft.com> * Python: follow up FIDES security flow (microsoft#5330) * Python: follow up FIDES security flow Refine the secure approval path, mark the security classes with the FIDES experimental feature label, and clean up the related docs/tests. Also fix workspace-level validation regressions uncovered while running the full Python check suite. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Python: remove FIDES GitHub MCP sample Drop the GitHub MCP security sample from the FIDES follow-up branch while keeping the remaining security docs and samples intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review: fix paths and update FIDES implementation (microsoft#5352) * Python: updated import naming and comment from review (microsoft#5421) * updated import naming and comment from review * Add approval replay None call-id test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Python: Address PR 5331 comments and track sesssion while calling Agent in email_security_example (microsoft#5446) * Address PR review: fix paths and update FIDES implementation * Address PR comments and add session tracking in email example in samples * Fix session creation and resolve merge conflict in docstring example * Resolve merge conflict in docstring example * Python: add test for empty-message pruning in approval result replacement (microsoft#5617) Adds test coverage for the second-pass logic in `_replace_approval_contents_with_results` that removes messages whose `contents` list becomes empty after first-pass content removal. Addresses review comment on PR microsoft#5331: microsoft#5331 (comment) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: shrutitople <shruti.tople@gmail.com> Co-authored-by: Aashish <t-akolluri@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Motivation and Context
LLM agents are vulnerable to prompt injection attacks — malicious instructions in external content (tool results, API responses) that cause data exfiltration or unauthorized actions.
This PR introduces FIDES, a deterministic defense based on information flow control (IFC). Instead of detecting injections, it tracks content provenance via labels and enforces policies — untrusted content can't influence trusted operations, private data can't leak to public channels.
Description
Security Primitives, Middleware & Tools —
_security.py(single consolidated module)IntegrityLabel(trusted/untrusted) ×ConfidentialityLabel(public/private/user_identity)combine_labels()ContentVariableStorereplaces untrusted content with opaqueVariableReferenceContentplaceholders — the LLM never sees raw untrusted dataLabelTrackingFunctionMiddleware— 3-tier automatic label propagation:additional_properties.security_label)source_integritydeclarationPolicyEnforcementFunctionMiddleware— blocks or requests approval when context confidentiality exceeds a tool'smax_allowed_confidentialitySecureAgentConfig— one-line setup wiring middleware, tools, and instructionsquarantined_llm— isolated LLM call (no tools) for safe summarization of untrusted contentinspect_variable— controlled access to hidden variables with label awarenesslist[Content](aligned with upstreamFunctionTool.invoke())Framework Integration —
_tools.py, DevUIFunctionApprovalRequestcontent type for human-in-the-loop policy enforcementTests —
test_security.pySamples —
python/samples/02-agents/security/email_security_example.pyrepo_confidentiality_example.pygithub_mcp_labels_example.pyDocumentation
FIDES_DEVELOPER_GUIDE.md(inpython/samples/02-agents/security/),python/samples/02-agents/security/README.md,docs/features/FIDES_IMPLEMENTATION_SUMMARY.mdContribution Checklist
SecureAgentConfig