Skip to content

Commit 86d7a20

Browse files
waleedlatif1claude
andcommitted
fix: escape workingDirectory in SSH execute-command route
Use escapeShellArg() with single quotes for the workingDirectory parameter, consistent with all other SSH routes (execute-script, create-directory, delete-file, move-rename). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent be41fbc commit 86d7a20

File tree

1 file changed

+8
-2
lines changed
  • apps/sim/app/api/tools/ssh/execute-command

1 file changed

+8
-2
lines changed

apps/sim/app/api/tools/ssh/execute-command/route.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { createLogger } from '@sim/logger'
33
import { type NextRequest, NextResponse } from 'next/server'
44
import { z } from 'zod'
55
import { checkInternalAuth } from '@/lib/auth/hybrid'
6-
import { createSSHConnection, executeSSHCommand, sanitizeCommand } from '@/app/api/tools/ssh/utils'
6+
import {
7+
createSSHConnection,
8+
escapeShellArg,
9+
executeSSHCommand,
10+
sanitizeCommand,
11+
} from '@/app/api/tools/ssh/utils'
712

813
const logger = createLogger('SSHExecuteCommandAPI')
914

@@ -52,7 +57,8 @@ export async function POST(request: NextRequest) {
5257
try {
5358
let command = sanitizeCommand(params.command)
5459
if (params.workingDirectory) {
55-
command = `cd "${params.workingDirectory}" && ${command}`
60+
const escapedWorkDir = escapeShellArg(params.workingDirectory)
61+
command = `cd '${escapedWorkDir}' && ${command}`
5662
}
5763

5864
const result = await executeSSHCommand(client, command)

0 commit comments

Comments
 (0)