Skip to content

Python: Add windows junction detection for skills - #7507

Open
westey-m wants to merge 1 commit into
microsoft:mainfrom
westey-m:python-skills-windows-junctions
Open

Python: Add windows junction detection for skills#7507
westey-m wants to merge 1 commit into
microsoft:mainfrom
westey-m:python-skills-windows-junctions

Conversation

@westey-m

@westey-m westey-m commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

Description & Review Guide

  • What are the major changes?
  • What is the impact of these changes?
  • What do you want reviewers to focus on?

Related Issue

Fixes #

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.

Copilot AI lite review requested due to automatic review settings August 4, 2026 14:55
@westey-m
westey-m temporarily deployed to github-app-auth August 4, 2026 14:55 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth August 4, 2026 14:55 — with GitHub Actions Inactive
@westey-m
westey-m temporarily deployed to github-app-auth August 4, 2026 14:55 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 4, 2026
@github-actions github-actions Bot changed the title Add windows junction detection for skills Python: Add windows junction detection for skills Aug 4, 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.

🟡 Not ready to approve

A newly added test (test_link_probe_detects_windows_reparse_attribute) will fail on non-Windows platforms because it asserts a Windows-only stat constant without skipping.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR hardens Python skill and file-access path handling on Windows by treating directory junctions (and other reparse points) as disallowed “link-like” path segments, closing an escape vector similar to symlinks.

Changes:

  • Added a shared private helper (is_link_or_reparse_point) for detecting symlinks, junctions, and Windows reparse points.
  • Updated file-based skills discovery/validation to reject any path containing a symlink or reparse point segment (fail-closed on probe errors).
  • Consolidated junction creation helpers in tests and added coverage for junction/reparse-point detection.
File summaries
File Description
python/packages/core/agent_framework/_filesystem.py Introduces shared link/reparse-point detection helper used by security checks.
python/packages/core/agent_framework/_skills.py Extends skill resource/script scanning and resource validation to treat reparse points like symlinks (and fail closed on probe errors).
python/packages/core/agent_framework/_harness/_file_access.py Reuses the shared helper to consistently filter/deny link-like filesystem entries.
python/packages/core/tests/core/conftest.py Adds a reusable create_junction_or_skip test helper for Windows junction creation.
python/packages/core/tests/core/test_skills.py Updates symlink tests to new API name and adds a junction guard test.
python/packages/core/tests/core/test_harness_file_access.py Switches to shared junction helper and adds a unit test for the Windows reparse-attribute fallback.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread python/packages/core/tests/core/test_harness_file_access.py

@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.

Automated Code Review

Reviewers: 5 | Confidence: 55% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by westey-m's agents

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _filesystem.py13192%19
   _skills.py13447094%321, 591, 1109, 1124, 1126–1127, 1493–1494, 1736, 1765, 2281, 2471, 2989–2990, 3092, 3100, 3105, 3108, 3114, 3134, 3146, 3151, 3247, 3255, 3260, 3263, 3269, 3289, 3298, 3303, 3572–3573, 4030, 4033, 4035–4036, 4038, 4189, 4516, 4531, 4539, 4566, 4570, 4574, 4637–4638, 4640–4641, 4653, 4657, 4693–4694, 4698–4699, 4743–4745, 4751, 4800, 4804, 4808, 4818–4820, 5022–5023, 5045–5046, 5053–5054
packages/core/agent_framework/_harness
   _file_access.py6264992%189, 220, 283, 393, 395, 407, 411, 439, 452–453, 460–467, 471, 475, 841–842, 867, 871, 926–928, 950–953, 992, 994, 1051, 1053, 1458–1459, 1470–1471, 1483–1484, 1498–1499, 1522–1523, 1538, 1543–1544, 1573
TOTAL44476411290% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9115 35 💤 0 ❌ 0 🔥 2m 27s ⏱️

@westey-m
westey-m enabled auto-merge August 4, 2026 15:15
return

if FileSkillsSource._has_symlink_in_path(resolved_target, root_directory_path):
if FileSkillsSource._has_link_or_reparse_point_in_path(resolved_target, root_directory_path):

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.

Could we reject a junction before _discover_skill_directories adopts it as the skill_dir? Path.is_dir() follows a child junction, and every check here starts from that junction as root_directory_path, so the junction itself is never inspected and its external SKILL.md, resources, and scripts are loaded. I think this breaks the configured-root trust boundary and can lead to prompt injection or arbitrary script execution when skill approvals are disabled.

Would it make sense to probe each discovery entry with is_link_or_reparse_point before descending, failing closed on OSError?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants