Skip to content

Commit 4136a2f

Browse files
Nitin-100Nitin Chaudhary
authored andcommitted
fix: Improvements on MSRC CLI (#15974)
* fix: resolve MSRC command/argument injection vulnerabilities in CLI - MSRC 112511: Replace execSync with execFileSync in msbuildtools.ts cleanProject() to prevent shell command injection via slnFile parameter (CWE-78) - MSRC 112495/112540: Replace .split(' ') anti-pattern with discrete argument array in winappdeploytool.ts uninstallAppPackage() to prevent argument injection via appName parameter (CWE-88) - Also fixes {$targetDevice.ip} syntax bug (was never interpolating the IP address) * Change files --------- Co-authored-by: Nitin Chaudhary <nitchaudhary@microsoft.com>
1 parent 727ee78 commit 4136a2f

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix command injection in cleanProject() (CWE-78) and argument injection in uninstallAppPackage() (CWE-88)",
4+
"packageName": "@react-native-windows/cli",
5+
"email": "nitchaudhary@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/@react-native-windows/cli/src/utils/msbuildtools.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export default class MSBuildTools {
4545
}
4646

4747
cleanProject(slnFile: string) {
48-
const cmd = `"${path.join(
49-
this.msbuildPath(),
50-
'msbuild.exe',
51-
)}" "${slnFile}" /t:Clean`;
52-
const results = child_process.execSync(cmd).toString().split(EOL);
48+
const msbuild = path.join(this.msbuildPath(), 'msbuild.exe');
49+
const results = child_process
50+
.execFileSync(msbuild, [slnFile, '/t:Clean'])
51+
.toString()
52+
.split(EOL);
5353
results.forEach(result => console.log(chalk.white(result)));
5454
}
5555

packages/@react-native-windows/cli/src/utils/winappdeploytool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export default class WinAppDeployTool {
157157
newSpinner(text),
158158
text,
159159
this.path,
160-
`uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '),
160+
['uninstall', '-package', appName, '-ip', targetDevice.ip],
161161
verbose,
162162
'UninstallAppOnDeviceFailure',
163163
);

0 commit comments

Comments
 (0)