Repository navigation
Measure whether the host property can replace the native console thunk - #10984
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
cac5e9f to
0a5b8e2
Compare
Measurement only. Changes no installer code and gates nothing. It is the prerequisite for the largest AV-shape reduction available, and it is built so that it can say no. ## What it decides `GetStdHandle` / `GetConsoleMode` / `SetConsoleMode` are three of the ten native imports left in `install.ps1`, and in `studio/setup.ps1` they are the ONLY reason that file carries the reflection-emit helpers, the child-process capability probe and a Device Guard CIM query at all -- roughly 300 lines whose entire purpose is colouring a banner. "Defines a dynamic assembly, P/Invokes kernel32, spawns a hidden child interpreter" is the densest malicious-looking region in either script, and VirusTotal's only high-severity Sigma hit on install.ps1 is `Potential WinAPI Calls Via CommandLine`, which is that probe. `$Host.UI.SupportsVirtualTerminal` is the documented replacement: the PowerShell console host runs the same enable-VT sequence on its own stdout at startup and reports the outcome. Whether it agrees on Windows PowerShell 5.1's conhost is a measurement, not a deduction, and being wrong prints raw escape sequences at a user instead of a banner. So this measures both answers side by side. ## Why an ordinary CI step could not answer it Actions captures stdout, so `[Console]::IsOutputRedirected` is true in every step and both answers come back as the redirected ones -- which is precisely the case the installers decide early and never reach the native path for. Confirming that: run locally under pwsh here, the property answers `True` while stdout is redirected, which is exactly why `Enable-StudioVirtualTerminal`'s `$script:StudioStdoutRedirected` early return has to stay whatever else changes. The console case therefore runs under `conhost.exe`, which allocates a real console so the child's stdout is a console handle and `GetConsoleMode` can answer. Results travel through a file, because that console's output goes nowhere a runner can read. Windows PowerShell 5.1 specifically, since it is the interpreter `install.rs:433-440` spawns and a different host implementation from pwsh 7. ## The control Without it this lane would be worthless. A `conhost` that silently failed to attach would leave both runs redirected, the two answers would trivially agree, and the job would report SAFE having measured nothing. So the console run must report `isOutputRedirected=False` before any verdict is printed; otherwise the job fails as an unmeasured console rather than a safe one. Three outcomes, all explicit: SAFE (the two agree at a real console), UNSAFE (they disagree, do not swap the implementation), or could-not-measure. There is no path where silence reads as success. The probe emits its own P/Invoke stubs rather than using `Add-Type`, so the lane that exists to remove a compiler does not introduce one, and it loads under RemoteSigned rather than a relaxed policy for the same reason. ## Verification - `Probe-VirtualTerminal.ps1` parses clean over 633 tokens; the workflow's inline step parses clean over 325. - Run for real under pwsh on Linux, where it degrades honestly: the property answers, the native call records `GetStdHandle` failing because kernel32 is absent, and nothing crashes. - `lint_workflow_triggers.py` clean over 51 workflows; `tests/studio/test_ci_shell_suite_coverage.py` and `tests/security/test_lint_workflow_triggers.py` green. Action SHAs pinned to the versions the rest of the repo already uses.
0a5b8e2 to
2a025e1
Compare
Verdict: SAFEMeasured on real Windows PowerShell 5.1.26100.33296 (
The control fired. The console-attached run really had a console ( The redirected row is the case the installers short-circuit on So Residual gap, stated rather than glossedThis is a hosted |
…is tree The rationale for replacing the native console thunk pointed at .github/workflows/windows-vt-preflight.yml, which lives in #10984 and so does not exist on this branch. An earlier revision pointed at docs/windows-installer-av-shapes.md, which no longer exists anywhere. Both read as authoritative and neither could be opened, which leaves the justification for deleting a native call unverifiable. Cite #10984 for the measurement and AV_SHAPES_RECORD for the record, since that travels with the repo, and add a guard so the next broken pointer fails a test instead of shipping.
…2025 The lane reported one global SAFE verdict after sampling windows-latest, which is Windows Server 2025 and is not what any user runs. The property and the startup virtual-terminal behaviour are supplied by the OS, so ConsoleHost and the in-box Windows PowerShell differ between images and agreement on one says nothing about another. Measure windows-latest, windows-2022 and windows-11-arm. The last is the only client SKU a hosted runner offers and so the closest thing here to the machine in the report. windows-2019 is not an option, GitHub retired it. fail-fast is off because one UNSAFE answer is the most valuable result this lane can produce and cancelling its siblings would lose the comparison. Each leg now states its own verdict and says it speaks for its own image; a summary job holds the combined claim and names what is still not covered, which is Windows 10 and x64 Windows 11 client. The probe records the OS caption, build and architecture, because a verdict that does not say which ConsoleHost produced it cannot be checked against the host a user reports. Artifacts are named per leg: upload-artifact refuses a duplicate name, so one shared name would have left a single leg's measurements.
|
@codex security review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f49780290
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Start-Process -FilePath $conhost -Wait -ArgumentList @( | ||
| $ps51, '-NoProfile', '-NonInteractive', | ||
| '-ExecutionPolicy', 'RemoteSigned', | ||
| '-File', $probe, '-OutFile', $console, '-Attached' | ||
| ) |
There was a problem hiding this comment.
Launch PowerShell rather than passing it to conhost
On every hosted Windows matrix leg, this starts conhost.exe as though its positional arguments were a child command line, but conhost's upstream argument parser treats that position as console-server plumbing rather than an executable to launch. Consequently the PowerShell probe never runs, console.json is never created, and the workflow always exits at the following existence check without producing a measurement. Start PowerShell through a launcher that requests the documented CREATE_NEW_CONSOLE process flag instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I checked this against the file you linked and against this lane's own output, and it does not hold in either place.
ConsoleArguments.cpp does treat an unrecognised positional as the start of a client command line, not as server plumbing. The final else of the parse loop is // If we encounter something that doesn't match one of our other args, then it's the start of the commandline followed by _GetClientCommandline(args, i, false); break;, and _GetClientCommandline builds _clientCommandline from that token onward. conhost.exe powershell.exe ... is the documented shape of launching a client under the classic host.
More directly, the lane has already run this on a hosted windows-latest leg and produced a measurement. From run 34944217155:
--- redirected (Actions step)
isOutputRedirected : True
SupportsVirtualTerminal : True
isOutputRedirected : False
SupportsVirtualTerminal : True
control: the console-attached run really had a console (isOutputRedirected=False)
VERDICT: SAFE. At a real console the property and the native call both answer True,
The second row is console.json, so the probe ran and wrote its result. The isOutputRedirected -eq $false gate immediately above the verdict exists for exactly the failure you describe: a conhost that silently did not attach would leave both runs redirected, the two answers would agree trivially, and the lane would refuse to report rather than pass. It reported, so a real console was allocated.
No change made.
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ad of emitting a P/Invoke thunk for it install.ps1 and studio/setup.ps1 both emitted a reflection-built type declaring GetStdHandle, GetConsoleMode and SetConsoleMode for one consumer: the ANSI colour banner. That cluster (a dynamic assembly, a kernel32 P/Invoke, and in setup.ps1 a hidden child interpreter to gate it) is the densest malicious-looking region in either script and the only thing behind the one high-severity Sigma rule VirusTotal reports, and it is decoration. Windows PowerShell's console host performs that exact sequence at startup and reports the outcome through $Host.UI.SupportsVirtualTerminal. The pre-flight in PR #10984 measured 5.1.26100 attached to a real console: the property answers True, the native call answers True, and the console mode read before touching it is already 0x7, so the SetConsoleMode was re-setting a bit the host had set. The property is also the stricter of the two, because TryTurnOnVirtualTerminal re-reads the mode after setting it while the deleted code trusted SetConsoleMode's return value. The redirected case is unchanged and still decided first, by $script:StudioStdoutRedirected, before the property is read, so the Tauri pipe path and the CLI are untouched. The emit apparatus itself stays in both files. setup.ps1's Get-NvidiaLibraryProbeType emits the nvml and nvcuda imports through the same gate, so its coverage in tests/python/test_windows_installer_native_type_fallback.py stays parametrised over both scripts; only the console-helper test is install-only. Rebuilt as one commit on current main.
…easurement says it was a no-op (#10999) * Windows installers: read the console's virtual terminal support instead of emitting a P/Invoke thunk for it install.ps1 and studio/setup.ps1 both emitted a reflection-built type declaring GetStdHandle, GetConsoleMode and SetConsoleMode for one consumer: the ANSI colour banner. That cluster (a dynamic assembly, a kernel32 P/Invoke, and in setup.ps1 a hidden child interpreter to gate it) is the densest malicious-looking region in either script and the only thing behind the one high-severity Sigma rule VirusTotal reports, and it is decoration. Windows PowerShell's console host performs that exact sequence at startup and reports the outcome through $Host.UI.SupportsVirtualTerminal. The pre-flight in PR #10984 measured 5.1.26100 attached to a real console: the property answers True, the native call answers True, and the console mode read before touching it is already 0x7, so the SetConsoleMode was re-setting a bit the host had set. The property is also the stricter of the two, because TryTurnOnVirtualTerminal re-reads the mode after setting it while the deleted code trusted SetConsoleMode's return value. The redirected case is unchanged and still decided first, by $script:StudioStdoutRedirected, before the property is read, so the Tauri pipe path and the CLI are untouched. The emit apparatus itself stays in both files. setup.ps1's Get-NvidiaLibraryProbeType emits the nvml and nvcuda imports through the same gate, so its coverage in tests/python/test_windows_installer_native_type_fallback.py stays parametrised over both scripts; only the console-helper test is install-only. Rebuilt as one commit on current main. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
unslothai#10984) * Measure whether the host property can replace the native console thunk Measurement only. Changes no installer code and gates nothing. It is the prerequisite for the largest AV-shape reduction available, and it is built so that it can say no. ## What it decides `GetStdHandle` / `GetConsoleMode` / `SetConsoleMode` are three of the ten native imports left in `install.ps1`, and in `studio/setup.ps1` they are the ONLY reason that file carries the reflection-emit helpers, the child-process capability probe and a Device Guard CIM query at all -- roughly 300 lines whose entire purpose is colouring a banner. "Defines a dynamic assembly, P/Invokes kernel32, spawns a hidden child interpreter" is the densest malicious-looking region in either script, and VirusTotal's only high-severity Sigma hit on install.ps1 is `Potential WinAPI Calls Via CommandLine`, which is that probe. `$Host.UI.SupportsVirtualTerminal` is the documented replacement: the PowerShell console host runs the same enable-VT sequence on its own stdout at startup and reports the outcome. Whether it agrees on Windows PowerShell 5.1's conhost is a measurement, not a deduction, and being wrong prints raw escape sequences at a user instead of a banner. So this measures both answers side by side. ## Why an ordinary CI step could not answer it Actions captures stdout, so `[Console]::IsOutputRedirected` is true in every step and both answers come back as the redirected ones -- which is precisely the case the installers decide early and never reach the native path for. Confirming that: run locally under pwsh here, the property answers `True` while stdout is redirected, which is exactly why `Enable-StudioVirtualTerminal`'s `$script:StudioStdoutRedirected` early return has to stay whatever else changes. The console case therefore runs under `conhost.exe`, which allocates a real console so the child's stdout is a console handle and `GetConsoleMode` can answer. Results travel through a file, because that console's output goes nowhere a runner can read. Windows PowerShell 5.1 specifically, since it is the interpreter `install.rs:433-440` spawns and a different host implementation from pwsh 7. ## The control Without it this lane would be worthless. A `conhost` that silently failed to attach would leave both runs redirected, the two answers would trivially agree, and the job would report SAFE having measured nothing. So the console run must report `isOutputRedirected=False` before any verdict is printed; otherwise the job fails as an unmeasured console rather than a safe one. Three outcomes, all explicit: SAFE (the two agree at a real console), UNSAFE (they disagree, do not swap the implementation), or could-not-measure. There is no path where silence reads as success. The probe emits its own P/Invoke stubs rather than using `Add-Type`, so the lane that exists to remove a compiler does not introduce one, and it loads under RemoteSigned rather than a relaxed policy for the same reason. ## Verification - `Probe-VirtualTerminal.ps1` parses clean over 633 tokens; the workflow's inline step parses clean over 325. - Run for real under pwsh on Linux, where it degrades honestly: the property answers, the native call records `GetStdHandle` failing because kernel32 is absent, and nothing crashes. - `lint_workflow_triggers.py` clean over 51 workflows; `tests/studio/test_ci_shell_suite_coverage.py` and `tests/security/test_lint_workflow_triggers.py` green. Action SHAs pinned to the versions the rest of the repo already uses. * Measure the console on every available Windows host, not just Server 2025 The lane reported one global SAFE verdict after sampling windows-latest, which is Windows Server 2025 and is not what any user runs. The property and the startup virtual-terminal behaviour are supplied by the OS, so ConsoleHost and the in-box Windows PowerShell differ between images and agreement on one says nothing about another. Measure windows-latest, windows-2022 and windows-11-arm. The last is the only client SKU a hosted runner offers and so the closest thing here to the machine in the report. windows-2019 is not an option, GitHub retired it. fail-fast is off because one UNSAFE answer is the most valuable result this lane can produce and cancelling its siblings would lose the comparison. Each leg now states its own verdict and says it speaks for its own image; a summary job holds the combined claim and names what is still not covered, which is Windows 10 and x64 Windows 11 client. The probe records the OS caption, build and architecture, because a verdict that does not say which ConsoleHost produced it cannot be checked against the host a user reports. Artifacts are named per leg: upload-artifact refuses a duplicate name, so one shared name would have left a single leg's measurements. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…easurement says it was a no-op (unslothai#10999) * Windows installers: read the console's virtual terminal support instead of emitting a P/Invoke thunk for it install.ps1 and studio/setup.ps1 both emitted a reflection-built type declaring GetStdHandle, GetConsoleMode and SetConsoleMode for one consumer: the ANSI colour banner. That cluster (a dynamic assembly, a kernel32 P/Invoke, and in setup.ps1 a hidden child interpreter to gate it) is the densest malicious-looking region in either script and the only thing behind the one high-severity Sigma rule VirusTotal reports, and it is decoration. Windows PowerShell's console host performs that exact sequence at startup and reports the outcome through $Host.UI.SupportsVirtualTerminal. The pre-flight in PR unslothai#10984 measured 5.1.26100 attached to a real console: the property answers True, the native call answers True, and the console mode read before touching it is already 0x7, so the SetConsoleMode was re-setting a bit the host had set. The property is also the stricter of the two, because TryTurnOnVirtualTerminal re-reads the mode after setting it while the deleted code trusted SetConsoleMode's return value. The redirected case is unchanged and still decided first, by $script:StudioStdoutRedirected, before the property is read, so the Tauri pipe path and the CLI are untouched. The emit apparatus itself stays in both files. setup.ps1's Get-NvidiaLibraryProbeType emits the nvml and nvcuda imports through the same gate, so its coverage in tests/python/test_windows_installer_native_type_fallback.py stays parametrised over both scripts; only the console-helper test is install-only. Rebuilt as one commit on current main. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Measurement only. Changes no installer code and gates nothing. It is the prerequisite for the largest AV-shape reduction available in the #10805 work, and it is deliberately built so that it can say no.
What it decides
GetStdHandle/GetConsoleMode/SetConsoleModeare three of the ten native imports left ininstall.ps1. Instudio/setup.ps1they are the only reason that file carries the reflection-emit helpers, the child-process capability probe and a Device Guard CIM query at all: roughly 300 lines whose entire purpose is colouring a banner.That matters because "defines a dynamic assembly, P/Invokes kernel32, spawns a hidden child interpreter" is the densest malicious-looking region in either script, and it is what VirusTotal's only high-severity Sigma hit on
install.ps1names (Potential WinAPI Calls Via CommandLine). Removing it is the single biggest reduction on the table, and unusually it removes code rather than rewiring it.$Host.UI.SupportsVirtualTerminalis the documented replacement: the PowerShell console host performs the same enable-VT sequence on its own stdout at startup and reports the outcome. Whether it actually agrees on Windows PowerShell 5.1's conhost is a measurement, not a deduction, and being wrong prints raw escape sequences at a user instead of a banner. So this reports both answers side by side and compares them.Why an ordinary CI step cannot answer it
Actions captures stdout, so
[Console]::IsOutputRedirectedis true in every step and both answers come back as the redirected ones, which is precisely the case the installers decide early and never reach the native path for.Confirming that rather than assuming it: run under pwsh on Linux, the property answers
Truewhile stdout is redirected. Which is also whyEnable-StudioVirtualTerminal's$script:StudioStdoutRedirectedearly return has to stay whatever else changes.The console case therefore runs under
conhost.exe, which allocates a real console so the child's stdout is a console handle andGetConsoleModecan answer. Results travel through a file, because that console's output goes nowhere a runner can read. Windows PowerShell 5.1 specifically, since it is the interpreterinstall.rs:433-440spawns and a different host implementation from pwsh 7, so pwsh's answer does not transfer.The control, without which this lane would be worthless
A
conhostthat silently failed to attach would leave both runs redirected, the two answers would trivially agree, and the job would report SAFE having measured nothing. So the console run must reportisOutputRedirected=Falsebefore any verdict is printed; otherwise the job fails as an unmeasured console rather than a safe one.Three outcomes, all explicit:
There is no path where silence reads as success.
The probe emits its own P/Invoke stubs rather than using
Add-Type, so the lane that exists to remove a compiler does not introduce one, and it loads under RemoteSigned rather than a relaxed policy for the same reason.Verification
Probe-VirtualTerminal.ps1parses clean over 633 tokens; the workflow's inline step over 325.GetStdHandlefailing because kernel32 is absent, and nothing crashes.lint_workflow_triggers.pyclean over 51 workflows.tests/studio/test_ci_shell_suite_coverage.pyandtests/security/test_lint_workflow_triggers.pygreen. Action SHAs pinned to the versions the rest of the repo already uses.What happens next
If this reports SAFE, the follow-up deletes the thunk from both scripts and about 300 lines from
studio/setup.ps1with it. If it reports UNSAFE the follow-up is cancelled, not forced. That is the point of measuring first.