Skip to content

Forge ACP v1 threat model

Forge runs as a local stdio child of Microsoft Intelligent Terminal, with the signed-in user's permissions. Its commands are /health, /agents, /sessions, /usage, and /help.

ACP messages from the client are untrusted, including prompt text, resource links, and cwd. Gateway response bodies are also untrusted because they become terminal text. Same-user processes, the user's own %LOCALAPPDATA% and %USERPROFILE%\.fleet-secrets, and the loopback gateway are inside the trust boundary. Same-user code can already read the gateway token. This boundary does not provide isolation from malicious code running as that user.

Controls

  • src/Forge.Acp/AcpServer.cs: DefaultMaxLineChars limits an input line to 4 Mi characters; HandleRequestAsync enforces MaxOutstandingRequests (64). HandleNewSessionAsync enforces MaxSessions (256), evicting idle sessions.
  • src/Forge.Acp/AcpServer.cs: _outbound holds at most 1,024 messages. _runToken stops producers and backend work; the separate _abortCts stops transport I/O. WriteLineAsync uses TryWrite: saturation of an open queue aborts, while frames arriving after normal completion are silently dropped. WriterLoopAsync reads with the abort token and directly awaits each write and flush with a linked per-frame WriteTimeout (30 seconds); no write task is orphaned. I/O failures and timeouts call AbortTransport, and the stream is never reused after a timeout. Abort wakes both idle and active writers. Reader results distinguish data, EOF, shutdown, and fault; observed late reader faults also abort and mark TransportFailed. When reading ends, producers are cancelled, handlers drain for DrainTimeout, and the outbound queue completes. Writer draining then gets its own five-second budget; expiry aborts transport and waits at most two further seconds. Final cancelled prompt frames can drain without cancelling stdout. CLI exit precedence is transport failure (1), handled exception (1), Ctrl+C (130), then clean EOF (0).
  • src/Forge.Acp/TerminalText.cs: TerminalText.Sanitize removes terminal control characters and bidi controls. AcpServer.EmitAsync and SanitizeInput in src/Forge.Acp/AcpServer.cs, and Program.RunAskEventsAsync in src/Forge.Cli/Program.cs, apply it at terminal output boundaries.
  • src/Forge.Acp/AcpServer.cs: TryNormalizeCwd requires a fully qualified local path and rejects Windows UNC and device paths. Resource links remain metadata; v1 does not fetch them.
  • src/Forge.Acp/FleetBackend.cs: ValidateGateway requires a loopback HTTP(S) URL without userinfo, query, or fragment. CreateHandler disables redirects and proxies. GatewayGetAsync applies DefaultRequestTimeout (15 seconds), including body reads; ReadBoundedAsync enforces MaxBodyBytes (1 MiB). Caller cancellation propagates without final frames. HTTP/I/O failures map to unreachable, invalid UTF-8 to bad encoding, and malformed JSON to bad JSON; gateway labels are sanitized before becoming terminal text.
  • src/Forge.Acp/FleetBackend.cs: ReadLocalBoundedAsync, called by ReadTokenAsync and ReadUsageAsync, limits token reads to TokenByteCap (4 KiB) and usage reads to UsageByteCap (128 KiB).
  • src/Forge.Cli/Program.cs: RunAcpAsync leaves transcripts off unless explicitly enabled by --log or FORGE_ACP_LOG. In src/Forge.Acp/Transcript.cs, JsonlTranscript.Write bounds entries to MaxEntryChars (4,096 characters) and queues at most QueueCapacity (256). Open and WriteLoopAsync enforce MaxRetainedBytes (4 MiB) per transcript file. Logging disables on saturation or I/O failure; enabled transcripts may contain prompt text.
  • src/Forge.Acp/FleetBackend.cs: PromptAsync returns FreeTextMessage ("not wired") for free text, without network access or execution.

Out of scope

Process spawning is absent from v1. /council belongs to follow-up FLT-468. The closed gateway chat route belongs to FLT-467; v1 does not call it.

Deferred hardening (FLT-469)

Locations below refer to the round-5 reviewed revision, 2355f5b.

  • src/Forge.Acp/AcpServer.cs:108, legal maximum lines amplify synchronous parsing and large-object allocations (Medium; no stated allocation budget).
  • src/Forge.Acp/AcpServer.cs:473, single-flight slot clears before the final result is queued (Medium; ordering outside stated controls).
  • src/Forge.Acp/AcpServer.cs:171, drain snapshot/deadline does not fence surviving backend work (Low).
  • src/Forge.Acp/AcpServer.cs:299, prompt DOM parsing can throw outside the tracked-handler catch (Low).
  • src/Forge.Acp/AcpServer.cs:424, resource links retain their full metadata DOM (Low).
  • src/Forge.Acp/AcpServer.cs:402, idle eviction can miss a newly idle session (Low).
  • src/Forge.Acp/AcpServer.cs:486, prompt CTS cancellation races disposal (Low).
  • src/Forge.Acp/AcpServer.cs:455, saturation does not synchronously stop producers and lacks a queued-byte budget (Low).
  • src/Forge.Acp/AcpServer.cs:514, sanitized rawInput keys can collide; unusual JsonValue/depth cases need hardening (Low).
  • src/Forge.Acp/AcpServer.cs:532, response IDs are reparsed and response-sent state is a plain bool (Low).
  • src/Forge.Cli/Program.cs:189, unknown backend event types do not mark ask failed (Low).
  • src/Forge.Cli/Program.cs:198, exception diagnostics may disclose sensitive message content (Low).
  • src/Forge.Cli/Program.cs:184, ask bypasses the ACP cwd normalizer (Low).
  • src/Forge.Acp/FleetBackend.cs:189, unknown-command tokens amplify allocations and echoed text (Low).
  • src/Forge.Acp/FleetBackend.cs:274, composed request URIs are not repinned and HostPc skips header validation (Low).
  • src/Forge.Acp/FleetBackend.cs:321, non-401 error snippets can disclose reflected sensitive data (Low).
  • src/Forge.Acp/TerminalText.cs:15, residual Unicode marks and separators permit visual spoofing (Low).
  • src/Forge.Acp/Transcript.cs:43, null transcript arguments can throw into the protocol caller (Low).
  • src/Forge.Acp/Transcript.cs:38, truncation suffix exceeds the entry cap and an injected oversized stream remains oversized (Low).
  • src/Forge.Acp/Transcript.cs:36, inherited transcript ACLs may allow other-user reads (Low).
  • Round-7 finding 7 (ff74949), src/Forge.Cli/Program.cs:208: consolidate duplicate gateway validation and dispose HttpClient if backend construction fails.
  • Round-7 finding 8 (ff74949), src/Forge.Acp/FleetBackend.cs:148: consolidate read-only command dispatch and derive command/help metadata from one table.
  • Round-7 finding 9 (ff74949), src/Forge.Acp/FleetBackend.cs:472: remove unreachable UsageCap truncation and avoid allocating for the empty-output check.
  • Round-7 finding 10 (ff74949), src/Forge.Acp/AcpServer.cs:83: avoid stdin chunk string allocation and the second copy with owned pooled buffers or ReadOnlyMemory.
  • Round-8 (6598e95), src/Forge.Acp/FleetBackend.cs:227: consolidate duplicated token-error catch bodies.
  • Round-8 (6598e95), src/Forge.Acp/FleetBackend.cs:149: replace the four copied command blocks with shared dispatch metadata.
  • Round-8 (6598e95), src/Forge.Acp/AcpServer.cs:146: reduce repeated stdin chunk copies.
  • Round-8 (6598e95), src/Forge.Cli/Program.cs:210: remove double gateway validation and protect HttpClient lifetime on constructor failure.
  • Round-8 (6598e95), src/Forge.Acp/FleetBackend.cs:337: bound Snippet input before sanitizing it.