GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — Skip the AppLocker policy test files when no script policy is configured by azchohfi · Pull Request #28374 · PowerShell/PowerShell ConversationPR SummaryFixes #28372. On every start, This adds a check before the test files are written. They are skipped only when none of these has a policy:
A location counts as "no policy" only if it does not exist. The one exception is the CodeIdentifiers key: Windows can create it with just PR ContextMeasured on Windows 11 26100 (i9-10900K), Release builds of master 1aac7f5 with and without this change (the two outputs differ only in System.Management.Automation.dll), 40 interleaved runs, median of the paired differences with 95% confidence interval:
On this machine (no AppLocker or SRP policy) the build without the change writes two test files to %TEMP% per start and the build with it writes none; both report Tests:
I could not test with a real AppLocker or SRP policy because writing those policy keys needs admin rights. To check enforcement on a test machine (as admin):
I used GitHub Copilot to investigate this and to help write the change and tests; I reviewed the code and ran the tests above myself. PR Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsTo find the system-wide AppLocker policy, PowerShell writes two __PSScriptPolicyTest_* files to %TEMP% on every start, checks them with SAFER, and deletes them. When the machine has no AppLocker script rules and no Software Restriction Policy, the result is always Allowed. Check the places such a policy lives first and skip the test files when none of them has a policy: the compiled AppLocker script policy (%windir%\System32\AppLocker\Script.AppLocker), AppLocker script rules under HKLM\SOFTWARE\Policies\Microsoft\Windows\SrpV2\Script, and SRP under SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers in HKLM and HKCU. A CodeIdentifiers key with only AuthenticodeEnabled is treated as no policy. Anything that exists or cannot be read keeps the test. Co-authored-by: Copilot App <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
requested review from
a team,
Patrick Meinecke (SeeminglyScience) and
Travis Plunk (TravisEz13)
as code owners
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Changes recommendedThe WOW64 path lookup can miss an effective AppLocker policy and leave the session in FullLanguage, while additional policy-detection and test-reliability issues remain unresolved. 5 open issues
What changed in this PRThis PR addresses #28372 by reducing PowerShell startup overhead when no AppLocker script policy or Software Restriction Policy is detected, avoiding temporary policy-test files and their SAFER checks. Changes:
Review effort: Balanced
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. - Keep the AppLocker probe in 32-bit processes on 64-bit Windows, where the system directory is redirected. - Treat an existing SrpV2\Script key as a policy even when it is empty. - Fail the Pester test if the child pwsh exits with an error, and do not expect the test files when WDAC enforces lockdown. - Use the same helpers in the xUnit machine check. Co-authored-by: Copilot App <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers
Copilot code review
Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
At least 1 approving review is required to merge this pull request. Uh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Startup: the AppLocker probe costs about 40 ms on every pwsh start, also when no AppLocker policy existsUh oh!
There was an error while loading. Please reload this page. 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. | |||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |