Skip to content

mxc-sdk: diagnostic.js runs a PATH-resolved whoami at import time, even with diagnostics off #1265

Description

Package: @microsoft/mxc-sdk 0.8.0, dist/diagnostic.js.

What happens
At module load, diagnostic.js computes PIPE_NAME by calling getDiagnosticPipeName(). On Windows this runs
execSync('whoami /user /fo csv /nh', …). It runs on every import, whether or not the diagnostic console is enabled.
execSync goes through the shell, so whoami is resolved from PATH.

Why it matters

  1. On machines where another whoami comes before System32 in PATH, that program runs instead. Git for Windows'
    usr/bin is a common case. It prints whoami: extra operand '/user' on the host process's stderr. In a full-screen
    terminal application that text lands on top of the UI.
  2. Any executable named whoami found earlier in PATH runs at import time with the host's rights, even though the
    caller never enabled diagnostics.

Suggested fix (any of these)

  • Compute the pipe name lazily, only when the diagnostic console is enabled.
  • Run %SystemRoot%\System32\whoami.exe by absolute path with execFileSync (no shell).
  • Obtain the SID without spawning a process.

Repro
On Windows, put Git for Windows' usr\bin before System32 in PATH, then import the package, for example with
node --input-type=module -e "await import('@microsoft/mxc-sdk')". The whoami error appears on stderr.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-Node-SDKNode.js and TypeScript SDK APIs, bindings, packaging, CLI integration, or tests.Issue-BugSomething is not working as intended.OS-WindowsApplies specifically to Windows hosts or Windows behavior.Priority2High-impact issue affecting key functionality; prioritize for the next appropriate release.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions