Skip to content

Security package SA: startup hooks off, inherited .NET settings named, launch-path variables from trusted sources - #48

Merged
donislawdev merged 1 commit into
mainfrom
fix/security-package-sa
Oct 6, 2026
Merged

donislawdev merged 1 commit into
mainfrom
fix/security-package-sa

Conversation

@donislawdev

Copy link
Copy Markdown
Owner

First package of the security review: what an elevated process inherits from the account that started it.

What changes

  • Startup hooks are off for every project (StartupHookSupport in Directory.Build.props). StartupHookGuards asks the running test host whether System.StartupHookProvider.IsSupported is on, and refuses any project that sets the property itself. The published single-file bws.exe carries false in its embedded runtimeconfig.
  • An elevated session names the .NET settings it inherits - profiler, EventPipe file, mini dump, diagnostic ports, and for the window the native-library unpacking folder. A program cannot switch these off for itself. The command line prints one sentence on stderr before reading anything (exit code unchanged), the window shows it in the red line under the list. Nothing changes without administrator rights.
  • Launch-path variables no longer come from this process's environment. Injected names (ProgramFiles, ProgramData, PUBLIC, SystemDrive and the x86 variants) come from sources measured not to follow the environment, and the machine block is read raw from the registry because Environment.GetEnvironmentVariables(Machine) expands it with this process's variables. A name nothing here knows stays as written, and a file not found under it is "not read" rather than "missing".
  • Documented, not closed: the window unpacks its native WPF libraries to the account's temporary folder (README Honest limits, FAQ in both languages, SECURITY.md).

No contract change: no JSON field, switch, exit code or snapshot schema.

How it was checked

  • Narrow test run: core 58/58, CLI 5/5, window 38/38, architecture 185/185, site 26/26.
  • Mutation entries for every new behaviour plus one re-anchored entry and neighbours: 15/15 caught.
  • tools/compat against the previous CLI build: 801 entries, identical field for field on an ordinary environment.
  • The published CLI with a dump switch set only for the child process prints the sentence and exits 0, and without it prints nothing.

Not checked

  • The window's sentence on a live window (test host only).
  • The new environment reading under a restricted token.

🤖 Generated with Claude Code

… and stop reading launch-path variables from our own environment

An elevated process inherits the environment of the account that started it, and that
environment can be written by a process of the same account without elevation. Three
consequences of that are closed or made visible here.

- StartupHookSupport is false for every project in Directory.Build.props. StartupHookGuards
  asks the running test host for System.StartupHookProvider.IsSupported rather than reading
  the property back, and refuses a project that overrides it.
- Profiler, trace, dump and diagnostic-port settings cannot be switched off from inside a .NET
  program, so an elevated session now names any it finds: the command line on the error
  channel before it reads anything, the window in the line under the list. Without
  administrator rights nothing changes.
- ManagerEnvironment no longer falls back to this process's environment. Injected names such
  as ProgramFiles and ProgramData come from sources measured not to follow it, and the
  machine block is read as written, because the framework's own reading expands it with this
  process's variables. A name nothing here can answer for stays as written, and a file not
  found under it is reported as not read rather than missing.
- README, the FAQ pages and SECURITY.md describe what is not closed: the window unpacks its
  native libraries to the account's temporary folder, and same-account code is handled as
  defence in depth rather than as a boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 93f2d322-2617-4bd5-9a5e-9bbbdbaff401
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@donislawdev
donislawdev merged commit 2218eab into main Oct 6, 2026
8 checks passed
@donislawdev
donislawdev deleted the fix/security-package-sa branch October 6, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant