Python: Reject Windows junctions in FileSystemAgentFileStore - #7291
Merged
eavanvalkenburg merged 3 commits intoJul 27, 2026
Merged
Conversation
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:02 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:02 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:02 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:03 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:05 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:05 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Python FileSystemAgentFileStore containment boundary on Windows by treating NTFS directory junctions (and other reparse points) as link-like entries during listing and recursive search, preventing enumeration from escaping the configured root.
Changes:
- Introduces a shared
_is_link_or_reparse_point()predicate (symlink + junction + Windows reparse attribute) and uses it across direct path validation, directory listing, and recursive search enumeration. - Updates link/reparse probing to be
lstat()-based and fail-closed when link/reparse status cannot be determined. - Adds a Windows regression test that creates a real directory junction and asserts that read/list/search do not traverse it.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_harness/_file_access.py | Adds unified link/reparse detection and applies it consistently to validation, listing, and recursive search enumeration. |
| python/packages/core/tests/core/test_harness_file_access.py | Adds a Windows junction regression test and updates the fail-closed probe test to patch Path.lstat. |
Contributor
Author
|
@microsoft-github-policy-service agree |
sricursion
marked this pull request as ready for review
July 23, 2026 13:38
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 13:38 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 15:55 — with
GitHub Actions
Inactive
sricursion
temporarily deployed
to
github-app-auth
July 23, 2026 15:59 — with
GitHub Actions
Inactive
eavanvalkenburg
approved these changes
Jul 27, 2026
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
westey-m
approved these changes
Jul 27, 2026
Contributor
Author
|
Thanks Eduard and Westey. |
This was referenced Jul 30, 2026
Merged
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 & Context
FileSystemAgentFileStorepromises root-scoped access and rejects linked or reparse paths during direct operations, but its directory listing and recursive search paths only checkedPath.is_symlink(). On Windows, directory junctions are reparse points that do not report as symlinks, sofile_access_grepcould descend outside the configured root.Description & Review Guide
lstat(), POSIX link mode,Path.is_junction()when available, and the Windows reparse attribute fallback. Apply it to direct path validation, directory listing, and recursive search, and add a Windows regression test with a real directory junction.FileSystemAgentFileStorenow consistently omits symlinks, junctions, and other reparse points from listing and search, preventing recursive file access from crossing the configured root. Existing regular-file behavior and public APIs are unchanged.Related Issue
Fixes #7290
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.