Skip to content

fix(core): Apply dataCollection.databaseQueryData to inline SQL literals - #24089

Draft
s1gr1d wants to merge 1 commit into
developfrom
sig/dc-database-query-data
Draft

fix(core): Apply dataCollection.databaseQueryData to inline SQL literals#24089
s1gr1d wants to merge 1 commit into
developfrom
sig/dc-database-query-data

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 4, 2026

Copy link
Copy Markdown
Member

dataCollection.databaseQueryData: false did nothing outside Supabase. mysql, mysql2, postgres, tedious, knex, the Nuxt DB helper and Cloudflare D1 all wrote the raw statement to db.query.text, so inline literals like WHERE email = 'jane@example.com' shipped either way. Most of them already computed a sanitized copy for db.query.summary and then ignored it.

The new filterCollectedDbQueryText helper in @sentry/core/server keeps the raw statement by default and swaps in the sanitized one when the option is off. The spec exempts sanitized statements, so dropping the attribute would cost more than it protects.

Fixes #24084

…erals

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.69 kB - -
@sentry/browser - with treeshaking flags 26.99 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.89 kB - -
@sentry/browser (incl. Tracing) 49.07 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.07 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.98 kB - -
@sentry/browser (incl. Tracing, Replay) 88.62 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.85 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.3 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.24 kB - -
@sentry/browser (incl. Feedback) 46.17 kB - -
@sentry/browser (incl. sendFeedback) 33.75 kB - -
@sentry/browser (incl. FeedbackAsync) 38.85 kB - -
@sentry/browser (incl. Metrics) 29.66 kB - -
@sentry/browser (incl. Logs) 29.94 kB - -
@sentry/browser (incl. Metrics & Logs) 30.59 kB - -
@sentry/react 30.45 kB - -
@sentry/react (incl. Tracing) 51.28 kB - -
@sentry/vue 35.91 kB - -
@sentry/vue (incl. Tracing) 51.34 kB - -
@sentry/svelte 28.71 kB - -
CDN Bundle 30.43 kB - -
CDN Bundle (incl. Tracing) 49.6 kB - -
CDN Bundle (incl. Logs, Metrics) 32.66 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.53 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.31 kB - -
CDN Bundle (incl. Tracing, Replay) 87.15 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.08 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.03 kB - -
CDN Bundle - uncompressed 90.13 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.81 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.52 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.59 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.82 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.44 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.15 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.9 kB - -
@sentry/nextjs (client) 53.89 kB - -
@sentry/sveltekit (client) 49.51 kB - -
@sentry/core/server 41 kB +0.11% +45 B 🔺
@sentry/core/browser 13.53 kB - -
@sentry/node 124.81 kB +0.07% +75 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB - -
@sentry/node - without tracing 88.5 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 104.14 kB +0.08% +74 B 🔺
@sentry/aws-serverless 96.87 kB +0.03% +23 B 🔺
@sentry/cloudflare (withSentry) - minified 201.72 kB +0.09% +166 B 🔺
@sentry/cloudflare (withSentry) 501.87 kB +0.1% +498 B 🔺

View base workflow run

Comment on lines +19 to +21
filterCollectedDbQueryText,
flushIfServerless,
} from '@sentry/core/server';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nuxt DB breadcrumbs and static span names bypass databaseQueryData redaction

Nuxt's database instrumentation filters only the db.query.text span attribute; successful queries still place the raw SQL in breadcrumb fields and use it as the span name when span streaming is disabled. Inline literals derived from caller or request data can therefore be sent despite dataCollection.databaseQueryData: false; apply the helper to the breadcrumb and non-streaming span-name paths.

Evidence
  • createBreadcrumb() passes the unfiltered query to both message and data['db.query.text']; addBreadcrumb() stores these values on the current isolation scope for subsequent events.
  • In createStartSpanOptions(), the non-streaming branch sets name directly to query, while only the db.query.text attribute uses filterCollectedDbQueryText.
  • Nuxt's production database plugins invoke this instrumentation for configured Nitro databases, and db.exec plus prepared-statement methods accept statements containing inline literals.
  • No central breadcrumb or span-name filtering applies databaseQueryData, so a successful query followed by an error event or a static transaction can expose the raw literal.

Identified by Warden · security-review · ZWT-URM

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.

dataCollection.databaseQueryData has no effect on db.query.text

1 participant