PowerShell / PowerShell/Win32-OpenSSH

Fix memory corruption and support WinPE

Open
#2,435 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Two distinct issues surface when running sshd on WinPE (a restricted
Windows environment with no user-profile service and no desktop /
window-station for non-interactive users). Both crash the daemon before
the user can log in.

  1. load_user_profile format-string mismatch.
    The debug3 call on LoadUserProfileW failure declares
    "%s %S %d" (three specifiers) but passes only two arguments. %S
    consumes GetLastError()'s DWORD as a wide-string pointer, then
    wcsnlen dereferences it and crashes sshd-session post-auth. Only
    visible where LoadUserProfileW actually fails (e.g. WinPE, which
    has no user-profile service), so stock Windows was unaffected.

  2. sshd-auth crashes on restricted window stations.
    sshd-auth is a privsep helper spawned as a different user and runs
    without desktop / window-station access. user32.dll's DllMain
    binds to the process window station and fails with
    STATUS_DLL_INIT_FAILED in restricted environments, so the helper
    dies before auth begins. The only transitive user32 references in
    sshd-auth come from console.c's ConRestoreViewRect_NoPtyHack
    (ShowWindow / GetWindowPlacement), which sshd-auth does not execute.
    Delay-loading user32 is sufficient: the DLL is never loaded in
    practice.

Depends on PowerShell/Win32-OpenSSH#2434 (shared build changes).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the LoadUserProfileW failure logging and console.c's ConRestoreViewRect_NoPtyHack references, then inspect the shared build changes from Win32-OpenSSH#2434. Confirm the format arguments no longer corrupt memory and that user32.dll is delay-loaded so sshd-auth starts in restricted WinPE environments without loading it.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.