Skip to content

MSSQL QuoteIdentifier does not escape ] characters, enabling SQL injection in all MSSQL operations#324

Open
shanecodezzz wants to merge 1 commit intocrossplane-contrib:masterfrom
shanecodezzz:fix/code-quality-1771103319
Open

MSSQL QuoteIdentifier does not escape ] characters, enabling SQL injection in all MSSQL operations#324
shanecodezzz wants to merge 1 commit intocrossplane-contrib:masterfrom
shanecodezzz:fix/code-quality-1771103319

Conversation

@shanecodezzz
Copy link

Description of your changes

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

…e `]` characters, enabling sql injection in all mssql operations.

Escape closing brackets by replacing `]` with `]]` inside QuoteIdentifier, matching the MySQL/PostgreSQL escaping pattern.
Copy link

@paragon-review paragon-review left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This review identified 1 issue in 2 files.

Confidence score: 5/5

  • Low risk - No critical or high-priority issues found

Severity breakdown: Low: 1

2 files reviewed, 1 comment


Tip: @paragon-run <instructions> to chat with our agent or push fixes!

Dashboard

// QuoteIdentifier for mssql queries
func QuoteIdentifier(id string) string {
return "[" + id + "]"
return "[" + strings.ReplaceAll(id, "]", "]]") + "]"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security: No unit tests exist for QuoteIdentifier or QuoteValue

No unit tests exist for QuoteIdentifier or QuoteValue. Regressions to this SQL injection fix would go undetected. Add table-driven tests covering ], ]], empty string, and embedded [ inputs.

View Details

Location: pkg/clients/mssql/mssql.go (lines 124)

Analysis

No unit tests exist for QuoteIdentifier or QuoteValue

What fails There are no tests for QuoteIdentifier or QuoteValue in the mssql package, so regressions to this critical SQL injection fix would not be caught.
Result No test files found — zero coverage for quoting functions.
Expected Table-driven unit tests should cover edge cases: input containing ], input containing ]], empty string, embedded [ characters, and normal identifiers.
Impact Without tests, future changes could silently reintroduce the SQL injection vulnerability this PR fixes.
How to reproduce
ls pkg/clients/mssql/*_test.go  # No test files exist
AI Fix Prompt
Fix this issue: No unit tests exist for QuoteIdentifier or QuoteValue. Regressions to this SQL injection fix would go undetected. Add table-driven tests covering ], ]], empty string, and embedded [ inputs.

Location: pkg/clients/mssql/mssql.go (lines 124)
Problem: There are no tests for QuoteIdentifier or QuoteValue in the mssql package, so regressions to this critical SQL injection fix would not be caught.
Current behavior: No test files found — zero coverage for quoting functions.
Expected: Table-driven unit tests should cover edge cases: input containing ], input containing ]], empty string, embedded [ characters, and normal identifiers.
Steps to reproduce: ls pkg/clients/mssql/*_test.go  # No test files exist

Provide a code fix.

Tip: Reply with @paragon-run to automatically fix this issue

@shanecodezzz
Copy link
Author

Hey @crossplane-contrib!

We ran Paragon on this PR and it caught some real issues — check the inline comments above.

Found 1 issues including bugs and security fixes.

We know maintaining OSS is tough, especially without automated code review catching things before they hit prod. We set up open source projects with Paragon so you don't have to worry about that stuff. Shoot me an email at shane@polarity.so if you're interested, happy to get you set up!

polarity.so/paragon

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants