Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:20000419 Fauxnix Trusted PowerShell Host Selection

From Leeroopedia
Knowledge Sources
Domains Host_Selection, Security, PowerShell
Last Updated 2026-10-26 00:00 GMT

Overview

A security-sensitive host selection technique that resolves the PowerShell executable from a trusted, drive-absolute system path by default, and only searches PATH for an opt-in Core host while excluding the current working directory.

Description

Trusted PowerShell Host Selection prevents PATH-tampering attacks. By default (no FAUXNIX_PS), the Desktop host (5.1) is resolved from %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe — a trusted, drive-absolute path that cannot be shadowed by a planted powershell.exe earlier in PATH. The SystemRoot env var is validated as drive-absolute before use. When FAUXNIX_PS=pwsh is set, the function searches PATH entries for pwsh.exe but excludes the current working directory and non-absolute entries, so a planted pwsh.exe in cwd cannot be selected. An invalid FAUXNIX_PS value returns an error rather than falling back silently. The selection is resolved once per session and reused for all invocations.

Usage

Use this principle whenever a tool must spawn a system shell on behalf of an untrusted or semi-trusted source. The trusted-default + opt-in-PATH-search pattern balances security (no PATH trust by default) with flexibility (opt-in Core support).

Theoretical Basis

if FAUXNIX_PS unset:
  executable = SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe
  validate SystemRoot is drive-absolute; validate executable exists
elif FAUXNIX_PS == 'pwsh':
  for each absolute PATH entry (excluding cwd):
    candidate = entry\pwsh.exe; if exists(candidate): return candidate
  error: pwsh.exe not found in eligible PATH entries
elif FAUXNIX_PS == 'powershell':
  same as default (Desktop), but marked as configured
else:
  error: invalid FAUXNIX_PS value

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment