Skip to content

.NET/Python: Improve MCP skill resource validation - #8690

Merged
SergeyMenshykh merged 5 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-issue-duplicate-check
Sep 24, 2026
Merged

SergeyMenshykh merged 5 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-issue-duplicate-check

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Collaborator

Motivation & Context

Strengthen MCP skill resource-name validation while preserving supported resource identifiers and URI schemes

Description & Review Guide

  • What are the major changes? Refine internal resource-name handling, update documentation, and expand unit coverage.
  • What is the impact of these changes? No public API changes. Existing MCP resource schemes remain supported.
  • What do you want reviewers to focus on? Cross-language consistency, compatibility, and test coverage.

Related Issue

N/A.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 23, 2026 13:27
@SergeyMenshykh SergeyMenshykh self-assigned this Sep 23, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Sep 23, 2026
@agent-framework-automation agent-framework-automation Bot added python Usage: [Issues, PRs], Target: Python .NET Usage: [Issues, PRs], Target: .Net labels Sep 23, 2026
@github-actions github-actions Bot changed the title .NET/Python: Improve MCP skill resource validation Python: .NET/Python: Improve MCP skill resource validation Sep 23, 2026
@github-actions github-actions Bot changed the title Python: .NET/Python: Improve MCP skill resource validation .NET: .NET/Python: Improve MCP skill resource validation Sep 23, 2026
@SergeyMenshykh SergeyMenshykh changed the title .NET: .NET/Python: Improve MCP skill resource validation .NET/Python: Improve MCP skill resource validation Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical encoded-delimiter traversal bypasses and additional URI/path validation issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Improves MCP skill resource-name validation across .NET and Python while preserving supported URI schemes.

Changes:

  • Adds layered decoding and unsafe-path validation.
  • Expands cross-language tests and documentation.
  • Adds .NET rejection logging.
File Description
python/​packages/​core/​tests/​core/​test_mcp_skills.py Expands validation and URI-scheme tests.
python/​packages/​core/​agent_framework/​_skills.py Implements layered resource-name validation.
dotnet/​tests/​Microsoft.Agents.AI.Mcp.UnitTests/​Skills/​AgentMcpSkillsSourceTests.cs Adds equivalent .NET test coverage.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​Loaders/​SkillMdEntryLoader.cs Propagates logging to MCP skills.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentMcpSkillsSource.cs Documents resource security behavior.
dotnet/​src/​Microsoft.Agents.AI.Mcp/​Skills/​AgentMcpSkill.cs Adds validation and rejection logging.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (1 commit(s)): e11dc4a66efb
Model: gpt-5.6-sol-fast

Overview

The PR adds cross-language validation for absolute paths, traversal at multiple percent-encoding depths, embedded URI forms, and control characters, with permissive-server tests confirming rejected names never reach the MCP transport. It also preserves valid resource identifiers and root schemes. Two gaps remain: encoded delimiters can hide encoded traversal from the segment check, and recursively decoding without a bound permits request-local CPU exhaustion.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: dotnet/src/Microsoft.Agents.AI.Mcp/Skills/AgentMcpSkill.cs

SergeyMenshykh and others added 3 commits September 23, 2026 15:08
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Split names at the first literal query/fragment delimiter, then decode the path and suffix independently. Make the Python decoder recursive with a bounded LRU cache that preserves the decoding depth limit.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for Python

@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Sep 24, 2026
Merged via the queue into microsoft:main with commit 024dd99 Sep 24, 2026
49 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-issue-duplicate-check branch September 24, 2026 17:27
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Sep 24, 2026

This branch was previously deployed

2 inactive deployments
github-app-auth — bd78e939 Deployed Sep 24, 2026 by SergeyMenshykh via add_label #23708
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants