Repository navigation
Python: Harden FIDES security state and policy enforcement - #9652
Eduard van Valkenburg (eavanvalkenburg) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Code coverage overviewLanguages: Python Python / code-coverage/python
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
🟡 Changes recommended
Replay reconstruction can miss loaded history and lose identity-scoped restrictions, leaving downstream policy checks weaker than required.
3 open issues
What changed in this PR
This PR hardens Python FIDES information-flow enforcement across transcript replay, MCP results, hidden arguments, and persisted session state. Non-history context-provider labeling remains a separate follow-up.
Changes:
- Reconstruct missing replay security state while preserving restored labels.
- Retain MCP security metadata independently and reject invalid tool policies.
- Defer hidden-value validation until authorization, support surrogate-safe serialization, and add regression tests and guidance.
| File | Description |
|---|---|
python/samples/02-agents/security/FIDES_DEVELOPER_GUIDE.md |
Documents replay handling, metadata validation, and authorization ordering. |
python/packages/core/tests/test_security.py |
Adds policy, replay, serialization, and validator regressions. |
python/packages/core/tests/core/test_mcp.py |
Tests security-label retention when payload budgets are exhausted. |
python/packages/core/agent_framework/security.py |
Implements replay reconstruction, policy parsing, and deferred argument materialization. |
python/packages/core/agent_framework/_tools.py |
Integrates deferred security argument materialization into invocation. |
python/packages/core/agent_framework/_middleware.py |
Tracks the active function middleware pipeline. |
python/packages/core/agent_framework/_mcp.py |
Adds an independently bounded security-metadata carrier. |
docs/features/FIDES_IMPLEMENTATION_SUMMARY.md |
Clarifies enforced flows and context-provider trust boundaries. |
Review effort: Balanced
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 634139edf460
Model: gpt-5.6-sol
Overview
The PR adds conservative replay reconstruction, independently bounded MCP IFC retention, delayed hidden-argument materialization, ASCII-safe durable state, and centralized tool-policy parsing. Its strongest guardrails are fail-closed MCP labeling, identity-bound argument materialization, unconditional ContextVar cleanup, and targeted regression coverage. Two gaps remain: restored sessions stop conservatively labeling newly supplied assistant/tool input, and explicit null enum policies bypass the new invalid-policy path.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/security.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Motivation & Context
A private security review identified several cases where FIDES could lose or weaken information-flow state across transcript replay, MCP result retention, hidden argument validation, durable serialization, and invalid tool metadata. These gaps could cause policy decisions to use less restrictive integrity or confidentiality information than the data warranted.
This change hardens
SecureAgentConfigand the FIDES middleware pipeline while preserving restored session state and approval-resume behavior. Context-provider message labeling remains separate follow-up work because context providers are trusted plugins with an existing documented trust boundary.Description & Review Guide
_meta.ifcin an independently bounded security carrier so generic Host-payload budget exhaustion cannot discard the label; malformed or unretainable supplied IFC metadata fails closed.invalid_policyviolation.Related Issue
N/A - security hardening based on a privately reported issue. Per
SECURITY.md, vulnerability details are not tracked in a public GitHub issue; maintainer direction was explicitly confirmed before implementation. The context-provider labeling follow-up is tracked separately in #9645 and is intentionally not closed by this PR. No competing open PR was found.AI Assistance
AI assistance details: GitHub Copilot assisted with the security assessment, implementation, regression tests, documentation updates, and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.