Skip to content

fix(server-utils): Sanitize SQL Server bracketed identifiers - #24255

Merged
s1gr1d merged 4 commits into
developfrom
sig/db-tests-improvements-1
Sep 10, 2026
Merged

fix(server-utils): Sanitize SQL Server bracketed identifiers#24255
s1gr1d merged 4 commits into
developfrom
sig/db-tests-improvements-1

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 9, 2026

Copy link
Copy Markdown
Member

Follow-up for #24248, which left the SQL Server case open.

The sanitizer had no state for T-SQL [bracketed] identifiers, so a quote inside one desynced it: SELECT * FROM [dbo].[user's] WHERE email = 'jane@example.com' leaked the address into db.query.text and db.query.summary.

There is now an mssql dialect that reads [...] as an identifier, and tedious, knex and Prisma route to it through a new
toSqlDialect() helper.

Two older leaks turned up while testing it: an identifier run ending in an escaped closer ([a]], "") was treated as closed and copied out whole, and T-SQL money literals ($1000) survived because the integer pattern protects PostgreSQL $n placeholders.

Known limit: SQLite accepts [...] too, but shares the standard dialect with PostgreSQL, where reading brackets as identifiers would keep ARRAY['secret'] raw.

Sources:

@s1gr1d
s1gr1d added this pull request to stack #24251 September 9, 2026 14:36
@s1gr1d
s1gr1d requested a review from a team as a code owner September 9, 2026 14:36
@s1gr1d
s1gr1d requested review from logaretm and stephanie-anderson and removed request for a team September 9, 2026 14:36
@s1gr1d

s1gr1d commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@s1gr1d
s1gr1d requested a review from Lms24 September 9, 2026 14:36
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.91 kB - -
@sentry/browser - with treeshaking flags 27.21 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.1 kB - -
@sentry/browser (incl. Tracing) 50.27 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.28 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.26 kB - -
@sentry/browser (incl. Tracing, Replay) 89.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 78.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.46 kB - -
@sentry/browser (incl. Feedback) 46.4 kB - -
@sentry/browser (incl. sendFeedback) 33.96 kB - -
@sentry/browser (incl. FeedbackAsync) 39.07 kB - -
@sentry/browser (incl. Metrics) 29.93 kB - -
@sentry/browser (incl. Logs) 30.19 kB - -
@sentry/browser (incl. Metrics & Logs) 30.86 kB - -
@sentry/react 30.66 kB - -
@sentry/react (incl. Tracing) 52.59 kB - -
@sentry/vue 36.15 kB - -
@sentry/vue (incl. Tracing) 52.53 kB - -
@sentry/svelte 28.93 kB - -
CDN Bundle 30.64 kB - -
CDN Bundle (incl. Tracing) 50.78 kB - -
CDN Bundle (incl. Logs, Metrics) 32.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.61 kB - -
CDN Bundle (incl. Tracing, Replay) 88.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.29 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.36 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.38 kB - -
CDN Bundle - uncompressed 90.72 kB - -
CDN Bundle (incl. Tracing) - uncompressed 151.68 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.3 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 157.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 271.25 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 277.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 284.95 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 290.89 kB - -
@sentry/nextjs (client) 54.91 kB - -
@sentry/sveltekit (client) 50.69 kB - -
@sentry/core/server 37.1 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 128.46 kB +0.12% +149 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.82 kB - -
@sentry/node - without tracing 89.04 kB +0.03% +24 B 🔺
@sentry/node - without channel injection 107.54 kB +0.14% +150 B 🔺
@sentry/aws-serverless 97.43 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 203.1 kB +0.16% +312 B 🔺
@sentry/cloudflare (withSentry) 505.66 kB +0.16% +788 B 🔺

View base workflow run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 92e939b. Configure here.

@s1gr1d
s1gr1d removed the request for review from stephanie-anderson September 9, 2026 15:24
@s1gr1d
s1gr1d force-pushed the sig/db-tests-improvements-1 branch from 92e939b to 1fe12a3 Compare September 9, 2026 15:25

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SQL really is another one of those "there are 15 competing standards" XKCD situations 😅

Good change, thanks!

Comment thread packages/server-utils/src/utils/sql.ts Outdated
if (system === 'mssql' || system === 'sqlserver' || system === 'microsoft.sql_server') {
return 'mssql';
}
return undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: should this return 'standard', to better match with the SqlDialect type? logaf-l, feel free to disregard!

Base automatically changed from sig/db-tests-improvements to develop September 10, 2026 08:10
@s1gr1d
s1gr1d force-pushed the sig/db-tests-improvements-1 branch from 82f5f3b to 1050489 Compare September 10, 2026 08:10
@s1gr1d
s1gr1d merged commit d3c6689 into develop Sep 10, 2026
446 of 450 checks passed
@s1gr1d
s1gr1d deleted the sig/db-tests-improvements-1 branch September 10, 2026 08:52
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