Skip to content

fix: MCP guard, socket host, RPC client, sandbox runner, file launch hardening (#1565) - #1679

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
issue/1565-review-hardening
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
issue/1565-review-hardening

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Refs #1565 (CSV export items are left for a decision: BOM, formula guard and CRLF change the file users get).

  • MCP SQL guard: refuse QUERY_TO_XML*, CURSOR_TO_XML, TABLE_TO_XML*, PG_ADVISORY_*, PG_SLEEP*, LO_*, NEXTVAL, SETVAL. EXPLAIN SELECT REPLACE(...) is allowed again; only REPLACE INTO is refused.
  • McpSocketHost: at most 16 sockets waiting for their token and 4 KiB before the token line is complete.
  • JsonRpcStdioClient.sendRequest: the write is inside the try, so a closed sink does not leave _pending[id] behind.
  • SandboxProcessRunner.start: the scratch directory is deleted if detecting bwrap or building the launch command throws.
  • FileLaunchService: dropped the duplicate hasPendingTarget; SQLite path comparison is case-insensitive on Windows and macOS.
  • Tests for the guard and the socket host.

@github-actions github-actions Bot added enhancement New feature or request stability Theme parser epic label: stability core Core library logic and services P3 Low priority / Polish & Enhancements labels Oct 17, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 4465669 into dev Oct 17, 2026
14 checks passed
@ZhuchkaTriplesix

Copy link
Copy Markdown
Member Author

🔍 Post-Merge Code Review & Verification

Great defense-in-depth security hardening across the MCP and platform subsystems:

  1. MCP SQL Guard Refusals (mcp_sql_guard.dart):

    • Thorough coverage against side-effect functions outside transaction semantics (QUERY_TO_XML, PG_ADVISORY_*, PG_SLEEP, LO_*, NEXTVAL, SETVAL).
    • Restricting REPLACE INTO while re-allowing EXPLAIN SELECT REPLACE(...) prevents false-positive query rejections on safe string transformations.
  2. DoS Protection on MCP Sockets (mcp_socket_host.dart):

    • Limiting pending unauthenticated connections (maxUnauthenticated: 16) and enforcing a hard cap on handshake line length (maxHandshakeBytes: 4096) mitigates local port-exhaustion attacks.
  3. RPC & Process Safety (json_rpc_stdio_client.dart, sandbox_process_runner.dart):

    • Immediate cleanup of _pending[id] upon write failure prevents unbounded completer memory leaks when stdio pipe breaks.
    • Guarantees scratch directory deletion if bubblewrap detection throws.
  4. Cross-Platform File Launching (file_launch_service.dart):

    • Case-insensitive comparison _samePath on Windows and macOS aligns with native filesystem semantics for SQLite databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core library logic and services enhancement New feature or request P3 Low priority / Polish & Enhancements stability Theme parser epic label: stability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant