W-22550530: Prevent SOQL injection in DevOps Work Item and Pipeline queries#460
Open
jag-j wants to merge 4 commits into
Open
W-22550530: Prevent SOQL injection in DevOps Work Item and Pipeline queries#460jag-j wants to merge 4 commits into
jag-j wants to merge 4 commits into
Conversation
Fixes W-22550530 This commit addresses SOQL injection vulnerabilities in the MCP DevOps provider by implementing strict input validation for all user-provided values in SOQL queries. Changes: - Created soqlUtils.ts with validation functions for Salesforce IDs and work item names - Added isValidSalesforceId() to validate 15/18 character ID format - Added validateWorkItemName() to validate WI-XXXXXXX format - Added escapeSoqlString() for proper quote escaping - Applied validation to all SOQL queries in: * getWorkItems.ts (projectId, workItemName) * getWorkItemsMP.ts (workItemName, workItemId) * getPipelineMP.ts (projectId) * getPipelineStagesMP.ts (pipelineId) - Added comprehensive unit tests for all validation functions Security improvements: - Prevents injection via malformed IDs like "001' OR 1=1--" - Validates work item name format before query construction - Rejects all non-alphanumeric characters in IDs - Blocks common SQL injection patterns Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The previous validation was too strict and only accepted WI-XXXXXXX format. This caused test failures because managed package work items can have alphanumeric names like "Test Work Item". Changes: - Added containsSqlInjectionPatterns() to detect actual injection attempts - Updated validateWorkItemName() to accept both: * Standard format: WI-XXXXXXX * Managed package format: alphanumeric with spaces, hyphens, underscores - Still blocks all SQL injection patterns (OR, UNION, --, semicolons, etc.) - Added tests for new validation scenarios - Maintains strong security while supporting existing test mocks This fixes test failures while preserving injection protection.
- Remove single quote from injection patterns array (was causing array index issues) - Simplify containsSqlInjectionPatterns logic - Allow single quotes in safe name pattern since they are escaped - Simplify error message format for validateWorkItemName This fixes unit test failures where valid names like "O'Brien Task" were incorrectly rejected. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Fixes @W-22550530@
This commit addresses SOQL injection vulnerabilities in the MCP DevOps provider by implementing strict input validation for all user-provided values in SOQL queries.
Changes:
Security improvements:
What does this PR do?
What issues does this PR fix or reference?