File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1244,8 +1244,25 @@ export class IpcMain {
12441244 }
12451245
12461246 try {
1247+ // Validate scriptName doesn't contain path separators (prevent path traversal)
1248+ if ( scriptName . includes ( "/" ) || scriptName . includes ( "\\" ) || scriptName . includes ( ".." ) ) {
1249+ return Err (
1250+ `Invalid script name: ${ scriptName } . Script names must not contain path separators.`
1251+ ) ;
1252+ }
1253+
12471254 const scriptPath = getScriptPath ( workspacePath , scriptName ) ;
12481255
1256+ // Double-check the resolved path stays within scripts directory
1257+ const scriptsDir = path . join ( workspacePath , ".cmux" , "scripts" ) ;
1258+ const normalizedScriptPath = path . normalize ( scriptPath ) ;
1259+ const normalizedScriptsDir = path . normalize ( scriptsDir ) ;
1260+ if ( ! normalizedScriptPath . startsWith ( normalizedScriptsDir + path . sep ) ) {
1261+ return Err (
1262+ `Invalid script name: ${ scriptName } . Script path escapes scripts directory.`
1263+ ) ;
1264+ }
1265+
12491266 let scriptExists = false ;
12501267 try {
12511268 const stat = await runtimeInstance . stat ( scriptPath ) ;
You can’t perform that action at this time.
0 commit comments