Skip to content

Commit b0c1d00

Browse files
committed
fix: use execFile with arg arrays to prevent command injection in status
exec() spawns a shell, so interpolated args like sandboxName are vulnerable to shell metacharacter injection. execFile() bypasses the shell entirely by passing args as an array directly to the process.
1 parent 867f27d commit b0c1d00

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎nemoclaw/src/commands/status.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { exec } from "node:child_process";
4+
import { execFile } from "node:child_process";
55
import { existsSync } from "node:fs";
66
import { promisify } from "node:util";
77
import type { PluginLogger, NemoClawConfig } from "../index.js";
88
import { loadState } from "../blueprint/state.js";
99

10-
const execAsync = promisify(exec);
10+
const execFileAsync = promisify(execFile);
1111

1212
/**
1313
* Detect whether the plugin is running inside an OpenShell sandbox.
@@ -128,7 +128,7 @@ async function getSandboxStatus(sandboxName: string, insideSandbox: boolean): Pr
128128
return { name: sandboxName, running: false, uptime: null, insideSandbox: true };
129129
}
130130
try {
131-
const { stdout } = await execAsync(`openshell sandbox status ${sandboxName} --json`, {
131+
const { stdout } = await execFileAsync("openshell", ["sandbox", "status", sandboxName, "--json"], {
132132
timeout: 5000,
133133
});
134134
const parsed = JSON.parse(stdout) as SandboxStatusResponse;
@@ -162,7 +162,7 @@ async function getInferenceStatus(insideSandbox: boolean): Promise<InferenceStat
162162
return { configured: false, provider: null, model: null, endpoint: null, insideSandbox: true };
163163
}
164164
try {
165-
const { stdout } = await execAsync("openshell inference get --json", {
165+
const { stdout } = await execFileAsync("openshell", ["inference", "get", "--json"], {
166166
timeout: 5000,
167167
});
168168
const parsed = JSON.parse(stdout) as InferenceStatusResponse;

0 commit comments

Comments
 (0)