From 207e11569964f357ce42762caf9a6a09d49a7a75 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Wed, 5 Nov 2025 08:47:35 +0100 Subject: [PATCH] Restricts shell metacharacters in paths Addresses a potential command injection vulnerability by tightening the validation of executable paths. Removes brackets and curly braces from the list of disallowed shell metacharacters in paths on Windows to prevent issues when paths contain these characters. Only the metacharacters that can't appear in safe paths are disallowed. --- src/core/SecurityUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/SecurityUtils.ts b/src/core/SecurityUtils.ts index 827806a..3433e81 100644 --- a/src/core/SecurityUtils.ts +++ b/src/core/SecurityUtils.ts @@ -217,7 +217,7 @@ export class SecurityUtils { // Check for command injection attempts const dangerousPatterns = [ - /[;&|`$(){}[\]]/, // Shell metacharacters + /[;&|`$<>]/, // Shell metacharacters that can't appear in safe paths // eslint-disable-next-line no-control-regex /\x00/, // Null bytes /\n|\r/, // Newlines @@ -371,7 +371,7 @@ export class SecurityUtils { const normalizedPath = path.normalize(executablePath.trim()); - if (/[;&|`$(){}[\]]/.test(normalizedPath)) { + if (/[;&|`$<>]/.test(normalizedPath)) { return 'Shell metacharacters are not allowed in executable paths'; } if (/\x00/.test(normalizedPath)) { // eslint-disable-line no-control-regex