A product-wide defect sweep (31-agent find→verify workflow) surfaced 21 confirmed,
adversarially-verified defects (3 critical, 7 high, 9 medium, 2 low) across the
backend/packages moat. All fixed here, each TDD'd (failing test first) and verified;
1351 tests green across the touched + rippled domains, backend tsc 0.
CRITICAL
- Privilege escalation: sk_ API-key mint stored caller-supplied scopes verbatim, so
any authenticated user could mint an admin/internal key → super-user. Minted scopes
are now a subset of the minter's; privileged scopes refused unless already held
(identity/api-key.service.ts + routes + ports).
- RCE: the recoder.workflow.verify MCP tool shelled caller-supplied checks[].command
with the full process.env. Closed in depth — minimal PATH/HOME-only env (no shell
inheritance), caller commands stripped (registry-only), the MCP boundary drops the
command field, AND workflow.verify raised to needs_approval in the risk classifier
(capability-binders + workflow-engine + agent-mcp + agent-policy).
HIGH
- Retrieval LFI: HTTP ingest took an arbitrary fs path read via search → inline-text
only + tenant-namespaced collections (memory/routes/retrieval.routes.ts).
- Auth fail-open: getAuthEnv returned an empty BETTER_AUTH_SECRET under DOCKER=1 →
removed the short-circuit; missing secrets fail fast (packages/auth/keys.ts).
- Forbidden-path bypass: `**/` glob didn't match repo-root files → leading `**/` now
optional-segment; rm-rf gate hardened against flag reordering/long-form
(packages/agent-policy/rules/{glob,command-risk}.ts).
- Governance blind to nested args: describeToolInput dropped arrays/objects → recursive
secret-free projection with depth/size bounds (governance/tool-exec-gate.ts).
- Billing undercharge: polar/dodo emitUsage swallowed push errors so flushOnce marked
undelivered usage flushed → re-throw; webhook timestamp-freshness blocks replay
(billing/adapters/{polar,dodo,shared}.ts).
- Secret-in-logs: stub auth senders logged token-bearing magic-link/reset URLs → log
email + not-wired only (identity/adapters/better-auth.adapter.ts).
MEDIUM/LOW
- acceptInvite IDOR (ownership check); retrieval cross-tenant (principal-bound
collections); OPA response validated fail-closed; run-tailer attached-guard cleared
on completion so continued runs stream; metering idempotency keyed per-event (no
under-count); control-mode probe race; db_schema_inspect privilege gate; comma-join
FROM allowlist bypass; KvStore silent write-drop → rethrow; migration split-on-;
in literals/comments.
Adversarial-review scoped to the moat (identity/api/billing/agent-os/conductor/
persistence/engines) — not exhaustive; a full pre-launch security pass is still
warranted before multi-tenant cloud. Packages rebuilt (agent-policy/workflow-engine
gitignored dist; agent-mcp tracked dist committed).