Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

Checkpoint: File edits

rUv2d1a2b792ce4
diff --git a/v3/@claude-flow/cli/src/mcp-tools/auto-install.ts b/v3/@claude-flow/cli/src/mcp-tools/auto-install.ts
index c1561da16b..e412477ca4 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/auto-install.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/auto-install.ts
@@ -40,6 +40,16 @@ export async function autoInstallPackage(
): Promise<boolean> {
const { timeout = 60000, save = false, silent = false } = options;
+ // Validate package name to prevent command injection (CVE fix)
+ // Valid npm package names: @scope/name or name, alphanumeric with - . _ ~
+ const validPackageName = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*(@[a-z0-9-._~]+)?$/i;
+ if (!validPackageName.test(packageName)) {
+ if (!silent) {
+ console.error(`[claude-flow] Invalid package name: ${packageName}`);
+ }
+ return false;
+ }
+
// Only attempt once per session
if (installAttempts.has(packageName)) {
return false;
@@ -51,12 +61,18 @@ export async function autoInstallPackage(
console.error(`[claude-flow] Auto-installing ${packageName}...`);
}
- const saveFlag = save ? '--save' : '--no-save';
- execSync(`npm install ${packageName} ${saveFlag}`, {
+ // Use spawn with array args to prevent shell injection
+ const args = ['install', packageName, save ? '--save' : '--no-save'];
+ const result = spawnSync('npm', args, {
stdio: silent ? 'pipe' : ['pipe', 'pipe', 'pipe'],
timeout,
+ shell: false, // Explicitly disable shell
});
+ if (result.status !== 0) {
+ throw new Error(result.stderr?.toString() || 'Installation failed');
+ }
+
if (!silent) {
console.error(`[claude-flow] Successfully installed ${packageName}`);
}