Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

fix(account-rotation): harden keychain/exec paths, goto allowlist, rescue loop

Cursor Agent4d71f0a93538
diff --git a/claude-ops/scripts/account-rotation/ai-brain.mjs b/claude-ops/scripts/account-rotation/ai-brain.mjs
index 1ffe783e..a47f2554 100644
--- a/claude-ops/scripts/account-rotation/ai-brain.mjs
+++ b/claude-ops/scripts/account-rotation/ai-brain.mjs
@@ -20,6 +20,31 @@ const DEFAULT_MODEL = 'claude-haiku-4-5';
const MAX_DECISIONS = 6;
const REQUEST_TIMEOUT_MS = 30_000;
+const GOTO_ALLOWED_HOSTS = new Set([
+ 'localhost',
+ '127.0.0.1',
+ 'claude.ai',
+ 'www.claude.ai',
+ 'platform.claude.com',
+ 'accounts.google.com',
+ 'myaccount.google.com',
+ 'oauth2.googleapis.com',
+ 'login.microsoftonline.com',
+]);
+
+function isAllowedGotoUrl(urlStr) {
+ try {
+ const u = new URL(urlStr);
+ if (u.protocol !== 'https:' && u.protocol !== 'http:') return false;
+ const host = u.hostname.toLowerCase();
+ if (GOTO_ALLOWED_HOSTS.has(host)) return true;
+ if (host.endsWith('.google.com')) return true;
+ return false;
+ } catch {
+ return false;
+ }
+}
+
// ── Resolve API key from env → Doppler → keychain ────────────────────────────
function readCommand(argv, timeout = 4000) {
try {
@@ -297,17 +322,7 @@ export async function executeAIAction(driver, action, { googlePassword } = {}) {
return await driver.fillInput(sel, googlePassword);
}
case 'goto': {
- if (!action.url) return false;
- // Code-level URL allowlist — prompt constraints alone are insufficient
- const allowedHosts = ['claude.ai', 'accounts.google.com', 'myaccount.google.com', 'login.microsoftonline.com'];
- try {
- const host = new URL(action.url).hostname;
- if (!allowedHosts.some((d) => host === d || host.endsWith('.' + d))) {
- return false;
- }
- } catch {
- return false;
- }
+ if (!action.url || !isAllowedGotoUrl(action.url)) return false;
await driver.goto(action.url);
return true;
}
diff --git a/claude-ops/scripts/account-rotation/daemon.mjs b/claude-ops/scripts/account-rotation/daemon.mjs
index eacbefc2..450671b2 100644
--- a/claude-ops/scripts/account-rotation/daemon.mjs
+++ b/claude-ops/scripts/account-rotation/daemon.mjs
@@ -20,7 +20,7 @@
import { readFileSync, writeFileSync, existsSync, unlinkSync, appendFileSync, statSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
-import { execSync, execFileSync, spawn, spawnSync } from 'child_process';
+import { execFileSync, spawn, spawnSync } from 'child_process';
import { tmpdir } from 'os';
const __dirname = dirname(fileURLToPath(import.meta.url));
diff --git a/claude-ops/scripts/account-rotation/rotate.mjs b/claude-ops/scripts/account-rotation/rotate.mjs
index f42aa352..26773499 100644
--- a/claude-ops/scripts/account-rotation/rotate.mjs
+++ b/claude-ops/scripts/account-rotation/rotate.mjs
@@ -127,7 +127,14 @@ function log(msg) {
function notify(title, msg) {
try {
- execSync(`osascript -e 'display notification "${msg.replace(/"/g, '\\"')}" with title "${title}"'`);
+ execFileSync(
+ 'osascript',
+ [
+ '-e',
+ `display notification "${msg.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}" with title "${title.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`,
+ ],
+ { timeout: 5000 },
+ );
} catch {}
}
@@ -2097,7 +2104,8 @@ async function runAuthFlow(driver, account) {
if (aiBrainEnabled && aiBrainHistory.length < AI_BRAIN_MAX_DECISIONS) {
const url = await driver.currentUrl().catch(() => '');
log(`[ai-brain] loop exhausted — final rescue attempt`);
- for (let rescue = 0; rescue < AI_BRAIN_MAX_DECISIONS - aiBrainHistory.length && rescue < 3; rescue++) {
+ const rescueBudget = Math.min(3, AI_BRAIN_MAX_DECISIONS - aiBrainHistory.length);
+ for (let rescue = 0; rescue < rescueBudget; rescue++) {
const action = await askAIBrain({
page: driver._page,
account,