Skip to content

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

Open
s1gr1d wants to merge 3 commits into
sig/db-tests-improvementsfrom
sig/db-tests-improvements-1
Open

fix(server-utils): Sanitize SQL Server bracketed identifiers#24255
s1gr1d wants to merge 3 commits into
sig/db-tests-improvementsfrom
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 📦

Path Size % Change Change
@sentry/browser 28.81 kB - -
@sentry/browser - with treeshaking flags 27.12 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB - -
@sentry/browser (incl. Tracing) 49.27 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.28 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.21 kB - -
@sentry/browser (incl. Tracing, Replay) 88.81 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.99 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.49 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.44 kB - -
@sentry/browser (incl. Feedback) 46.3 kB - -
@sentry/browser (incl. sendFeedback) 33.87 kB - -
@sentry/browser (incl. FeedbackAsync) 38.99 kB - -
@sentry/browser (incl. Metrics) 29.84 kB - -
@sentry/browser (incl. Logs) 30.1 kB - -
@sentry/browser (incl. Metrics & Logs) 30.78 kB - -
@sentry/react 30.57 kB - -
@sentry/react (incl. Tracing) 51.64 kB - -
@sentry/vue 36.07 kB - -
@sentry/vue (incl. Tracing) 51.56 kB - -
@sentry/svelte 28.85 kB - -
CDN Bundle 30.56 kB - -
CDN Bundle (incl. Tracing) 49.81 kB - -
CDN Bundle (incl. Logs, Metrics) 32.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.77 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.48 kB - -
CDN Bundle (incl. Tracing, Replay) 87.35 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.26 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.28 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.27 kB - -
CDN Bundle - uncompressed 90.47 kB - -
CDN Bundle (incl. Tracing) - uncompressed 148.36 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 154.32 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.3 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.95 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.65 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 287.59 kB - -
@sentry/nextjs (client) 54.09 kB - -
@sentry/sveltekit (client) 49.73 kB - -
@sentry/core/server 36.99 kB - -
@sentry/core/browser 13.55 kB - -
@sentry/node 128.16 kB +0.19% +240 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.61 kB - -
@sentry/node - without tracing 88.73 kB +0.03% +22 B 🔺
@sentry/node - without channel injection 107.42 kB +0.26% +270 B 🔺
@sentry/aws-serverless 97.12 kB +0.03% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 202.67 kB +0.31% +623 B 🔺
@sentry/cloudflare (withSentry) 504.38 kB +0.3% +1.47 kB 🔺

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!

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!

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