🌊 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(managed): refuse . and .. resource ids; guard reads common argument wrappers (ruflo-agent 0.4.1) (#4478)
rUvf02989a78c06
diff --git a/plugins/ruflo-agent/.claude-plugin/plugin.json b/plugins/ruflo-agent/.claude-plugin/plugin.jsonindex 5e7cf1660b..c55799f078 100644--- a/plugins/ruflo-agent/.claude-plugin/plugin.json+++ b/plugins/ruflo-agent/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-agent","description": "Local WASM and managed cloud runtimes with bounded dynamic workflows, live capability discovery and session-local mod policy.",- "version": "0.4.0",+ "version": "0.4.1","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-agent/CHANGELOG.md b/plugins/ruflo-agent/CHANGELOG.mdindex 6f07357315..6aa5fcc90e 100644--- a/plugins/ruflo-agent/CHANGELOG.md+++ b/plugins/ruflo-agent/CHANGELOG.md@@ -2,6 +2,10 @@Newest first. One `## <version> — <date>` heading per version, then `feat:`, `fix:`, `breaking:` and `chore:` bullets (ADR-478). Built from git history; this is the whole history.+## 0.4.1 — 2026-10-25+- fix: the dynamic-workflow guard now reads call arguments wrapped as `tool_input`, `params`, `args` or `parameters` (as well as `input` and `arguments`), and refuses a wrapper that is not an object or two competing wrappers; before, an unrecognised wrapper was read as a flat envelope with no policy fields and the call was allowed+- fix: a session, thread or environment id of `.` or `..` is refused before any request is sent (`encodeURIComponent` leaves it unchanged, so `/v1/sessions/..` would have resolved to `/v1/`)+## 0.4.0 — 2026-10-24- feat: verified feedback cycles, independent host verification, atomic admission and isolated native memory with replay and policy checks- fix: `managed_agent_prompt` could report the previous turn's answer as finished on a later poll while the new turn was still running; only events from the acknowledged message onward are trackeddiff --git a/plugins/ruflo-agent/docs/adrs/0004-verified-learning-and-console.md b/plugins/ruflo-agent/docs/adrs/0004-verified-learning-and-console.mdindex 12735da602..a344559eb7 100644--- a/plugins/ruflo-agent/docs/adrs/0004-verified-learning-and-console.md+++ b/plugins/ruflo-agent/docs/adrs/0004-verified-learning-and-console.md@@ -342,4 +342,11 @@ The following are **known limits that this change does not remove**. They are whqueued while the session was busy, and whether `max_list_cost.amount` is in cents. Both need the live-provider canary that isstill an open release gate.-A native-memory child process is a process boundary, not an OS memory or network sandbox.+8. **Dynamic-mode egress is model-chosen.** When `dynamicWorkflows` is on, `allowedHosts`, `initScript`, `mcpServers` URLs and `packages`+ are chosen by the model and constrained only by `networking: limited`; there is no plugin-level host allowlist.+9. **Unconfirmed guard envelope.** The dynamic-workflow guard reads the arguments from `input`, `arguments`, `tool_input`, `params`, `args`+ or `parameters`, or from a flat event. A host that names the field something else would not be seen by the guard (it only tightens+ `managed_agent_create`; it never loosens another gate).++A native-memory child process is a process boundary, not an OS memory or network sandbox. Its offline mode relies on a library flag+on the module instance that is loaded, and the size of an IPC message is checked after it is parsed.diff --git a/plugins/ruflo-agent/hooks/managed.ts b/plugins/ruflo-agent/hooks/managed.tsindex c7d50d03a5..634fbe9928 100644--- a/plugins/ruflo-agent/hooks/managed.ts+++ b/plugins/ruflo-agent/hooks/managed.ts@@ -5,13 +5,20 @@ export const MANAGED_TOOLS = ['managed_agent_capabilities', 'managed_agent_learnconst record = (v: unknown): Record<string, unknown> | undefined => v !== null && typeof v === 'object' && !Array.isArray(v) ? v as Record<string, unknown> : undefined-/** Host tool envelopes may be flat or hold arguments in input/arguments. Never scan arbitrary descendants as policy. */+/** Argument wrappers a host may use. Only these are read; arbitrary descendants are never scanned as policy. */+const WRAPPERS = ['input', 'arguments', 'tool_input', 'params', 'args', 'parameters'] as const++/**+ * Host tool envelopes may be flat or hold the arguments in one wrapper. A wrapper that is not an object, two wrappers, or a wrapper+ * next to a flat `dynamicWorkflows` are ambiguous, so they are refused (undefined) rather than read as an envelope with no policy fields.+ */export function managedInput(event: unknown): Record<string, unknown> | undefined {const e = record(event)if (!e) return undefined- if ('input' in e) return e.dynamicWorkflows !== undefined || 'arguments' in e ? undefined : record(e.input)- if ('arguments' in e) return e.dynamicWorkflows !== undefined ? undefined : record(e.arguments)- return e+ const present = WRAPPERS.filter(k => k in e)+ if (present.length === 0) return e+ if (present.length > 1 || e.dynamicWorkflows !== undefined) return undefined+ return record(e[present[0]!])}export function managedName(tool: string): string | undefined {diff --git a/plugins/ruflo-agent/scripts/smoke.sh b/plugins/ruflo-agent/scripts/smoke.shindex 3834748ccb..3ce9e878c9 100755--- a/plugins/ruflo-agent/scripts/smoke.sh+++ b/plugins/ruflo-agent/scripts/smoke.sh@@ -7,11 +7,11 @@ step() { printf "→ %s ... " "$1"; }ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }-step "1. plugin.json is ruflo-agent 0.4.0 with both-runtime keywords"+step "1. plugin.json is ruflo-agent 0.4.1 with both-runtime keywords"P="$ROOT/.claude-plugin/plugin.json"v=$(grep -E '"version"' "$P" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)n=$(grep -E '"name"' "$P" | grep -oE 'ruflo-agent' | head -1)-if [[ "$v" != "0.4.0" ]]; then bad "expected version 0.4.0, got '$v'";+if [[ "$v" != "0.4.1" ]]; then bad "expected version 0.4.1, got '$v'";elif [[ "$n" != "ruflo-agent" ]]; then bad "expected name ruflo-agent";elsemiss=""diff --git a/v3/@claude-flow/cli/__tests__/managed-mod-integration.test.ts b/v3/@claude-flow/cli/__tests__/managed-mod-integration.test.tsindex f76e1e2b9c..98cc9390ad 100644--- a/v3/@claude-flow/cli/__tests__/managed-mod-integration.test.ts+++ b/v3/@claude-flow/cli/__tests__/managed-mod-integration.test.ts@@ -35,6 +35,16 @@ describe('mod admission', () => {expect(managedVerdict(create, input, enabled)).toContain('predefined');expect(managedVerdict(create, input, readOptions({ managedWorkflows: 'on', allowInlineAgents: 'on' }))).toBeUndefined();});+ it.each(['tool_input', 'params', 'args', 'parameters'])('applies the policy to arguments wrapped as %s instead of letting them through', wrapper => {+ // An unrecognised wrapper used to be read as a flat envelope with no dynamicWorkflows field, so the call was allowed.+ expect(managedVerdict(create, { [wrapper]: { ...valid, budgetCents: '2501' } }, enabled)).toContain('budget');+ expect(managedVerdict(create, { [wrapper]: valid }, enabled)).toBeUndefined();+ expect(managedVerdict(create, { [wrapper]: valid }, readOptions(undefined))).toContain('off');+ });+ it('denies a wrapper that is not an object, and two competing wrappers', () => {+ expect(managedVerdict(create, { tool_input: 'dynamicWorkflows' }, enabled)).toContain('malformed');+ expect(managedVerdict(create, { tool_input: valid, params: { ...valid, budgetCents: '1' } }, enabled)).toContain('malformed');+ });it('reads flat and nested envelopes and rejects ambiguous input', () => {expect(managedVerdict(create, { input: valid }, enabled)).toBeUndefined();expect(managedVerdict(create, { arguments: valid }, enabled)).toBeUndefined();diff --git a/v3/@claude-flow/cli/__tests__/managed-workflows.test.ts b/v3/@claude-flow/cli/__tests__/managed-workflows.test.tsindex 67eb9f57c5..0e585c070e 100644--- a/v3/@claude-flow/cli/__tests__/managed-workflows.test.ts+++ b/v3/@claude-flow/cli/__tests__/managed-workflows.test.ts@@ -220,6 +220,32 @@ describe('transport and cleanup security', () => {});});+describe('resource ids cannot walk the API path', () => {+ // encodeURIComponent('..') is '..', so an id of '..' would send GET /v1/sessions/.. which normalises to /v1/.+ it.each([+ ['managed_agent_status', { sessionId: '..' }],+ ['managed_agent_status', { sessionId: '.' }],+ ['managed_agent_events', { sessionId: '..' }],+ ['managed_agent_events', { sessionId: 'sesn_a', threadId: '..' }],+ ['managed_agent_prompt', { sessionId: '..', message: 'x' }],+ ['managed_agent_terminate', { sessionId: '..' }],+ ])('%s %j sends nothing', async (tool, input) => {+ const result = await call(tool, input);+ expect(Boolean(result.error) || result.success === false).toBe(true);+ expect(fetchMock).not.toHaveBeenCalled();+ });+ it('terminate will not delete an environment named ..', async () => {+ fetchMock.mockResolvedValueOnce(new Response(null, { status: 204 }));+ const result = await call('managed_agent_terminate', { sessionId: 'sesn_a', environmentId: '..' });+ expect(result.environmentDeleted).toBe(false);+ expect(fetchMock.mock.calls.every(c => !String(c[0]).includes('/environments'))).toBe(true);+ });+ it('ordinary ids are still sent', async () => {+ fetchMock.mockImplementation(() => json({ id: 'sesn_a', status: 'idle' }));+ expect(await call('managed_agent_status', { sessionId: 'sesn_a' })).toMatchObject({ sessionId: 'sesn_a', status: 'idle' });+ });+});+describe('failures after a prompt was already sent', () => {it('reports the message id so a retry does not send a duplicate', async () => {fetchMock.mockResolvedValueOnce(json({ data: [event('sent', 'user.message', { processed_at: null })] })).mockImplementation(() => json({}, 500));diff --git a/v3/@claude-flow/cli/src/mcp-tools/managed-agent-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/managed-agent-tools.tsindex d4c85cdc2d..3d7b8c9d53 100644--- a/v3/@claude-flow/cli/src/mcp-tools/managed-agent-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/managed-agent-tools.ts@@ -62,6 +62,8 @@ async function maRequest<T = unknown>(): Promise<{ ok: true; status: number; data: T } | { ok: false; status: number; error: string; body?: unknown }> {const key = apiKey();if (!key) return { ok: false, status: 0, error: NEEDS_KEY.error };+ // encodeURIComponent leaves '.' and '..' alone, so an id of '..' would walk up the API path (/v1/sessions/.. is /v1/).+ if (path.split('?')[0].split('/').some(segment => segment === '.' || segment === '..')) return { ok: false, status: 0, error: 'Invalid managed resource id' };try {const res = await fetch(`${apiBase()}/v1${path}`, {method, headers: headers(key), redirect: 'error',