Repository navigation
test(mcp): security suite for the MCP server - #1142
Merged
Merged
Conversation
… executable comments (#1138)
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.
Security suite for the MCP epic #1133, with two hardening fixes it turned up.
Fixes
McpRedaction: the connection's own secrets when loaded (password, connection string, SSH password / key / passphrase),scheme://user:pass@user info,password= / pwd= / passphrase= / token= / api_key=values and PEM private keys are masked. Also applied when creating the delegate fails./*! ... */and/*M! ... */, which the comment stripper hid from the guard. For MySQL connections such comments are now refused.Tests (
test/core/mcp/mcp_security_test.dart)McpSqlGuard(DML, DDL, GRANT, COPY, CALL, DO, PREPARE/EXECUTE, SET / RESET / BEGIN READ WRITE, NOTIFY, stacked statements, data-modifying CTEs, EXPLAIN ANALYZE, SELECT INTO / INTO OUTFILE, row locks, server functions, comment-split keywords, executable comments, ATTACH, writable PRAGMAs, load_extension ...), and none of them reaches the delegate throughrun_queryorexplain_query.isReadOnly: true(layer 2).schema://resource, called through a real MCP client, never return password, SSH password / key / passphrase, host, user or file path: in normal results, in driver errors that quote all of them, and when delegate creation fails.McpRedactionunit tests.Already covered elsewhere and not duplicated: token refusal and 0600 / 0700 permissions (
mcp_server_test.dart), timeout / row limit / cell truncation (mcp_query_service_test.dart), the database refusing a write on the real SQLite MCP session (mcp_sqlite_readonly_test.dart).Not done: a live Postgres / MySQL read-only check; CI has no database services. The session flags themselves are covered by the pool tests.
Written without running locally; CI is the first run.
Closes #1138