Repository navigation
fix(hooks): pin the module path before every hook line resolves a command - #65
Merged
Merged
Conversation
…mand
Windows PowerShell 5.1 and pwsh load a command such as Get-Variable from
the first module on PSModulePath that exports it. A module that the
account puts first on that path, in its own module folder, or in the
working directory of a 5.1 without a documents folder turned the guard's
denial into exit 0 (R12-02, R12-08).
All 15 PowerShell lines of hooks.json and the 3 of the contributor-profile
asset now start their inner command with
[Environment]::SetEnvironmentVariable('PSModulePath',
[IO.Path]::Combine([AppContext]::BaseDirectory, 'Modules')), and the
closing statement makes the same call first. No hook script changes.
HookContract accepts only the new closing statement and runs every payload
with a tripwire module where the PowerShell of each spawn looks first.
Migration: derive pinned hooks.json files again, re-pin hooks.json and the
verifier in every containment profile, and refresh ~/.copilot.
Co-authored-by: AI Assistant <ai@example.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The review of 4667dd7 ran three hand edits of the contained guard line against HookContract, and each passed although a planted module then turned a denial into exit 0: aliases before anything else, every name module-qualified, and a pin with a profile folder first (R18-01). HookContract now requires the interpreter to get its text with -Command, that text to start with the shipped pin, compared as typed, and no second PSModulePath after it, as it requires the shipped closing statement; a line that fails is refused before anything runs. The tripwire stays as a second net, with a narrowed claim. The Windows PowerShell 5.1 wrapper is first asked which folder it looks in first, and runs with PSModulePath removed where the machine sets none (R18-04, R18-06). XDG_DATA_HOME is removed for the tripwire's spawns, and its placement is tested on every platform (R18-05). The records state that the outer 5.1 of VS Code looks for powershell in its modules when PATH lacks it (R18-02); the hook authoring Instruction no longer shows an unpinned launcher (R18-03). The planted-module cases get a positive control, and test messages drop ANSI escapes that broke the NUnit report (R18-08). hooks.json, the asset and every hook script are unchanged; the verifier changes. Co-authored-by: AI Assistant <ai@example.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…he pin The re-review of 34de586 (R18-09) passed six hand edits after the pin through HookContract while a planted module or script answered for the guard: the module path set again under another spelling (a computed name, an Env:PSModuleP* wildcard, New-Item Env:), Import-Module by path, an alias to a script by path, and a nested pwsh. The records said that assigning the module path again is refused. The hooks README (the HookContract row, gap 4 and the section on the containment profile), docs/SECURITY-REVIEW.md and the CHANGELOG now say what the check refuses: a -Command text that does not start with the exact pin, a later mention of PSModulePath by name, -File, -EncodedCommand, a line without a command, and any closing statement but the exact one. They name the six forms by kind and tell operators to keep the inner -Command text of every line exactly as shipped. No code changes; the verifier stays at 32558cf0. Co-authored-by: AI Assistant <ai@example.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Align decision 0016 with the closing statement that pins the module path first (R18-07): a dated note names the pin, the new statement of the windows and powershell launchers, and the entry of 2026-11-14 in docs/SECURITY-REVIEW.md; last-verified moves to 2026-11-14. activeContext.md makes brief 18 the current focus, names brief 19, the owner's publish step, as next, moves brief 15 to the previous focuses, records the residual of brief 18, and narrows brief 12's. progress.md gains the brief 18 milestone and drops the oldest one, so both files stay under 180 lines. systemPatterns.md adds one sentence to the hooks bullet: a hook line pins its module path through .NET types before any command. Co-authored-by: AI Assistant <ai@example.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
raandree
added a commit
that referenced
this pull request
Nov 16, 2026
Brief 19 published the stack of briefs 13, 16, 17, 12, 14, 15 and 18 as #59 to #65, each squash tree equal to its rebased tip and each pull request's CI green on Ubuntu, macOS and Windows. #62's first CI failed one relay row off Windows, a fixture gap that a test-only fix in its squash closed; the CI-platform pattern records the lesson. ~/.copilot was redeployed from bd28133. The active context moves the merged briefs to previous focuses and names the owner's remaining steps. Progress records the milestone and the newest preview, and curates the oldest milestone. Co-authored-by: AI Assistant <ai@example.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Brief 18: every PowerShell hook line, the 15 of
hooks.jsonand the 3of the contributor-profile asset, pins the module path of each
PowerShell process it runs in to that interpreter's own
Modulesfolder before it resolves a command by name. A module that the run
identity can plant for Windows PowerShell 5.1 no longer answers for the
push guard or the grant recorder (R12-02, R12-08). The inner
-Commandstarts with the pin, and the closing statement makes the same call
first, with the exit codes it gave before. No hook script changed: the
guard, the grant recorder and the appender keep their digests.
HookContractaccepts only the new closing statement, holds the-Commandtext of a pinned line to the exact pin, refuses a latermention of
PSModulePathby name,-File,-EncodedCommandand aline without a command, and runs every payload with a tripwire module
of its own as a second net.
Option 3 was decided under the owner's delegation; merging this is the
owner's explicit answer.
Validation: every new test red first; mutants on copies 12 of 12, then
25 of 25. The full gate before the Memory Bank commit passed 6,231
tests, 0 failed, 145 skipped, coverage 91.61 %. Review: Request
changes (R18-01 Major), re-review Approve with changes (R18-09, taken
as records); all fixed.
Open: code after the pin is read only for a mention of
PSModulePath,so keep the inner
-Commandtext exactly as shipped; the outer 5.1 ofVS Code looks
powershellup in its modules when itsPATHlacks it;the host's environment, a writable
$PSHOME, and the barepowershellandpwshstay open. The Ubuntu and macOS legs firstran, green, in an early read of the whole stack (run 43695341208),
where the eight planted-module controls passed on Windows; they fail
rather than skip where a runner's 5.1 does not search a planted
place.
Re-pin once merged, deriving every pinned
hooks.jsonagain from theshipped
PreToolUseentry:32558cf02a594aa2922f8614bb897cab1d651d4f46932a653c98d77801842842
hooks.json:ed05f232b68d0715b5c351d50234f9250ef14b8139801fb5810c9b825512cb14
contributor-profile.hooks.json:e553312ef5d9051e510b08a19894a48f0a4bf819998901e22e7652de01ff1eec
Rebased onto main unchanged: the tree is the brief's recorded tip
plus brief 12's test fix (b69cb23), which main already holds.
Co-authored-by: AI Assistant ai@example.com
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com