fix(cli): Windows PATH registration is unusable under Constrained Language Mode #59
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral#59
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up from the round-5 review of #47 (comment). Not a regression — #47's CLM handling never worked in the case it was written for.
Problem
_execute_path_operation(app/cli/adapters/windows_adapter.py) appends aWM_SETTINGCHANGEbroadcast guarded bytry { Add-Type ... } catch { Write-Output "CLM_FALLBACK" }, on the theory that Constrained Language Mode blocksAdd-Typeand the operator should then be told to open a new shell.Under real CLM the script never reaches that guard. The registry block above it calls:
CLM disallows method invocation on non-allowed .NET types, and
Microsoft.Win32.Registryis not on the allowed list. The registry block hastry ... finallywith nocatch, so the error propagates, PowerShell exits non-zero, and the operator gets:never the CLM warning. Conversely, when the
catchdoes fire (e.g.Add-Typeblocked by WDAC with no compiler available), the message asserts "Constrained Language Mode detected" and claims "Global PATH updated in registry" — which may be false.Proposed fix
Rewrite the PATH read/write to use
reg.exeinstead of .NET registry types.reg.exeis an external binary, so it is unaffected by CLM:reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path(returns the rawREG_EXPAND_SZvalue)reg add ... /v Path /t REG_EXPAND_SZ /d "<value>" /fThis keeps AC4's
REG_EXPAND_SZpreservation, which was the whole reason for avoiding[Environment]::SetEnvironmentVariable. The broadcast can stay as-is: under CLM it genuinely cannot run, and theCLM_FALLBACKwarning would then be both reachable and accurate.Parsing
reg queryoutput needs care (leading whitespace, theREG_EXPAND_SZtype token, values containing spaces). Worth a dedicated parser plus tests.Acceptance
REG_EXPAND_SZstill preserved;%SystemRoot%not corruptedCLM_FALLBACKonly emitted when the registry write actually succeededWhy
ready-for-humanThe change is specifiable, but nothing in this repo executes PowerShell, so it cannot be verified here. Shipping an unverifiable rewrite of the load-bearing path is what this issue exists to avoid repeating.
Related: #23, #47.
Triage resolution — 2026-09-23
Agent implementation and portable tests may proceed. Human Windows verification
is the merge gate, not a requirement to implement every part manually.
Retain the original PATH correctness requirements: successful registry access
under constrained-language execution, preservation of unexpanded values and
registry type, truthful broadcast-fallback reporting and distinct failure
diagnostics. Validate behavior rather than relying only on generated-script
substring assertions.
Before merge, the user must run the agent-prepared checklist on Windows Server
2019 under both normal and constrained-language execution and record the
results. Issue #60 tracks that verification. Linux tests alone cannot satisfy
the Windows acceptance criteria. A Windows CI runner is separate infrastructure
work and is not a prerequisite for beginning implementation.