Skip to content

.Net: Reject dot segments in session upload paths - #14646

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
mainfrom
sk-session-paths
Oct 23, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
mainfrom
sk-session-paths

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Motivation and Context

SessionsPythonPlugin.UploadFileAsync accepts a model-supplied remote file name. Unlike the Python implementation, the .NET path did not reject standalone . or .. path segments before placing that name in the multipart upload request. It also needed platform-independent handling for Windows separators and rooted, drive-qualified, or UNC names.

Rejecting those forms keeps uploads within the intended session data path while preserving ordinary file names and relative nested paths.

The .NET build matrix also began failing NuGet audit after a new advisory was published for the centrally pinned MessagePack 3.1.7 dependency. The first patched 3.x release is 3.1.9.

Description

  • Add a small remote file-name validator and run it before local file access or network I/O.
  • Treat both / and \ as path separators and reject dot segments, rooted names, drive prefixes, and UNC paths.
  • Document the remote path constraint in the kernel function parameter description.
  • Add targeted regression cases for unsafe path forms, rejection without an HTTP request, and valid nested or dot-containing names.
  • Update the central MessagePack pin from 3.1.7 to 3.1.9 so the required .NET build matrix passes NuGet audit.

Validation:

  • $env:GITHUB_ACTIONS='true'; dotnet build dotnet\samples\Demos\AgentFrameworkWithAspire\ChatWithAgent.AppHost\ChatWithAgent.AppHost.csproj -c Release --warnaserror --nologo — passed with 0 warnings and 0 errors.
  • dotnet test dotnet\src\Plugins\Plugins.UnitTests\Plugins.UnitTests.csproj --filter FullyQualifiedName~SessionsPythonPluginTests --no-restore --nologo — passed, 53/53 tests.
  • git diff --check — passed.
  • The repository-wide test suite and pre-submission formatting script were not run.

Contribution Checklist

Reject standalone . and .. path segments in model-supplied remote upload names before local file or network I/O, matching the existing Python protection.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:29
@semantic-kernel-automation semantic-kernel-automation Bot added the .NET Issue or Pull requests regarding .NET code label Oct 23, 2026
@github-actions github-actions Bot changed the title .NET: Reject dot segments in session upload paths .Net: Reject dot segments in session upload paths Oct 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.

🟢 Approval recommended

The narrowly scoped validation matches the stated requirements and has targeted regression coverage, with no unresolved findings.

No open issues 🎉

What changed in this PR

This PR adds remote upload filename validation to the .NET SessionsPythonPlugin, rejecting standalone . and .. path segments while preserving ordinary filenames and nested paths.

Changes:

  • Validate remote filenames before local file access or network I/O.
  • Document the restriction in API documentation and kernel parameter metadata.
  • Add regression tests for rejected paths, rejection without an HTTP request, and valid nested or dot-containing names.
File Description
dotnet/​src/​Plugins/​Plugins.UnitTests/​Core/​SessionsPythonPluginTests.cs Tests rejected dot segments and accepted filenames.
dotnet/​src/​Plugins/​Plugins.Core/​CodeInterpreter/​SessionsPythonPlugin.cs Adds early remote filename validation and documents the constraint.

Review effort: Balanced

Use the first patched 3.x release so NuGet audit no longer fails the .NET build matrix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread dotnet/src/Plugins/Plugins.Core/CodeInterpreter/SessionsPythonPlugin.cs Outdated
Treat both slash styles as remote path separators and reject rooted, drive-qualified, and UNC upload names before file or network I/O.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merged via the queue into main with commit 382fe5a Oct 23, 2026
19 checks passed

This branch was previously deployed

2 inactive deployments
integration — 43e1c0ed Deployed Oct 23, 2026 by eavanvalkenburg via dotnet-integration-tests #32850
github-app-auth — 43e1c0ed Deployed Oct 23, 2026 by eavanvalkenburg via add_label #29425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants