Skip to content

.NET: Harden LocalCodeAct OS validation - #8239

Merged
westey (westey-m) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:fix-workflow-input-validation
Sep 10, 2026
Merged

.NET: Harden LocalCodeAct OS validation#8239
westey (westey-m) merged 2 commits into
microsoft:mainfrom
eavanvalkenburg:fix-workflow-input-validation

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation & Context

LocalCodeAct validation did not consistently apply its OS access policy across aliases, nested attributes, and derived values. This change makes the existing allow-list behavior consistent before generated code reaches execution.

Description & Review Guide

  • What are the major changes? Track OS-derived provenance across imports and value propagation, allow only lexical path transformations and read-only environment access, and add regression coverage that verifies rejected code never starts the runner.
  • What is the impact of these changes? Unknown OS-derived chains, reflective access, environment mutation, and process or network capability paths are rejected. The LocalCodeAct unit suite passes on .NET 10, and the validator compatibility matrix passes on Python 3.10 through 3.13.
  • What do you want reviewers to focus on? The explicit safe-chain policy and conservative provenance handling.

Related Issue

N/A — no high-confidence overlapping open issue identified.

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 the title prefix in sync automatically.

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.

🟡 Changes recommended

Two validation bypasses permit environment mutation and loss of OS provenance through shadowed builtin names.

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

Pull request overview

Hardens LocalCodeAct’s Python validator by tracking OS-derived values and enforcing explicit read-only policies before execution.

Changes:

  • Adds OS provenance tracking across imports, aliases, containers, and assignments.
  • Restricts OS path/environment operations and blocks reflective capability access.
  • Adds regression tests confirming rejected code never starts the runner.
File summaries
File Description
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/Resources/validator.py Implements OS provenance and access policies.
dotnet/tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/LocalExecuteCodeFunctionIntegrationTests.cs Expands allowed/rejected access coverage.
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/README.md Documents the hardened policy.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

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

Comment thread dotnet/src/Microsoft.Agents.AI.LocalCodeAct/Resources/validator.py
Comment thread dotnet/src/Microsoft.Agents.AI.LocalCodeAct/Resources/validator.py Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants