A command injection vulnerability exists in @wdio/browserstack-service that allows remote code execution (RCE) when processing git branch names in test orchestration. An attacker can exploit this by providing a malicious git repository with a branch name containing shell command injection payloads.
Details
Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer.
User-controlled git branch names are directly interpolated into execSync() calls without sanitization. Git allows branch names to contain special characters ,that can be used for command injection.
Git allows to create these branches.
Attacker creates a malicious git repository with a branch name containing command injection payload
Attacker configures WebdriverIO to use this repository via testOrchestrationOptions.runSmartSelection.source. if source is not provided it takes current directory as source.
When getGitMetadataForAISelection() executes, it extracts the malicious branch name
Branch name is interpolated into shell commands without sanitization
Shell interprets special characters and executes attacker's commands