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:DefaultMaxLineCharslimits an input line to 4 Mi characters;HandleRequestAsyncenforcesMaxOutstandingRequests(64).HandleNewSessionAsyncenforcesMaxSessions(256), evicting idle sessions.src/Forge.Acp/AcpServer.cs:_outboundholds at most 1,024 messages._runTokenstops producers and backend work; the separate_abortCtsstops transport I/O.WriteLineAsyncusesTryWrite: saturation of an open queue aborts, while frames arriving after normal completion are silently dropped.WriterLoopAsyncreads with the abort token and directly awaits each write and flush with a linked per-frameWriteTimeout(30 seconds); no write task is orphaned. I/O failures and timeouts callAbortTransport, 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 markTransportFailed. When reading ends, producers are cancelled, handlers drain forDrainTimeout, 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.Sanitizeremoves terminal control characters and bidi controls.AcpServer.EmitAsyncandSanitizeInputinsrc/Forge.Acp/AcpServer.cs, andProgram.RunAskEventsAsyncinsrc/Forge.Cli/Program.cs, apply it at terminal output boundaries.src/Forge.Acp/AcpServer.cs:TryNormalizeCwdrequires 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:ValidateGatewayrequires a loopback HTTP(S) URL without userinfo, query, or fragment.CreateHandlerdisables redirects and proxies.GatewayGetAsyncappliesDefaultRequestTimeout(15 seconds), including body reads;ReadBoundedAsyncenforcesMaxBodyBytes(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 byReadTokenAsyncandReadUsageAsync, limits token reads toTokenByteCap(4 KiB) and usage reads toUsageByteCap(128 KiB).src/Forge.Cli/Program.cs:RunAcpAsyncleaves transcripts off unless explicitly enabled by--logorFORGE_ACP_LOG. Insrc/Forge.Acp/Transcript.cs,JsonlTranscript.Writebounds entries toMaxEntryChars(4,096 characters) and queues at mostQueueCapacity(256).OpenandWriteLoopAsyncenforceMaxRetainedBytes(4 MiB) per transcript file. Logging disables on saturation or I/O failure; enabled transcripts may contain prompt text.src/Forge.Acp/FleetBackend.cs:PromptAsyncreturnsFreeTextMessage("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.