-
Notifications
You must be signed in to change notification settings - Fork 83
mxc-sdk: diagnostic.js runs a PATH-resolved whoami at import time, even with diagnostics off #1265
Copy link
Copy link
Open
Labels
Area-Node-SDKNode.js and TypeScript SDK APIs, bindings, packaging, CLI integration, or tests.Node.js and TypeScript SDK APIs, bindings, packaging, CLI integration, or tests.Issue-BugSomething is not working as intended.Something is not working as intended.OS-WindowsApplies specifically to Windows hosts or Windows behavior.Applies specifically to Windows hosts or Windows behavior.Priority2High-impact issue affecting key functionality; prioritize for the next appropriate release.High-impact issue affecting key functionality; prioritize for the next appropriate release.
Description
Activity
Metadata
Metadata
Assignees
Labels
Area-Node-SDKNode.js and TypeScript SDK APIs, bindings, packaging, CLI integration, or tests.Node.js and TypeScript SDK APIs, bindings, packaging, CLI integration, or tests.Issue-BugSomething is not working as intended.Something is not working as intended.OS-WindowsApplies specifically to Windows hosts or Windows behavior.Applies specifically to Windows hosts or Windows behavior.Priority2High-impact issue affecting key functionality; prioritize for the next appropriate release.High-impact issue affecting key functionality; prioritize for the next appropriate release.
Package:
@microsoft/mxc-sdk0.8.0,dist/diagnostic.js.What happens
At module load,
diagnostic.jscomputesPIPE_NAMEby callinggetDiagnosticPipeName(). On Windows this runsexecSync('whoami /user /fo csv /nh', …). It runs on every import, whether or not the diagnostic console is enabled.execSyncgoes through the shell, sowhoamiis resolved fromPATH.Why it matters
whoamicomes beforeSystem32inPATH, that program runs instead. Git for Windows'usr/binis a common case. It printswhoami: extra operand '/user'on the host process's stderr. In a full-screenterminal application that text lands on top of the UI.
whoamifound earlier inPATHruns at import time with the host's rights, even though thecaller never enabled diagnostics.
Suggested fix (any of these)
%SystemRoot%\System32\whoami.exeby absolute path withexecFileSync(no shell).Repro
On Windows, put Git for Windows'
usr\binbeforeSystem32inPATH, then import the package, for example withnode --input-type=module -e "await import('@microsoft/mxc-sdk')". Thewhoamierror appears on stderr.