Skip to content

Commit be41fbc

Browse files
waleedlatif1claude
andcommitted
fix: use randomized heredoc delimiter in SSH execute-script route
Prevents accidental heredoc termination if script content contains the delimiter string on its own line. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6f43fc9 commit be41fbc

File tree

1 file changed

+3
-2
lines changed
  • apps/sim/app/api/tools/ssh/execute-script

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ export async function POST(request: NextRequest) {
5555
const escapedScriptPath = escapeShellArg(scriptPath)
5656
const escapedInterpreter = escapeShellArg(params.interpreter)
5757

58-
let command = `cat > '${escapedScriptPath}' << 'SIMEOF'
58+
const heredocDelimiter = `SIMEOF_${randomUUID().replace(/-/g, '')}`
59+
let command = `cat > '${escapedScriptPath}' << '${heredocDelimiter}'
5960
${params.script}
60-
SIMEOF
61+
${heredocDelimiter}
6162
chmod +x '${escapedScriptPath}'`
6263

6364
if (params.workingDirectory) {

0 commit comments

Comments
 (0)