fix(security): do not treat COMMENT/CALL table names as mutations - #64
Merged
Conversation
Bare \bCOMMENT\b / \bCALL\b scans rejected SELECT * FROM comment. Match statement verbs only (mutating CTEs, WITH … DML, FOR UPDATE). Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
venkateshsakamuri-lab
marked this pull request as ready for review
August 17, 2026 18:28
venkateshsakamuri-lab
requested review from
a team and
geekypunk
as code owners
August 17, 2026 18:28
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
geekypunk
approved these changes
Aug 17, 2026
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
Yes, this is a real bug and it should be fixed before anyone hits it on a
commenttable.McpSqlGuardService.containsForbiddenKeyword(and the matching MCP JS shim) scanned the whole statement with\bCOMMENT\b/\bCALL\b. That is an identifier match, not a statement-verb match, so these were rejected as "potentially mutating":SELECT * FROM commentSELECT * FROM callJOIN comment ON comment.id = …SELECT COALESCE(comment, '')SELECT REPLACE(name, 'a', 'b')(REPLACEis also on the forbidden list)This guard sits on dashboard artifact queries (
POST /api/dashboards/queryand the public share query path) as well as/api/mcp/query-readonly. A generated dashboard against acommenttable would fail at the gate.Fix
Stop scanning bare words. Detect mutating statements only:
WITH x AS (DELETE FROM t RETURNING …) SELECT …WITH x AS (SELECT …) DELETE FROM t …SELECT … FOR UPDATEEXPLAIN DELETE …(whileEXPLAIN SELECT * FROM commentstays allowed)Top-level
DELETE/CALL/COMMENT ONwere already rejected by the first-keyword allowlist and still are.Java and JS stay in lockstep.
Test plan
./mvnw test -Dtest=McpSqlGuardServiceTest— 12 tests, 0 failures (FROM comment/FROM callallowed; mutating CTEs andWITH … DELETEstill blocked)node --test mcp/deepsql-phase1-lib.test.js— 78 tests, 0 failures