fix(mcp): use standalone flag matching to prevent false positives#1152
Open
algojogacor wants to merge 1 commit into
Open
fix(mcp): use standalone flag matching to prevent false positives#1152algojogacor wants to merge 1 commit into
algojogacor wants to merge 1 commit into
Conversation
Previously ValidateArgs used strings.Contains for all dangerous patterns, causing legitimate package names like 'clickup-cli' to be rejected because they contain '-c' as a substring of '-cli'. Split dangerous patterns into: - dangerousFlagPatterns: matched as standalone flags only (exact or flag=value) - dangerousCodePatterns: matched by substring for code injection patterns Closes nextlevelbuilder#1027
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.
This is an independent contribution from an open-source contributor.
Summary
Fix false positive in MCP argument validation where package names containing
-c(likeclickup-cli) are incorrectly rejected as dangerous patterns.Root Cause
ValidateArgs()ininternal/mcp/validation.gousedstrings.Containsfor all dangerous patterns. This caused-cto match inside-cli, triggering false positives for npm packages likeclickup-cli,mcp-cli, etc.Fix
Split
dangerousArgPatternsinto two categories:-c,-e,-r,--eval,--require,--import): matched using newisStandaloneFlag()helper that checks for exact match or flag=value form, avoiding substring false positivesexec(,eval(,__import__,child_process,subprocess): continue usingstrings.Containsfor code injection patterns that should be caught anywhereTesting
-c,-e,--evalstill correctly rejectedclickup-cli,@clickup-cli,mcp-clino longer trigger false positives-c"code",-e=script,--eval=codestill correctly rejectedCloses #1027