Repository navigation
Protect property assignment on non-core objects to NoteProperty members in Constrained Language Mode - #28206
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
PSSetMemberBinder
Justin Chung (jshigetomi)
marked this pull request as ready for review
October 14, 2026 21:43
Justin Chung (jshigetomi)
requested review from
a team,
Patrick Meinecke (SeeminglyScience) and
Dongbo Wang (daxian-dbw)
as code owners
October 14, 2026 21:43
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Security-boundary changes need human validation of enforcement, cached bindings, and audit behavior, with a regression-coverage gap remaining.
1 open finding
What changed in this PR
Strengthens Constrained Language property-assignment restrictions for non-core objects.
Changes:
- Restricts instance-member writes to exact
PSNotePropertymembers, with audit-mode logging. - Removes the non-instance setter exemption for
ToString. - Adds rejection tests for instance ScriptProperty and AliasProperty assignments.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 | Adds constrained-language assignment tests. |
| src/System.Management.Automation/engine/runtime/Binding/Binders.cs | Enforces setter restrictions and audit logging. |
| src/System.Management.Automation/engine/parser/Compiler.cs | Caches reflection metadata for the new setter helper. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| constrainedTargetType = targetValue.GetType(); | ||
| } | ||
|
|
||
| if (!CoreTypes.Contains(constrainedTargetType)) |
Dongbo Wang (daxian-dbw)
approved these changes
Oct 19, 2026
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.

PR Summary
This pull request strengthens property-setting restrictions in Constrained Language mode in PowerShell, ensuring that only
NotePropertyinstance members can be set on user objects, and that attempts to set other property types (such asScriptPropertyorAliasProperty) are properly blocked and audited. The changes also add targeted tests to verify this behavior.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header