🌊 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
fix(security): enforce blocked path components in project validators
Rudy Celeklid6cef09893a6
diff --git a/v3/@claude-flow/security/__tests__/path-blocked-descendants.test.ts b/v3/@claude-flow/security/__tests__/path-blocked-descendants.test.tsnew file mode 100644index 0000000000..a2af99e637--- /dev/null+++ b/v3/@claude-flow/security/__tests__/path-blocked-descendants.test.ts@@ -0,0 +1,32 @@+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { createFullProjectPathValidator } from '../src/path-validator.js';++let root: string;+beforeEach(async () => { root = await mkdtemp(join(tmpdir(), 'ruflo-blocked-paths-')); });+afterEach(async () => { await rm(root, { recursive: true, force: true }); });++describe('full-project blocked paths', () => {+ for (const name of ['node_modules/pkg/index.js', '.git/config', '.docker/config.json']) {+ for (const method of ['validate', 'validateSync'] as const) {+ it(`${method} rejects a descendant of ${name.split('/')[0]}`, async () => {+ const file = join(root, name);+ await mkdir(join(file, '..'), { recursive: true });+ await writeFile(file, 'private');+ const result = await createFullProjectPathValidator(root)[method](file);+ expect(result.isValid).toBe(false);+ expect(result.errors.some(error => error.includes('blocked'))).toBe(true);+ });+ }+ }+ for (const method of ['validate', 'validateSync'] as const) {+ it(`${method} blocks dotfile extensions while allowing normal hidden project files`, async () => {+ const validator = createFullProjectPathValidator(root);+ expect((await validator[method](join(root, '.env'))).isValid).toBe(false);+ expect((await validator[method](join(root, '.gitignore'))).isValid).toBe(true);+ expect((await validator[method](join(root, 'src/node_modules_notes.ts'))).isValid).toBe(true);+ });+ }+});diff --git a/v3/@claude-flow/security/src/path-validator.ts b/v3/@claude-flow/security/src/path-validator.tsindex 6236091ed0..7461c59aac 100644--- a/v3/@claude-flow/security/src/path-validator.ts+++ b/v3/@claude-flow/security/src/path-validator.ts@@ -39,8 +39,8 @@ export interface PathValidatorConfig {blockedExtensions?: string[];/**- * Blocked file names.- * Files matching these names are rejected.+ * Blocked file or directory names.+ * Matching components beneath an allowed prefix are rejected.*/blockedNames?: string[];@@ -423,8 +423,10 @@ export class PathValidator {// Check blocked file namesconst basename = path.basename(resolvedPath);- if (this.config.blockedNames.includes(basename)) {- errors.push(`File name "${basename}" is blocked`);+ const blockedPart = (relativePath || basename).split(path.sep)+ .find(part => this.config.blockedNames.includes(part));+ if (blockedPart) {+ errors.push(`File name "${blockedPart}" is blocked`);}// Check blocked extensions@@ -552,8 +554,10 @@ export class PathValidator {}const basename = path.basename(resolvedPath);- if (this.config.blockedNames.includes(basename)) {- errors.push(`File name "${basename}" is blocked`);+ const blockedPart = (relativePath || basename).split(path.sep)+ .find(part => this.config.blockedNames.includes(part));+ if (blockedPart) {+ errors.push(`File name "${blockedPart}" is blocked`);}const ext = path.extname(resolvedPath).toLowerCase();@@ -561,6 +565,14 @@ export class PathValidator {errors.push(`File extension "${ext}" is blocked`);}+ const fullname = basename.toLowerCase();+ for (const blockedExt of this.config.blockedExtensions) {+ if (fullname.endsWith(blockedExt)) {+ errors.push(`File extension "${blockedExt}" is blocked`);+ break;+ }+ }+return {isValid: errors.length === 0,resolvedPath,