fix: prevent command injection in project script execution#17
Open
iamarsenibragimov wants to merge 1 commit into
Open
fix: prevent command injection in project script execution#17iamarsenibragimov wants to merge 1 commit into
iamarsenibragimov wants to merge 1 commit into
Conversation
run_script() previously executed arbitrary shell commands from .envx/config.yaml without any validation or user confirmation. A malicious config (e.g. via a crafted PR) could achieve RCE. Three layers of defense added: - Command validation: block ~30 dangerous patterns (curl, wget, sudo, eval, rm -rf /, ssh, nc, etc.), null bytes, and excessively long commands (>4096 bytes) - Two-phase execution: run_script() now takes a `confirmed` parameter; when false it returns ScriptInfo without executing, allowing callers to display the command first - Interactive confirmation: CLI shows the full command, source config path, and env vars before prompting [y/N]
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
run_script()previously executed arbitrary shell commands from.envx/config.yamlwithout validation or user confirmation, allowing RCE via malicious config filesrun_script()to a two-phase API: returnsScriptInfofor review before execution[y/N]before runningTest plan
test_run_script_blocks_dangerous_commands)test_run_script_allows_safe_commands)test_run_script_blocks_null_bytes)test_run_script_success)validate_script_commanddirectlyenvx project run <script>shows confirmation prompt