Repository navigation
Python: block reparse points in Monty file capture - #9364
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Path validation remains vulnerable to a swap before read_bytes() reopens the file.
1 open finding
What changed in this PR
Hardens Monty’s attachment capture against Windows reparse-point traversal.
Changes:
- Detects symlinks, junctions, and reparse points during capture.
- Adds fail-closed and Windows junction regression tests.
| File | Description |
|---|---|
_execute_code_tool.py |
Adds secure-path validation during capture. |
test_monty_codeact.py |
Covers junctions, failures, and unchanged files. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): ad29dce3dd2d
Model: gpt-5.6-sol
Overview
This change strengthens Monty attachment capture by replacing symlink-only checks with the shared link/reparse-point predicate, classifying entries with lstat, and revalidating each path component before reading. The new tests cover Windows junctions created before and after the snapshot, fail-closed probe errors, unchanged files, and replacement detected by the second validation. The panel found residual path-open and aggregate-capture risks, but base-source comparison established that both predate this PR, so there is no publishable PR-introduced finding.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Jose Alvarez (jpalvarezl)
left a comment
There was a problem hiding this comment.
Reviewed the complete change and surrounding mount/capture code. I found no additional issues beyond the existing unresolved atomic path-swap thread, which remains the blocker to approval.
Open each captured file once, require the descriptor to match the validated lstat identity, and revalidate the path after opening so a file or ancestor swapped for a link after validation is skipped. Add portable junction-model and swap-after-validation tests.
|
Jose Alvarez (@jpalvarezl) the atomic path-swap thread is addressed in 01911a7 (details and the remaining Windows limitation are in the thread), and all checks are green on the new commit. Thanks for the review. |

Motivation & Context
Monty's post-execution file capture scans read-write mounts for new or modified files to return as attachments. On Windows, directory junctions and other reparse points are not always reported by
Path.is_symlink(), so the host-side capture walker could traverse beyond the configured mount. This change keeps attachment capture limited to real regular files under the mount root.Description & Review Guide
O_NOFOLLOWwhere available) with every path component revalidated after opening. Add regression tests: real NTFS junctions on Windows, a portable junction model elsewhere, and swap-after-validation cases._read_validated_file. Windows has no no-follow open, so the read-time check narrows the replacement window rather than being kernel-atomic there.Related Issue
N/A - no public issue. This is a narrowly scoped correction to host-side file capture, and no competing open pull request was found.
AI Assistance
AI assistance details: Implementation, tests, design review, and this PR description.
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.