Repository navigation
Hold and verify every WinUI triage debugger DLL until triage finishes - #954
Conversation
The WinUI triage pass verified JsProvider.dll by path and the child process later loaded it by path, with nothing holding the file in between. The engine DLLs (dbgeng, dbghelp, dbgcore, dbgmodel, msdia140, symsrv) were never signature-checked at use time at all. Resolution now holds every DLL the child loads via VerifiedTool, verifies each one's Microsoft signature by its handle-resolved path, and hands the child those resolved paths. ResolvedTriageBinaries owns the holds and the service releases them only after the child has exited (waiting for a killed child to finish exiting). Engine files must resolve inside the engine directory under their own names, the child now requires --jsprovider, and an unsigned cached engine DLL is re-acquired. Fixes #923 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f0de6168-3f21-4efa-8844-f5ca8ff1b59c
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The timeout path can release verified DLL holds before a slowly terminating child has exited.
Review effort: Balanced
Findings: 1
What changed in this PR
Hardens WinUI crash triage against debugger-DLL replacement between verification and loading.
Changes:
- Holds and verifies every known debugger DLL through child-process exit.
- Requires the child to use the verified
JsProvider.dllpath. - Adds security, acquisition, lifecycle, and documentation coverage.
| File | Description |
|---|---|
XamlTriageService.cs |
Manages verified DLL lifetime and child termination. |
XamlTriageRunner.cs |
Requires the explicit provider path. |
XamlTriageBinaries.cs |
Resolves, verifies, and holds debugger DLLs. |
VerifiedTool.cs |
Generalizes documentation to native binaries. |
XamlTriageServiceWorkflowTests.cs |
Tests hold lifetime across child outcomes. |
XamlTriageRunnerTests.cs |
Tests required provider arguments. |
XamlTriageBinariesTests.cs |
Tests locking, signatures, links, and junctions. |
XamlTriageBinariesAcquisitionTests.cs |
Tests reacquisition of unsigned cache files. |
docs/debugging.md |
Documents signature and locking behavior. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
WaitForExit(30s) could return with the child still alive, releasing the verified DLLs while it ran. Wait until termination is confirmed instead. Also hand held files over through a using-scoped owner and use Path.Join for fixed file-name segments. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f0de6168-3f21-4efa-8844-f5ca8ff1b59c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f0de6168-3f21-4efa-8844-f5ca8ff1b59c
winui-dbgext.js was hash-checked by path and later loaded by path with .scriptload. A script can run debugger commands, so a swap in between was still code execution. EnsureExtensionAsync now returns the script held open, hashed by its handle-resolved path, and the child is given that path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f0de6168-3f21-4efa-8844-f5ca8ff1b59c
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The security-sensitive changes build successfully and 146 targeted tests pass, but downloaded-cache end-to-end triage was not exercised.
Review effort: Balanced
Findings: None
Resolved since last review (1)
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 7907 passed, 37 skipped out of 7944 tests in 1379.3s (+21 tests, -314.3s vs. baseline) Test Coverage✅ 86.4% line coverage, 80.9% branch coverage · ✅ +0.1% vs. baseline CLI Startup Time60ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 954Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 954Run Updated 2026-09-30 22:42:55 UTC · commit |
…ents (#1046) ## Description `winapp __xaml-triage` is a hidden verb: during crash analysis, winapp starts it as a separate process to host the Windows debugger engine (DbgEng). It loaded whatever `--bin` (`dbgeng.dll` and its DLLs), `--jsprovider` and `--ext` (a debugger script) it was given. Only the parent process verified them, so anyone could start a signed winapp.exe directly and point it at an arbitrary DLL. The child process now verifies what it loads instead of trusting its arguments: - **The debugger DLLs:** `dbgeng.dll`, its supporting DLLs and `JsProvider.dll` must be Microsoft-signed and from the same build, using the parent's own check (reused, not duplicated). Each file is held open with no write or delete sharing until the engine is done, so it can't be swapped between the check and the load. - **The script:** `--ext` must be the pinned `winui-dbgext.js`. A debugger script can `.load` any DLL, so checking the DLLs alone isn't enough. Anything else is refused with a plain error. ## Usage Example I used a harmless test DLL whose `DllMain` writes a marker file naming the process that loaded it. **Arbitrary `dbgeng.dll`:** `winapp __xaml-triage --dump x.dmp --bin <temp>\bin --jsprovider <temp>\bin\JsProvider.dll --ext ext.js` Before (`main`): ``` xaml-triage failed: Unable to find an entry point named 'DebugCreate' in DLL 'dbgeng.dll'. MARKER: arbitrary dbgeng.dll loaded into ...\cli-main\winapp.exe (pid 19624) ``` After: ``` xaml-triage failed: refusing to load the debugger from '...\bin' and '...\bin\JsProvider.dll': they must be Microsoft-signed debugger files from the same build. (no marker: the DLL was never loaded) ``` **Genuine Microsoft-signed debugger files plus a custom `--ext` script that `.load`s the test DLL:** - Before (`main`): exit 0, and the marker reports the test DLL loaded into `...\cli-main\winapp.exe`. - After: `xaml-triage failed: refusing to run '...\evil.js': it is not the pinned WinUI debugger extension.` No marker. **Real use (genuine signed files, pinned script, a real minidump):** still exits 0 and runs the WinUI triage commands. ## Related Issue Follow-up to #954. The same class of issue as the DevTools injection worker fix in #943. ## Type of Change - 🐛 Bug fix ## Checklist - [x] New tests added for new functionality (if applicable). `Run_UnsignedEngine_IsRefusedBeforeLoading` fails on `main` with `xaml-triage failed: Could not load '...\bin\dbgeng.dll'`, which shows the child really tries to load the file. Another new test covers refusing a non-pinned script. - [x] Tested locally on Windows ## Additional Notes - **Not covered:** a process already running as the same user can still get a DLL loaded, for example by planting a default debugger extension where DbgEng searches (`PATH`, `_NT_DEBUGGER_EXTENSION_PATH`, `%LOCALAPPDATA%\Dbg\EngineExtensions`, or a folder holding copies of the signed engine), or by planting a DLL next to a copy of `winapp.exe`. That user can already run code, so this PR doesn't try to stop them. #1073 stops `winapp.exe` loading its own imports (such as `version.dll`) from its folder. It can't cover DLLs that Windows' own DLLs import, so installing to a folder the user can't write to remains the real protection. --------- Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Zach Teutsch <88554871+zateutsch@users.noreply.github.com>

Description
The WinUI stowed-exception triage pass (run automatically by
winapp run --debug-outputwhen a WinUI app crashes) loads downloaded debugger DLLs into a child process. Before this change, winapp checkedJsProvider.dll's Microsoft signature and then handed only its path to the child, which loaded it later. Nothing kept the file in place in between, so anything able to write the debugger cache could replace it after the check and have its own code run as the user. The engine DLLs next to it (dbgeng.dll,dbghelp.dll,dbgcore.dll,dbgmodel.dll,msdia140.dll,symsrv.dll) were worse: their signatures were never checked when triage used them.Now every DLL the triage child loads is:
The WinUI debugger extension script (
winui-dbgext.js) gets the same treatment: it is held open, hash-checked by its resolved path, and kept locked until the child exits. A script loaded into the debugger can run debugger commands, so swapping it was also code execution.A layout that fails any of these is skipped, the same as before. A cached engine DLL that fails the signature check is downloaded again on the next run instead of disabling triage permanently. This reuses
VerifiedToolfrom #922, which does the same for build tools.Usage Example
No command or flag changes. Reproduction (real Windows Kits debugger layout, real triage child, unsigned payload DLL whose
DllMainwrites a marker file):The same result holds when swapping
dbgcore.dllinstead. On this branch, the genuineJsProvider.dllfrom the held Windows Kits layout still loads and runs a script in the triage child.Related Issue
Fixes #923
Type of Change
Checklist
Screenshots / Demo
N/A (no UI change; textual reproduction above).
Additional Notes
VerifiedTool/JsProvider-acquirer tests pass locally (1 existing environment-dependent test is inconclusive). They cover: files locked while held and released after; every loaded DLL checked by its resolved path; any single unsigned DLL rejecting the layout and releasing all holds; junction re-point; symlinked engine files; re-acquiring an unsigned cached engine DLL; holds lasting until the child exits, including a killed child that is slow to die; the extension script being held and a tampered cached copy being replaced; and the child requiring--jsprovider.scripts/build-cli.ps1 -SkipTests -SkipMsix -SkipNpmsucceeds, with no CLI schema change.__xaml-triagechild now requires--jsproviderrather than guessing<bin>\JsProvider.dll. It is only ever invoked by the same binary, so there is no external consumer.docs/debugging.mdnow states that every debugger DLL, including those in aWINAPP_DBGTOOLS_DIRlayout, must be Microsoft-signed, and that those DLLs and the extension script are locked while triage runs.