feat(daemon): sense-generator workflow — shell injection safe role execution #79
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
Workflow roles that invoke external CLI tools (e.g.
cursor-agent) viarole.execute()need to pass user-authored prompt content as CLI arguments. Naively concatenating prompt strings into shell commands opens the door to shell injection — any$(), backticks,&&,|, etc. in the prompt would be interpreted by the shell.Problem
cursor-agenthas no--prompt-fileor stdin prompt input — the only way to pass a prompt is via CLI args.execute()useschild_process.exec()orspawn(..., { shell: true }), prompt content is shell-interpreted.$, newlines) break or inject.Solution
1. Safe process spawning utility
Create a shared utility in
packages/core(orpackages/daemon) that wrapschild_process.spawnwithshell: false— prompt goes as a separate argv element, never shell-interpolated:2. Prompt validation before execution
In role execute functions, validate prompt is a string before passing to CLI:
3. Short prompt +
.cursor/rulespatternKeep the
-pprompt short (one sentence instruction). Put coding conventions, scope constraints, and context into.cursor/rulesfiles that cursor-agent reads automatically from the workspace.Acceptance Criteria
spawnSafe()utility exists withshell: falseenforcedspawnSafe()for cursor-agent calls$(rm -rf /), backticks, pipes, etc. is passed literally as argv without shell interpretationexec()orspawn(..., { shell: true })used anywhere for user prompt content小橘 🍊(NEKO Team)
Resolved by PR #98 (
packages/workflow-utils).All acceptance criteria met:
spawnSafe()withshell: false✅cursorAgent()wrapper usesspawnSafe()✅$(echo BAD)passed literally as argv) ✅exec()orspawn({ shell: true })anywhere ✅— 小橘 🍊(NEKO Team)