Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix(tools,security): close gaps found in sandbox-hardening review

4 months ago

ebe8bf3
Authored
mweinbach6/9/2026, 10:38:38 PM
Follow-up hardening from a review of the branch:

- webFetch: cancel the response stream on over-cap throw (was leaking the
  connection like the download path already guards against), decode
  incrementally to halve peak memory, and cap the null-body fallback.
- webFetch: defang an embedded end-marker / sanitize the URL so attacker
  page content cannot break out of the untrusted-content frame.
- mcp: cap nested schema property/enum descriptions, not just the
  top-level tool description, so a hostile server cannot inject a large
  payload via a nested description.
- skills: keep the operator-authored policy overlay OUTSIDE the untrusted
  project-skill frame; add an exception line to the referenced-skill
  injection/steer headers so the "authoritative" wrapper no longer
  contradicts the inner untrusted framing.
- permissions: canonicalize credential deny dirs so a workspace symlink
  into .cowork/auth cannot bypass the block when the workspace path is
  itself symlinked (e.g. macOS /var -> /private/var).
- edit: reject a replaceAll whose projected result would exceed the file
  cap before building the string (heap-exhaustion guard).
- cleanup: move stranded imports to the top of AgentControl; extract the
  duplicated withRequestTimeout helper into src/utils/abortSignal.

Adds regression tests for each behavioral fix.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Parentf4906ee

16 files changed
  • src/mcp/index.ts+7−0
  • src/server/agents/AgentControl.ts+13−13
  • src/server/session/turnExecution/referenceInjection.ts+6−0
  • src/server/session/turnExecution/steerCoordinator.ts+6−0
  • src/skills/loadSkillBody.ts+7−3
  • src/tools/edit.ts+17−7
  • src/tools/exa.ts+1−5
  • src/tools/parallel.ts+1
−5
  • src/tools/webFetch.ts+33−6
  • src/utils/abortSignal.ts+13−0
  • src/utils/permissions.ts+11−2
  • test/mcp.test.ts+23−0
  • test/permissions.test.ts+21−0
  • test/skills.loadSkillBody.test.ts+18−0
  • test/tools/tools.edit.test.ts+20−0
  • test/tools/tools.webFetch.test.ts+32−0