Repository navigation
JS: Report command injection through child_process argument arrays when shell is enabled - #22978
Open
vishalshetagar wants to merge 2 commits into
Open
vishalshetagar wants to merge 2 commits into
vishalshetagar wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Description of the fix
js/command-line-injectionnow reports remote input that reaches the argument array ofspawn/execFilewhen theshelloption is set totrueor a nonempty string, including their synchronous variants.All three routes are now reported by
js/command-line-injection. Argument arrays in these examples withshell: false,shell: "", or noshelloption remain unreported.For
child_process.spawn,spawnSync,execFile, andexecFileSync, the command-injection sink modeling now reusesUnsafeShellCommandConstruction::ShellTrueCommandExecutionSinkfor shell-interpreted argument arrays.executesArrayAsShellalso recognizes nonempty string-valued shell paths, sojs/shell-command-constructed-from-inputhandles those calls as well. Thechild_processmodel recognizes the options argument inexecFilecalls with or without a callback.Testing
Regression checks cover boolean and string-valued shell options, synchronous variants, callbacks, promisified calls, and argument arrays built with
pushandunshift. Negative cases cover disabled or omitted shell options and constant arguments.All 66 targeted checks and the existing
CommandInjectionandUnsafeShellCommandConstructionquery test suites pass.Fixes #22825.