An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(guardrails): judge a run's folder by the platform's own path rules, so Windows no longer refuses six of the eight agents as unsafe, and a .. can no longer climb out of the state dir anywhere
Shahriar7af68dc4d042
diff --git a/src/daemon/guardrails/spawn.test.ts b/src/daemon/guardrails/spawn.test.tsindex f2c41cc..370e9b0 100644--- a/src/daemon/guardrails/spawn.test.ts+++ b/src/daemon/guardrails/spawn.test.ts@@ -1,9 +1,10 @@+import { join, posix, win32 } from 'node:path';import { describe, expect, test } from 'vitest';import { AGENT_KINDS, AGENTS, type AgentKind } from '@/lib/agents/catalog';import { mcpServerFor, RUNNERS } from '../agent/runners';import type { Plan, StreamContext } from '../agent/runners/types';import { stateDir } from '../lockfile';-import { CONTAINMENT, sealEnv, sealedAway, vetPlan, type SpawnMode } from './spawn';+import { CONTAINMENT, sealEnv, sealedAway, vetPlan, within, type SpawnMode } from './spawn';const settingsFor = (kind: AgentKind) => ({ bin: AGENTS[kind].bin });@@ -480,6 +481,36 @@ describe('spawn containment', () => {test('a sibling path is not inside the state dir', () => {expect(vetPlan('claude', 'run', { ...claudeRun, cwd: `${stateDir}-evil` }, stateDir)).toHaveLength(1);});++ test('a path that climbs out of the state dir is not inside it, whatever it starts with', () => {+ expect(vetPlan('antigravity', 'run', { ...agyRun, cwd: join(stateDir, 'agents', '..', '..', 'elsewhere') }, stateDir)).toHaveLength(1);+ });+ });++ describe('inside the state dir, by each platform’s path rules', () => {+ const home = 'C:\\Users\\sam\\.browsentic';++ test('a Windows folder under it is inside, however its drive letter is cased', () => {+ expect(within(`${home}\\agents\\grok\\run\\c1`, home, win32)).toBe(true);+ expect(within('c:\\users\\SAM\\.browsentic\\agents', home, win32)).toBe(true);+ expect(within(home, home, win32)).toBe(true);+ });++ test('a Windows sibling, another drive, or a climb out is not inside', () => {+ expect(within(`${home}-evil\\agents`, home, win32)).toBe(false);+ expect(within('D:\\Users\\sam\\.browsentic', home, win32)).toBe(false);+ expect(within(`${home}\\agents\\..\\..\\Documents`, home, win32)).toBe(false);+ });++ test('a folder whose name only begins with two dots is still inside', () => {+ expect(within('/home/sam/.browsentic/..cache', '/home/sam/.browsentic', posix)).toBe(true);+ expect(within(`${home}\\..cache`, home, win32)).toBe(true);+ });++ test('POSIX spells it with slashes, and compares case by case', () => {+ expect(within('/home/sam/.browsentic/agents/vibe/run', '/home/sam/.browsentic', posix)).toBe(true);+ expect(within('/home/sam/.Browsentic/agents', '/home/sam/.browsentic', posix)).toBe(false);+ });});describe('a model a CLI could read as a flag', () => {diff --git a/src/daemon/guardrails/spawn.ts b/src/daemon/guardrails/spawn.tsindex e1a8acf..840d797 100644--- a/src/daemon/guardrails/spawn.ts+++ b/src/daemon/guardrails/spawn.ts@@ -26,6 +26,7 @@* assumed away.*/+import { posix, win32 } from 'node:path';import { AGENTS, isModelId, type AgentKind } from '@/lib/agents/catalog';/**@@ -561,7 +562,11 @@ function variadic(args: readonly string[], flag: string): string[] {return values;}-function within(child: string, parent: string): boolean {- const base = parent.endsWith('/') ? parent : `${parent}/`;- return child === parent || child.startsWith(base);+/**+ * Whether `child` is `parent` or lies under it, by the platform's own path rules: Windows spells a+ * path with backslashes and compares it case-blind, and a `..` climbs out whatever the prefix says.+ */+export function within(child: string, parent: string, path: typeof posix = process.platform === 'win32' ? win32 : posix): boolean {+ const rel = path.relative(parent, child);+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel));}