🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
Checkpoint: File edits
rUv8698acc5ac0f
diff --git a/v3/@claude-flow/cli/src/commands/daemon.ts b/v3/@claude-flow/cli/src/commands/daemon.tsindex c73fba0eac..a3fd30aa98 100644--- a/v3/@claude-flow/cli/src/commands/daemon.ts+++ b/v3/@claude-flow/cli/src/commands/daemon.ts@@ -145,14 +145,50 @@ const startCommand: Command = {},};+/**+ * Validate path for security - prevents path traversal and injection+ */+function validatePath(path: string, label: string): void {+ // Must be absolute after resolution+ const resolved = resolve(path);++ // Check for null bytes (injection attack)+ if (path.includes('\0')) {+ throw new Error(`${label} contains null bytes`);+ }++ // Check for shell metacharacters in path components+ if (/[;&|`$<>]/.test(path)) {+ throw new Error(`${label} contains shell metacharacters`);+ }++ // Prevent path traversal outside expected directories+ if (!resolved.includes('.claude-flow') && !resolved.includes('bin')) {+ // Allow only paths within project structure+ const cwd = process.cwd();+ if (!resolved.startsWith(cwd)) {+ throw new Error(`${label} escapes project directory`);+ }+ }+}+/*** Start daemon as a detached background process*/async function startBackgroundDaemon(projectRoot: string, quiet: boolean): Promise<CommandResult> {- const stateDir = join(projectRoot, '.claude-flow');+ // Validate and resolve project root+ const resolvedRoot = resolve(projectRoot);+ validatePath(resolvedRoot, 'Project root');++ const stateDir = join(resolvedRoot, '.claude-flow');const pidFile = join(stateDir, 'daemon.pid');const logFile = join(stateDir, 'daemon.log');+ // Validate all paths+ validatePath(stateDir, 'State directory');+ validatePath(pidFile, 'PID file');+ validatePath(logFile, 'Log file');+// Ensure state directory existsif (!fs.existsSync(stateDir)) {fs.mkdirSync(stateDir, { recursive: true });@@ -162,7 +198,8 @@ async function startBackgroundDaemon(projectRoot: string, quiet: boolean): Promiconst __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);// dist/src/commands -> dist/src -> dist -> package root -> bin/cli.js- const cliPath = join(__dirname, '..', '..', '..', 'bin', 'cli.js');+ const cliPath = resolve(join(__dirname, '..', '..', '..', 'bin', 'cli.js'));+ validatePath(cliPath, 'CLI path');// Verify CLI path existsif (!fs.existsSync(cliPath)) {@@ -170,14 +207,15 @@ async function startBackgroundDaemon(projectRoot: string, quiet: boolean): Promireturn { success: false, exitCode: 1 };}- // Use shell to spawn daemon with proper output redirection- // This ensures the log file stays open even after parent exits- const shellCmd = `"${process.execPath}" "${cliPath}" daemon start --foreground --quiet >> "${logFile}" 2>&1 & echo $!`;-- const child = spawn('sh', ['-c', shellCmd], {- cwd: projectRoot,+ // Use spawn with explicit arguments instead of shell string interpolation+ // This prevents command injection via paths+ const child = spawn(process.execPath, [+ cliPath,+ 'daemon', 'start', '--foreground', '--quiet'+ ], {+ cwd: resolvedRoot,detached: true,- stdio: ['ignore', 'pipe', 'ignore'],+ stdio: ['ignore', fs.openSync(logFile, 'a'), fs.openSync(logFile, 'a')],env: { ...process.env, CLAUDE_FLOW_DAEMON: '1' },});