Description
The Microsoft Agent Framework provides a robust security system (SecureAgentConfig) that protects against indirect prompt injection a well-documented attack class where untrusted content (emails, documents, API responses) contains hidden instructions that the AI agent follows. However, 98.9% of official samples (357 of 361) construct agents without any security configuration, modeling insecure patterns that developers copy into production.
Whats at risk
The frameworks own security.py (3,000+ lines) demonstrates Microsoft understands the threat:
SecureAgentConfig provides automatic security middleware
quarantined_llm processes untrusted content in isolation (no tools, explicit "do not follow embedded instructions" system prompt)
ContentLabel system tracks trust levels (trusted vs untrusted)
PolicyEnforcementFunctionMiddleware blocks tool execution when context is tainted
But SecureAgentConfig is a ContextProvider opt-in, not default. Developers who follow the official samples never see it.
Current state
Samples WITH SecureAgentConfig (4):
02-agents/security/email_security_example.py
02-agents/security/github_mcp_example.py
02-agents/security/repo_confidentiality_example.py
02-agents/devui/workflow_spam/workflow.py
Samples WITHOUT SecureAgentConfig (357): All "get started" tutorials, all provider examples (OpenAI, Anthropic, Foundry, GitHub Copilot, Gemini, Ollama), all hosting examples (Azure Functions, DurableTask, Container), all workflow examples, all migration examples (autogen, semantic-kernel), all end-to-end examples.
The problem
A developer following the official learning path:
01-get-started/01_hello_agent.py → builds first agent (no security)
01-get-started/02_add_tools.py → adds tools (no security)
02-agents/providers/openai/client_with_function_tools.py → adds function tools (no security)
04-hosting/azure_functions/01_single_agent/function_app.py → deploys to production (no security)
At no point does the developer learn about SecureAgentConfig, quarantined_llm, or ContentLabel. If their agent processes any external content (emails, documents, web pages, API responses, user-uploaded files), it is vulnerable to indirect prompt injection the same attack class documented in:
- GitLost (GitHub Agentic Workflows, July 2026) leaked private repos via prompt injection in issues
- Comment and Control (Claude Code, Gemini CLI, GitHub Copilot Agent, April 2026) credential theft via PR titles
- RoguePilot (GitHub Copilot in Codespaces, Feb 2026) GITHUB_TOKEN exfiltration via passive prompt injection
- CVE-2026-55145 (Outlook Copilot) prompt injection via email body
Suggested improvements
- Add
SecureAgentConfig to "get started" samples the first agent a developer builds should be secure by default
- Add a security note to samples that omit it a comment like
# Note: This sample does not include SecureAgentConfig. See 02-agents/security/ for production-ready security patterns.
- Consider making
SecureAgentConfig the default if context_providers is None, the framework could auto-include a basic security configuration
- Add a "Security" section to the getting-started guide between "add tools" and "multi-turn", introduce security as a first-class concept
- Cross-reference security samples from provider samples each provider example could link to the corresponding security sample
Why this matters
The framework has excellent security tooling, but its hidden in a security/ subfolder that most developers will never find. The samples that developers actually follow (get-started, providers, hosting) model insecure patterns. This is the AI equivalent of a web framework providing CSRF protection but not enabling it in any tutorial developers will build vulnerable applications because thats what the examples teach them to do.
Additional Context
This issue was identified during a security review of the repository. No exploitation was performed. The finding is based on static analysis of the sample code and comparison with the frameworks own security documentation in security.py.
Scan methodology: all .py files in python/samples/ containing Agent( constructor calls were checked for the presence of SecureAgentConfig, secure_agent, or quarantin references. Results: 4 secure, 357 insecure.
Description
The Microsoft Agent Framework provides a robust security system (
SecureAgentConfig) that protects against indirect prompt injection a well-documented attack class where untrusted content (emails, documents, API responses) contains hidden instructions that the AI agent follows. However, 98.9% of official samples (357 of 361) construct agents without any security configuration, modeling insecure patterns that developers copy into production.Whats at risk
The frameworks own
security.py(3,000+ lines) demonstrates Microsoft understands the threat:SecureAgentConfigprovides automatic security middlewarequarantined_llmprocesses untrusted content in isolation (no tools, explicit "do not follow embedded instructions" system prompt)ContentLabelsystem tracks trust levels (trusted vs untrusted)PolicyEnforcementFunctionMiddlewareblocks tool execution when context is taintedBut
SecureAgentConfigis aContextProvideropt-in, not default. Developers who follow the official samples never see it.Current state
Samples WITH SecureAgentConfig (4):
02-agents/security/email_security_example.py02-agents/security/github_mcp_example.py02-agents/security/repo_confidentiality_example.py02-agents/devui/workflow_spam/workflow.pySamples WITHOUT SecureAgentConfig (357): All "get started" tutorials, all provider examples (OpenAI, Anthropic, Foundry, GitHub Copilot, Gemini, Ollama), all hosting examples (Azure Functions, DurableTask, Container), all workflow examples, all migration examples (autogen, semantic-kernel), all end-to-end examples.
The problem
A developer following the official learning path:
01-get-started/01_hello_agent.py→ builds first agent (no security)01-get-started/02_add_tools.py→ adds tools (no security)02-agents/providers/openai/client_with_function_tools.py→ adds function tools (no security)04-hosting/azure_functions/01_single_agent/function_app.py→ deploys to production (no security)At no point does the developer learn about
SecureAgentConfig,quarantined_llm, orContentLabel. If their agent processes any external content (emails, documents, web pages, API responses, user-uploaded files), it is vulnerable to indirect prompt injection the same attack class documented in:Suggested improvements
SecureAgentConfigto "get started" samples the first agent a developer builds should be secure by default# Note: This sample does not include SecureAgentConfig. See 02-agents/security/ for production-ready security patterns.SecureAgentConfigthe default ifcontext_providersis None, the framework could auto-include a basic security configurationWhy this matters
The framework has excellent security tooling, but its hidden in a
security/subfolder that most developers will never find. The samples that developers actually follow (get-started, providers, hosting) model insecure patterns. This is the AI equivalent of a web framework providing CSRF protection but not enabling it in any tutorial developers will build vulnerable applications because thats what the examples teach them to do.Additional Context
This issue was identified during a security review of the repository. No exploitation was performed. The finding is based on static analysis of the sample code and comparison with the frameworks own security documentation in
security.py.Scan methodology: all
.pyfiles inpython/samples/containingAgent(constructor calls were checked for the presence ofSecureAgentConfig,secure_agent, orquarantinreferences. Results: 4 secure, 357 insecure.