Skip to content

Commit 60d1760

Browse files
gavrielcclaude
andcommitted
fix: prevent command injection in setup verify PID check
Validate PID as positive integer and use process.kill() instead of shell interpolation via execSync, eliminating injection vector. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b42ce1 commit 60d1760

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

setup/verify.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ export async function run(_args: string[]): Promise<void> {
6868
const pidFile = path.join(projectRoot, 'nanoclaw.pid');
6969
if (fs.existsSync(pidFile)) {
7070
try {
71-
const pid = fs.readFileSync(pidFile, 'utf-8').trim();
72-
if (pid) {
73-
execSync(`kill -0 ${pid}`, { stdio: 'ignore' });
71+
const raw = fs.readFileSync(pidFile, 'utf-8').trim();
72+
const pid = Number(raw);
73+
if (raw && Number.isInteger(pid) && pid > 0) {
74+
process.kill(pid, 0);
7475
service = 'running';
7576
}
7677
} catch {

0 commit comments

Comments
 (0)