Skip to content
fmueckePublic

About

A launcher for repeatable least-privilege execution on Windows.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

launch-as Windows build

Launch-as is currently used in agent-win-sandbox to create a least-privilege session for a coding agent like Claude Code or GitHub Copilot CLI.

The first version was v0.3.2. Browse old stable v0.3.2 version. It creates the session via CreateProcessWithLogonW from the current user. However, this has some security implications due to derived logon session tokens:

  • Session user will be able to see and interact with the regular user's desktop.
  • For regular-user processes that retain the normal logon-SID default-DACL ACE, the session user can obtain PROCESS_VM_READ and PROCESS_TERMINATE, allowing memory reads and termination. Protected processes or processes with custom DACLs may not be accessible.

current version · Windows x64 · console and shared-desktop GUI programs

launch-as starts a program as a launch-as-managed local standard account through the launch-as-broker Windows service. The client never accepts, reads, stores, or transmits the account password. The broker creates an independent logon session, so the child does not inherit the caller's logon SID or its default access to the caller's processes.

This is a general-purpose alternate-account launcher: its authorised caller can choose a configured launch-as-managed account and any absolute executable. Default launches provide identity separation; --appcontainer-experimental-experimental adds Windows AppContainer confinement for console commands. Neither protects against a local administrator or kernel-level attacker. Interactive mode puts the target on the caller's shared desktop, so screen, window, clipboard, and input interaction are intentionally possible even though the target retains an independent logon SID.

Why not PsExec or runas.exe?

Both PsExec and runas.exe can start the agent under a dedicated Windows user, but they do not provide the isolation required by launch-as.

In testing, both approaches retain the interactive user's logon SID in the child token. Consequently, the sandboxed process can still access processes belonging to the interactive user (OpenProcess/VM_READ) and, when launched interactively, shares the user's desktop. Identity separation therefore does not establish the intended security boundary.

They also provide poor terminal integration: launching under the other user creates a separate console window rather than attaching the process cleanly to the existing terminal. This makes them unsuitable for workflows such as running an agent directly inside a VS Code integrated terminal.

launch-as instead creates an independent logon session with its own logon SID and provides terminal integration while preserving that boundary.

Install the binary package

Extract launch-as-v1.4.*-win64.zip and run the bundled setup script from its extracted directory. It elevates when needed, installs or updates the demand-start service and all four executables into %ProgramFiles%\launch-as, and can create a default account. Updating takes over that account and replaces its broker-owned password. The user who runs a fresh install becomes the broker's authorised caller, including after a prior uninstall; updates preserve that caller policy. Setup rejects a candidate whose launch-as.exe SemVer is lower than the installed client version; an equal version is a repair reinstall.

.\Setup-LaunchAs.ps1

The package contains launch-as.exe, launch-as-admin.exe, launch-as-broker.exe, launch-as-conhost.exe, Microsoft's ConPTY (conpty.dll and OpenConsole.exe), this README, the setup script, the license, and the third-party notices. Keep all binaries together while installing; setup copies them to %ProgramFiles%\launch-as with protected permissions. That directory is deliberately not added to PATH; invoke the installed client by its full path or add it to your own user PATH if desired.

For non-interactive automation, select an action explicitly and use -Force to accept the documented account/password-reset or uninstall operation:

.\Setup-LaunchAs.ps1 -Command Install -Force
.\Setup-LaunchAs.ps1 -Command Update -Force
.\Setup-LaunchAs.ps1 -Command Uninstall -Force

Setup

For automation or individual elevated administration operations, use launch-as-admin.exe. Run these commands from the extracted package directory (or out\build\Release after a source build):

.\launch-as-admin.exe install
.\launch-as-admin.exe create LaunchAsUser

install, create, forget, delete, and uninstall require elevation. install stops active broker sessions before updating the service and copies all launch-as executables. uninstall removes the service and every launch-as executable from %ProgramFiles%\launch-as; it retains registered Windows accounts and %ProgramData%\launch-as enrollment data. create <account> creates a dedicated account and fails if that name already exists. Use create <account> --takeover to deliberately reset an existing account's password and make it launch-as-owned. Taking over a disabled account requires --force to re-enable it. A forced takeover also creates the account when it is missing; without --force, a missing account fails.

The broker creates a password for each launch, uses it to reset and log on to the account, then clears its plaintext copy. A managed account supports up to two concurrent sessions; the broker supports four sessions globally. Further launches fail immediately. forget stops launch-as from managing the account without changing the Windows account. delete removes a SID-matched owned Windows account after its sessions end; neither command deletes its profile directory.

.\launch-as-admin.exe list
.\launch-as-admin.exe create LaunchAsUser --takeover
.\launch-as-admin.exe forget LaunchAsUser
.\launch-as-admin.exe uninstall

Launch

From a normal terminal, launch a configured launch-as-managed account in the current pane:

.\launch-as.exe `
    --user LaunchAsUser `
    --working-directory C:\dev\project `
    -- C:\Windows\System32\cmd.exe /d /k

run is an optional spelling of the same command. The client starts the demand-start broker, creates the terminal data pipes, and returns the target program's exit code. The broker owns the temporary launch password and kills the console job when the client control connection closes.

For a GUI program, select interactive mode explicitly:

.\launch-as.exe `
    --mode interactive `
    --user LaunchAsUser `
    --working-directory C:\dev\project `
    -- C:\Windows\System32\notepad.exe

The launcher holds a temporary ACL lease for the target's unique logon SID on the caller's WinSta0\Default objects and session BaseNamedObjects directory. It stays running until the complete GUI process tree exits and the broker releases that lease.

Known limitation: interactive windows use the classic, unthemed style. The Windows Themes service only serves processes that hold the caller's logon SID, which the child deliberately lacks. At high DPI, Windows draws this classic frame with visible glitches, such as undersized or misplaced caption buttons; window contents still scale correctly.

Security limitation: Interactive mode shares the caller's UI and named-object namespace. The child can create named objects or subdirectories there, potentially squatting on predictable names to spoof IPC or deny service to other applications. The directory grant is non-inheritable and leaves existing object ACLs unchanged; the child retains its independent logon SID. Use console mode or a separate RDP, Windows Sandbox, or VM session when this shared access is unacceptable. Removing the lease does not revoke handles already opened or delete objects kept alive by other processes. Abrupt launcher termination can leave lease grants behind.

AppContainer-based sandboxes started by the child, such as wxc-exec process containers, need --allow-container-creation:

  • Interactive mode: creating the container token fails with ERROR_ACCESS_DENIED, because it needs session directory rights the default lease does not grant. The switch leases them too: READ_CONTROL on BaseNamedObjects, and query, traverse, create object and create subdirectory on \Sessions\<caller-session>\AppContainerNamedObjects.
  • Console mode: the container starts, but a target that loads user32, such as PowerShell, exits with STATUS_DLL_INIT_FAILED. The launch's hidden session-0 window station grants only the managed account. With the switch, the console host grants all restricted application packages (S-1-15-2-2) access to that window station and its desktop.

Security limitation: in interactive mode the child can create objects in the caller session's AppContainer namespace, including pre-creating the namespace of an AppContainer app that has not started yet; this can affect the caller's packaged apps. In console mode, any AppContainer process can use the launch's hidden desktop. Only pass the switch when the child needs to start containers. wxc-exec cannot create its container at Low integrity, so don't combine the switch with --low-integrity for wxc-exec.

Console and interactive launches support these controls:

  • --restrict-access adds a WRITE_RESTRICTED token with the target user, its independent logon SID, and Everyone as restricting SIDs. Everyone keeps common Windows tools working. It also restricts reads through temporary folder denies. Normal read access remains available to Windows, Program Files, Program Files (x86), the target profile, and working directories. On each launch the broker ensures explicit account-SID denies on other existing base folders of mounted local volumes and on sibling folders along the allowed paths. It ensures traversal through allowed roots and their ancestors without granting new write rights. Ancestors retain normal directory-listing permissions, so names of excluded sibling folders can be visible while access through those folders remains denied. It changes only folder DACLs, without propagating ACEs or editing individual file DACLs. It removes traversal bypass from the launch token, so protected child ACLs cannot bypass a base deny through ordinary paths. No new write permissions are granted; profile and working-directory writes retain normal ACL requirements.

  • --low-integrity independently lowers token integrity to Low. Combine it with --restrict-access for both controls. Descendants inherit the token controls. Without --restrict-access, reads follow normal ACLs.

Console launches also support --appcontainer-experimental-experimental-experimental, with zero capabilities by default:

.\launch-as.exe --user LaunchAsUser --working-directory C:\dev\project `
    --appcontainer-experimental-experimental-experimental-experimental-experimental -- C:\Windows\System32\cmd.exe

Repeat --appcontainer-experimental-experimental-experimental-capability <name-or-SID> to grant capabilities explicitly, for example internetClient, privateNetworkClientServer, or a capability SID such as S-1-15-3-1. These network capabilities also permit DNS-service requests; leave them absent when preventing service-mediated DNS exfiltration is the goal. Windows derives custom capability names too, so a misspelled name can produce an ineffective capability rather than an error. Only S-1-15-3-... capability SIDs are accepted. At most 32 distinct input values are supported. AppContainer currently requires console mode and cannot combine with --restrict-access or --low-integrity.

Experimental limitation: AppContainer setup is coupled to launching a command. Separating capability and loopback configuration from execution, with explicit provisioning, session start/stop and cleanup, remains an open design discussion; see TODO.md.

The terminal host stays outside the container; the command and its descendants run inside it at Low integrity. The broker adds an inheritable Modify grant on the managed profile and workspace roots. It verifies the account's existing read/write/execute access and pins each root and its ancestors before changing the root ACL. On every launch, Windows propagates the grants to existing children while impersonating the managed account, using its ordinary metadata permissions. Protected child ACLs remain unchanged. New children inherit access normally. Integrity labels remain unchanged; AppContainer package grants permit writes to Medium-integrity files. Explicit inheritable Medium labels can prevent new-file creation (error 1314); setup does not override that policy. Volume roots, Windows, Program Files, ProgramData and the common Users directory are rejected.

Existing files that the managed account cannot update may still need preparation by their owner. Use the printed AppContainer SID: S-1-15-2-... and apply ordinary Windows inheritance:

$containerSid = 'S-1-15-2-...' # Replace with the printed SID.
icacls.exe C:\dev\project /grant "*${containerSid}:(OI)(CI)M"

This propagates permissions where the owner has normal metadata rights. Automatic propagation already covers account-owned profile and workspace contents; it never uses SYSTEM rights on descendants. Files that do not inherit can remain inaccessible. The profile name and its grants are specific to the account, workspace path and resolved capabilities. AppContainer profiles and grants remain after exit, including failed launches. Moving a prepared tree preserves its ACLs. Hard links share one ACL: propagation under the account's metadata rights can expose a linked file through its names outside the workspace too. Junctions do not grant access to their targets. Existing AppContainer/capability grants and Windows resources accessible to All Application Packages remain available: this is not an exact two-directory allowlist. Place agent runtimes in the workspace, managed profile or a location already readable by AppContainers, such as Program Files, so the confined command can load its dependencies. Preparation failures record the operation and path in the broker log, collected by --log.

Network policy remains external. For a local model proxy, use its numeric address http://127.0.0.1:8080 and prepare a loopback exemption separately if required. Each launch prints AppContainer: launch-as-...; an administrator can use that name with CheckNetIsolation.exe LoopbackExempt -a -n=<printed-name>. The exemption permits loopback for that identity, including other localhost ports; enforce the permitted endpoints through your WFP policy. Remove an exemption with LoopbackExempt -d -n=<printed-name>.

A disposable Windows Sandbox probe observed zero DNS packets for GetAddrInfoW, DnsQuery_W and DnsQueryEx in a zero-capability container, with successful receiver controls. The DNS APIs returned access denied. A loopback exemption allowed a TCP connection to 127.0.0.1:8080 without enabling those DNS requests. This is bounded evidence for those APIs and that guest, not a guarantee against all DNS/exfiltration paths. A reachable proxy or localhost service that resolves attacker-selected names can still provide an exfiltration path. See the AppContainer network analysis for the DNS-service capability check.

Read restriction uses one shared scope per account. Working directories accumulate until the last session and its descendants close; then the broker removes its temporary ACEs, preserving unrelated ACL entries. Restricted and unrestricted sessions cannot overlap for the same account. Other processes using that account can also be affected by the ACLs. The broker also holds directory handles until restoration to prevent replacement races. These pins block rename and deletion of visited directories for every user, including allowed roots, their ancestors, and denied base folders. Children inside allowed trees are ordinarily unpinned. Closing the account's last session releases the pins. Interactive launches temporarily grant the account traversal through Windows session namespace directories, allowing runtime startup without restoring filesystem traversal bypass. Mounted filesystems must support persistent ACLs. Launch fails if the scope cannot be prepared. Empty optical and removable drives reporting "not ready" are skipped. Media inserted during a session is outside the restriction until another launch; loaded filesystems still need ACL support. Restoration failures are audited and prevent scope reuse until restoration succeeds. Abrupt broker termination can leave denies in place. New base folders and mounted volumes are covered only by the next launch. Loose files in allowed-path ancestors, including drive roots, retain normal access. File-ID opens bypass folder denies; remote shares, unmounted volumes, previously opened handles, and hard-link aliases in allowed trees are also outside this path restriction. Allowed system trees retain their normal ACLs and the existing write-restricted-token behavior; this does not make them uniformly read-only. The token retains only the account's existing working-set privilege, disabled, for tools such as whoami; traversal bypass and all other privileges are removed. Windows normalized-name queries (GetFinalPathNameByHandleW with FILE_NAME_NORMALIZED) can return access denied without traversal bypass, even for allowed files. Tools that require these queries can be incompatible with --restrict-access.

Add --log to append launch steps, folders selected for deny, folders excluded from deny, allowed-path ancestors, skipped empty drives, and ACL restoration to %LOCALAPPDATA%\launch-as\launch-as.log for the caller. The client collects the broker's diagnostics when the launch attempt returns and when its session closes. Entries include the request ID, account, path, and Win32 result; command arguments and credentials are omitted. The broker also retains these diagnostics in Windows Event Log → Application, source launch-as-broker, event ID 7. Shared-scope tracing there stays enabled until final restoration. Scope decisions are copied under each active logged request's ID. Closing or failed requests stop receiving them. Final restoration reaches the text log when a logged session closes the scope; if only unlogged sessions remain, later decisions stay in Event Log. Read the text log with:

Get-Content "$env:LOCALAPPDATA\launch-as\launch-as.log" -Tail 100

With --low-integrity, the broker labels the profile and working tree Low using the target account's permissions. Accessible existing children are relabelled; new files and directories inherit Low. Medium items normally need Full Control for relabelling; already-Low items retain normal ACL requirements. Launch fails if either root cannot be prepared. Locked or inaccessible children, reparse points, and files with multiple hard links remain unchanged and may be read-only. Volume roots, Windows, Program Files, ProgramData, and the common Users directory are rejected. Labels persist after exit and may be partially applied on failure. Preparation permits at most 128 levels below either root and 100,000 examined objects across both trees. It checks a shared 30-second deadline between objects and directory batches; pending filesystem calls cannot be interrupted. Exceeding a depth or object limit fails the launch with ERROR_NOT_ENOUGH_QUOTA; deadline expiry returns ERROR_TIMEOUT. Already-applied labels persist on these failures too.

Low integrity limits writes to Low-labelled objects whose ACLs permit access. With both flags, writes must also pass the restricting-SID check. This is not a two-directory allowlist: previously labelled trees and other writable Low locations remain accessible. SMB shares, filesystems without integrity enforcement, network access, and services acting on the workload's behalf are outside this control. Never run unrelated programs unconfined as the managed account: they could execute content changed in its writable profile.

Build and test

The source build requires Visual Studio/MSVC, a Windows SDK, CMake 3.25+, PowerShell, ninja, and clang-format 22 or newer. Run build.ps1 from the repository root; it initializes the MSVC environment when needed and builds the Ninja Multi-Config Release target by default.

Local builds format sources by default. Use -SkipFormatting to build without running clang-format; CI uses this switch to build the checked-in sources unchanged.

.\build.ps1
.\build.ps1 -Configuration Debug
.\build.ps1 -RunTests
.\build.ps1 -RunSandboxTests
.\build.ps1 -RunAllTests
.\build.ps1 -PackageRelease

-PackageRelease performs a clean Release build in out\release-build and writes the distributable out\release\launch-as-v<version>-win64.zip package.

-RunTests runs every host-safe, noninteractive CTest test. The privileged audit, account-provisioning, and service-installer executables are built but are not registered with CTest. -RunSandboxTests runs those three executables and the process launcher's session-privilege regression as SYSTEM inside a fresh Windows Sandbox without elevating or changing the host. The privilege regression starts from SYSTEM's enabled TCB state, checks the broker's startup adjustment, then concurrent thread-local TCB scopes and cleanup after success and failure. It is excluded from the process launcher's normal host-safe CTest invocation. Installed GUI acceptance also checks that the running broker's process token retains TCB in a disabled state. The runner downloads a pinned revision of the Windows Sandbox test helper and verifies its SHA-256 before import.

-RunAllTests runs the local and automated Sandbox sets, then asks whether to run interactive acceptance in another fresh guest. Declining the prompt completes the automated run. Run the interactive workflow directly with:

.\build.ps1 -RunAcceptanceTest

The acceptance runner opens a fresh Windows Sandbox and drives it without guest command entry or a UAC prompt. The existing elevated Sandbox user creates LaunchAsDevCaller, temporarily adds it to Administrators so that its SID becomes the broker's authorised installer, then removes that group membership. A fresh standard-user logon with a real visible console runs the acceptance suite against the reserved LaunchAsDevTestUser managed account. The workflow checks console identity, process isolation, disconnect teardown, same-account concurrency, and one installed-service interactive GUI launch through the public CLI. It returns the result through the shared test directory, restores temporary desktop permissions, and destroys the guest.

No test entry point requires a broker service or managed test account on the host. Interactive acceptance requires Windows Sandbox with wsb.exe and a visible guest desktop, but no manual guest interaction. The production broker service and pipe names are intentional: they exist only inside the disposable guest and cannot conflict with a host installation.

The console probe confirms a distinct logon SID, no interactive windows, and denied VM_READ and TERMINATE access to the caller's process. The interactive probe confirms caller-session WinSta0\Default placement, a different target logon SID, a visible window, and lease release after the target tree exits. Crash recovery, RDP, Fast User Switching, launcher disappearance, and broker restart remain additional interactive acceptance cases. These are blast-radius controls, not protection from a local administrator or kernel-level attacker.

Design

launch-as-broker-spec.md describes the console (ConPTY) and interactive shared-desktop adapters, their different lifetimes, and their security boundaries.

License

launch-as is licensed under the GNU General Public License version 3 only. Source for this version is available at https://github.com/fmuecke/launch-as.

About

A launcher for repeatable least-privilege execution on Windows.

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages