Skip to content

Commit c4af174

Browse files
committed
🤖 fix: use single quotes for script argument escaping to prevent injection
Change-Id: Id4e929b2fb40a1583cb4f0740a52d6d134a7cc0e Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent e4f609d commit c4af174

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/node/services/scriptRunner.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ export async function runWorkspaceScript(
9898
// Quote arguments safely - basic quote wrapping for bash
9999
const escapedArgs = args
100100
.map((arg) => {
101-
// Basic escaping for bash arguments
102-
const safeArg = arg.replace(/"/g, `${String.fromCharCode(92)}"`);
103-
return `"${safeArg}"`;
101+
// Use single quotes for stronger escaping (preserves literals)
102+
// Replace ' with '\'' to safely break out and insert a literal quote
103+
const safeArg = arg.replace(/'/g, "'\\''");
104+
return `'${safeArg}'`;
104105
})
105106
.join(" ");
106107

0 commit comments

Comments
 (0)