Repository navigation
Keep an elevated window's native libraries in a folder only administrators can change - #52
Merged
Merged
Conversation
…s can change when it runs elevated An elevated window whose native libraries were unpacked under the temporary folder now starts once more with them in <drive of Windows>\ProgramData\BetterWindowsServices, a folder made with a protected list (SYSTEM and Administrators full control, OWNER RIGHTS read) and examined at every elevated start, level by level and file by file. A folder that cannot be made, cannot be read, can be changed by others or is a link refuses the start with a user32 box that says which folder and why. Without elevation, or outside a single-file bundle, nothing changes. The window has a Main of its own and App.xaml is a Page, because constructing the WPF application already loads the first library from the folder. The rule lives in Bws.Core (Unpacking, AdministratorsFolder), the restart and the box in Elevation.cs. One IL3000 suppression, counted in AnalyzerRuleGuards, recognises the bundle by its empty assembly location. The dead-code scan learns that the runtime calls a static Main. Security report S-1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README, the FAQ in both languages and SECURITY.md said the window loads the libraries it unpacks from the account's temporary folder and suggested setting DOTNET_BUNDLE_EXTRACT_BASE_DIR by hand. An elevated window now keeps them in ProgramData\BetterWindowsServices, checks that folder at every start and refuses to start when it cannot be trusted, so the advice is replaced by what the program does and what it costs: a second start and about 8 MB per version left in that folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What changes
An elevated window no longer loads WPF's native libraries from a folder other accounts can write to (security report S-1).
Main, before anything of WPF exists, where the runtime loads native libraries from. Anywhere but<drive of Windows>\ProgramData\BetterWindowsServicesit prepares that folder (protected list: SYSTEM and Administrators full control, OWNER RIGHTS read, owner Administrators), starts itself once more withDOTNET_BUNDLE_EXTRACT_BASE_DIRpointing there, and ends. Every elevated start examines the folder level by level down to the files. A folder that cannot be made, cannot be read, can be changed by others or is a link refuses the start with a user32 box naming the folder and what to do.How it is built
Bws.Core:Unpacking(the pure rule) andAdministratorsFolder(the descriptor rule, making and examining the folder).Bws.Gui:Program.Mainof its own,App.xamlas a Page, the restart and the box inElevation.cs(already the one file allowed to start a process and already outside coverage).[UnconditionalSuppressMessage]for IL3000, counted inAnalyzerRuleGuards: the bundle is recognised by its empty assembly location, the one documented fact for it.MessageBoxadded to the window's Win32 inventory and toOutboundRegisters.Main.Checked
wpfgfx_cor3.dllfrom the ProgramData folder, whose list is the protected one above. Without elevation it loads from the temporary folder in one process. The build from before this change loads from the temporary folder both ways.Not checked
Mainof the real window (the 64-67 ms second start was measured on a smaller probe).🤖 Generated with Claude Code