Fix OS command injection in convertToSingleHost.js manifest update - #232
Open
Zheng (zhngx1) wants to merge 2 commits into
Open
Fix OS command injection in convertToSingleHost.js manifest update#232Zheng (zhngx1) wants to merge 2 commits into
Zheng (zhngx1) wants to merge 2 commits into
Conversation
Contributor
|
Make sure to fix the other template repos and run 'npm audit fix' to pickup any new vulnerability fixes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an OS command injection vulnerability (CWE-78) in convertToSingleHost.js where the
projectNameandappIdcommand-line arguments were interpolated into a shell command string and executed viachildProcess.exec.Problem
The manifest-update step built a command string from untrusted
process.argvvalues and ran it through a shell:Because
execruns its argument through a shell (cmd.exe or /bin/sh), shell metacharacters (;,&&,`,$(),|) inappIdorprojectNamewere interpreted.appIdwas also completely unquoted. If an integrator forwarded untrusted input into these arguments, this allowed arbitrary command execution.Fix
childProcess.exec(shell) withchildProcess.execFile(..., { shell: false })and an argument array, soappIdandprojectNameare passed as literal arguments and can no longer inject commands.process.execPath(the running Node binary) viarequire.resolve("office-addin-manifest/cli.js"), instead of the npx/npx.cmd shim. This also fixesspawn EINVALon Node 24+, which refuses to run .cmd shims throughexecFilewithout a shell.