Repository navigation
xaml-triage child: verify what it loads instead of trusting its arguments - #1046
Conversation
… arguments The hidden __xaml-triage verb hosts DbgEng in winapp.exe and loaded whatever --bin, --jsprovider and --ext it was given; only the parent verified them. A signed winapp could therefore be started directly to load an arbitrary DLL. The child now, before loading anything: - holds and verifies dbgeng.dll, its supporting DLLs and JsProvider.dll with the parent's own check (Microsoft-signed, same build), with no write or delete sharing; - requires --ext to be the pinned winui-dbgext.js (a script can .load any DLL); - copies the verified engine files into a folder it creates and runs the engine from there, because DbgEng also loads default extension DLLs found beside the engine (the pinned script triggers that); the copies are held and re-verified. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Review found two ways around the private engine folder: - DbgEng takes extension and symbol-server search paths from _NT_* variables, which whoever starts the child controls; they are now cleared first. - Another process running as the same user could add a default-extension DLL to the folder before the engine searched it. The folder is now locked after the copy (OWNER RIGHTS removes the owner's ability to change permissions back), and anything present besides the copied files is refused. Also fixes CA1861 in the new test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Administrators keep full control of the folder, so an elevated process (as on CI) is not denied. The staged-contents check still runs everywhere. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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. ✅ 10465 passed, 43 skipped out of 10508 tests in 1935.2s (+2 tests, +100.3s vs. baseline) Test Coverage✅ 87.2% line coverage, 81.4% branch coverage · ✅ no change vs. baseline CLI Startup Time63ms median (x64, Updated 2026-10-16 17:17:14 UTC · commit |
Use 'using' for the original debugger holds and the staged folder in tests, and Path.Join in the new tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Zach Teutsch (zateutsch)
left a comment
There was a problem hiding this comment.
🤖 AI-generated review (winappcli pr-review skill) — verify before acting.
Changes requested. The hardening is the right shape, and every layer is needed for the threat it targets. But a same-user process can still undo the new staging-folder lock (reproduced, details inline). The other two inline comments are non-blocking.
What was exercised: dotnet test --filter XamlTriage (134 passed, 1 skipped); a Debug __xaml-triage run against the real signed arm64 debugger cache (files verified, copied, re-verified, ACL applied, cleanup worked); and two local reproductions of the lock bypass. The Windows Kits layout was not available, so the ext.dll comment is from reading the code only.
Same-user processes can already run code, and a copied winapp.exe loads a planted version.dll, so the copy-and-lock folder added cost (about 40 MB per run) without stopping that user. Keep the signature, pinned-script and _NT_* checks that stop the child being pointed at arbitrary files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Whoever sets the environment also controls PATH, which DbgEng searches for default extensions, so clearing _NT_* didn't close that route. It only took _NT_SYMBOL_PATH symbols away from developers who rely on it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
out of date
Follow-up to #1046. ## What was wrong `winapp.exe` statically imports several DLLs that aren't KnownDLLs (`version.dll`, `bcrypt.dll`, `crypt32.dll`, `iphlpapi.dll`, `ncrypt.dll`, `secur32.dll`). Windows searches the exe's own folder for those first. A DLL with one of those names placed next to `winapp.exe` gets loaded into the signed process. ## What changed The published exe sets the PE dependent-load flag to `LOAD_LIBRARY_SEARCH_SYSTEM32` (`/DEPENDENTLOADFLAG:0x800`). winapp.exe's own static imports now resolve only from System32. Runtime `LoadLibrary` calls (dbgeng, UI Automation, SkiaSharp, etc.) are unaffected. ## Repro: copy `winapp.exe` into an empty folder, add a junk `version.dll`, run `winapp.exe --version` | | Result | |---|---| | Before | exit `0xC000012F` (planted DLL was loaded) | | After | exit 0, prints the version | After the fix, junk copies of all six direct imports placed together also leave `--version` and `--help` at exit 0. `dumpbin /loadconfig winapp.exe` (Release publish): | | Dependent Load Flag | |---|---| | win-x64 before | `0000` | | win-x64 after | `0800` | | win-arm64 after | `0800` | ## Limitation This reduces the obvious case. It doesn't close it. I planted each of the ~220 non-KnownDLL names from the full import chain next to the fixed exe, one at a time. Two are still loaded from the exe's folder: - `sspicli.dll`, imported by Windows' `crypt32.dll` and `advapi32.dll` - `ntasn1.dll`, imported by Windows' `ncrypt.dll` Those system DLLs don't set this flag, and the exe's flag only applies to the exe's own imports. Any exe in a user-writable folder has this exposure. The real protection is installing to a location the user can't write to. ## Verification - `dotnet publish -c Release` for win-x64 and win-arm64 succeeds. The published `winapp --version` and `winapp --help` exit 0. - The exe has no delay-loaded imports, so this flag doesn't apply to anything loaded later at runtime. - Each check below ran the published x64 exe before and after the change. Results were identical: - `ui inspect` and `ui screenshot` against a running app work. The composite screenshot loads the bundled `libSkiaSharp.dll` from the exe's folder at runtime. - The `__xaml-triage` child loads dbgeng, JsProvider and the WinUI extension against a dump and produces the same output. - `perf start` / `stop` / `analyze` against a running WinUI 3 app: the ETW providers are enabled the same way. - The gated UI tests that drive the published exe (`WINAPP_UI_MULTIPROCESS_TESTS=1`, `InteractiveDesktop*`, `UiCommandTests`) passed 897/900. One was an intentional skip. The two failures were `foreground_not_target` focus races on a shared desktop. On reruns the baseline exe also failed one of them, and the fixed exe passed both twice. - No user-facing behavior change, so no doc updates. Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
winapp __xaml-triageis 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.dlland its DLLs),--jsproviderand--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:
dbgeng.dll, its supporting DLLs andJsProvider.dllmust 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.--extmust be the pinnedwinui-dbgext.js. A debugger script can.loadany 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
DllMainwrites 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.jsBefore (
main):After:
Genuine Microsoft-signed debugger files plus a custom
--extscript that.loads the test DLL:main): exit 0, and the marker reports the test DLL loaded into...\cli-main\winapp.exe.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
Checklist
Run_UnsignedEngine_IsRefusedBeforeLoadingfails onmainwithxaml-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.Additional Notes
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 ofwinapp.exe. That user can already run code, so this PR doesn't try to stop them. Resolve winapp.exe's own DLL imports from System32 only #1073 stopswinapp.exeloading its own imports (such asversion.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.