fix: prevent shell injection by replacing exec() with execFile()#46
Open
electricjesus wants to merge 1 commit intobun913:mainfrom
Open
fix: prevent shell injection by replacing exec() with execFile()#46electricjesus wants to merge 1 commit intobun913:mainfrom
electricjesus wants to merge 1 commit intobun913:mainfrom
Conversation
Using exec() with string interpolation allows shell metacharacter injection when URLs or API-sourced values (e.g. testCaseKey) contain special characters. Switching to execFile() with argument arrays bypasses the shell entirely, eliminating the injection surface.
c751ef5 to
ef2db34
Compare
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
exec()(shell string interpolation) withexecFile()(argv array) insrc/commands/open.tsandsrc/play/tui/App.tsxtestCaseKeyfrom Zephyr API responses) contain shell metacharactersApp.tsx, data is now written viastdin.end()instead of being interpolated into aprintfshell commandMotivation
exec()spawns a shell and interprets metacharacters. If a Zephyr API response returned a craftedtestCaseKey(e.g.$(malicious-command)), or if ajiraBaseUrlconfig value contained shell metacharacters, arbitrary commands could execute on the user's machine.execFile()bypasses the shell entirely by passing arguments as an array, closing this injection surface.Changes
src/commands/open.tsexec(\open "${url}"`)`execFile("open", [url])src/play/tui/App.tsxexec(\printf '%s' "${testCaseKey}" | pbcopy`)`execFile("pbcopy", []).stdin.end(testCaseKey)src/play/tui/App.tsxexec(\open "${url}"`)`execFile("open", [url])Test plan
zephyr open <key>still opens the browser on macOS/Linux/Windowsoandekeybindings in the play TUI still open browser correctlyostill copies the test case key to clipboardbun run buildproduces bundle successfully)