feat(security): SEC-06 - block filesystem disclosure in SHOW_AD mode#63
Merged
Killea merged 1 commit intoKillea:mainfrom Mar 19, 2026
Merged
Conversation
When SHOW_AD=true (public demo), agents could leak host filesystem information by posting directory listings through AgentChatBus messages. Changes: - New filesystemDisclosureFilter.ts: 6 detection patterns - Unix tree connector output (>=2 lines with ├── / └── / │) - Unix ls -la output (permissions block + total header) - Windows dir/Get-ChildItem output (column header or >=2 mode lines) - Dense path cluster (>=3 consecutive absolute path lines, line-counting) - /etc/passwd content dump (colon-separated UID:GID format) - SSH public key / authorized_keys content - Integrate checkFilesystemDisclosureOrThrow() in memoryStore.postMessage() and editMessage() — active only when SHOW_AD=true - /api/agents/register returns restricted_mode:true + restrictions array when SHOW_AD=true (cooperative signal for well-behaved MCP clients) - 36 new unit + integration tests (all pass) Design: conservative. Single path mention in prose = allowed. Structured bulk output = blocked. createThread system_prompt intentionally not filtered (admin-controlled, not agent-generated).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
filesystemDisclosureFilter.ts: server-side detection of filesystem directory listings in demo mode (SHOW_AD=true)memoryStore.postMessage()andeditMessage()— SHOW_AD-conditional, no impact on private/localhost deployments/api/agents/registerreturnsrestricted_mode: true+restrictions: ['no_filesystem_disclosure']whenSHOW_AD=true(cooperative signal for MCP clients)Motivation
On the public demo instance, an agent listed the full working directory structure when asked by another agent (public demo thread, 2026-03-08). The listing was produced by the agent's own filesystem tools (client-side), then posted as a message through AgentChatBus.
ACB cannot block client-side tool execution, but can enforce two complementary mitigations:
Content filter extension (server-enforced): Extend the existing
CONTENT_FILTERpattern whenSHOW_AD=trueto detect and block messages containing directory listings. Returns 400 with explanation.Restricted mode signal (cooperative): When an agent registers on a
SHOW_AD=trueinstance, the registration response includesrestricted_mode: true+restrictions: ['no_filesystem_disclosure']. Well-behaved MCP clients can use this to disable their filesystem tools proactively.Detection Patterns
Six patterns, all conservative (low false positive risk):
ls -ladrwx...) andtotal NheaderdirheaderMode ... LastWriteTime ... Namedirentriesd----/-a---+ date format/etc/passwdformat (user:x:0:0:) or SSH public key headerIntentionally allowed (to minimise false positives):
~/.ssh/mentioned in prose ("protect your~/.ssh/directory")createThreadsystem_prompt— admin-controlled, not agent-generatedTest plan
npm test -- tests/unit/test_filesystem_disclosure_filter.test.ts— 36/36 passnpm test— 529/530 pass (1 pre-existing flaky timing test inmsgWaitMinTimeoutABScenario, unrelated to this PR)/api/agents/registeron instance withSHOW_AD=true— response includesrestricted_mode: true/api/threads/:id/messageswith a tree output body onSHOW_AD=trueinstance — 400 with disclosure messageLimitations
restricted_modesignal only works if the client respects it; a malicious client can ignore it