Security Fix: Command Injection Vulnerability in Auto-Updater#103
Closed
MahmoudMohajer wants to merge 1 commit intoentrius:testfrom
Closed
Security Fix: Command Injection Vulnerability in Auto-Updater#103MahmoudMohajer wants to merge 1 commit intoentrius:testfrom
MahmoudMohajer wants to merge 1 commit intoentrius:testfrom
Conversation
Author
|
@anderdc can you take a look at this? |
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 Changes
This PR fixes a critical command injection vulnerability in the auto-updater orchestrator where user-controlled commit hashes could execute arbitrary shell commands, leading to remote code execution.
Changes Made
Added Commit Hash Validation (
_validate_commit_hash())Enhanced
_run_shell_command()MethodstrandList[str]for flexibilityshell=Falsefor list-based commands (safe mode)Fixed
perform_git_update()Method["git", "reset", "--hard", target_commit]Fixed
rollback_git_update()MethodHardened
run_setup_scripts()Methodshlex.quote()to safely escape file pathsMotivation and Context
The auto-updater orchestrator was vulnerable to command injection when processing commit hashes. If an attacker could control the
target_commitorprevious_commitparameters (either through repository control or direct method calls), they could inject malicious shell commands.Attack Scenario:
; rm -rf /or similarImpact: Critical - Remote code execution possible
Testing Performed
Vulnerability Tests
tests/auto_updater/test_command_injection.py)Validation Tests
Test Results
All tests pass successfully.
Security Improvements
Files Changed
auto_updater/auto_update/orchestrator.py- Security fixestests/auto_updater/test_command_injection.py- New test filetests/auto_updater/__init__.py- New test moduleCode Quality
_validate_commit_hash)Reviewers
@anderdc and @LandynDev
Labels
bug- Critical security bug fixContribution by Gittensor, learn more at https://gittensor.io/