Repository navigation
fix: quote postgres warehouse ddl identifiers - #7127
achettyiitr merged 12 commits into
Conversation
|
👋 I'm rudder-devbox. I opened this PR from a Linear ticket. Leave an inline comment on the diff — pick a line, add your comment, and Top-level PR comments need |
|
I found the actionable failure in the ClickHouse integration log: I fixed the ClickHouse/root downloader issue by isolating each load-file download under a UUID-scoped temp directory instead of a second-granularity destination directory, preventing concurrent table-load cleanup from removing a shared parent while another download is creating its nested path. I also added a regression asserting downloaded load files do not share the cleanup directory. Validation passed:
Pushed commit: 180a093 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7127 +/- ##
==========================================
+ Coverage 79.66% 79.69% +0.03%
==========================================
Files 595 595
Lines 66134 66140 +6
==========================================
+ Hits 52684 52713 +29
+ Misses 10337 10303 -34
- Partials 3113 3124 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6e7244c to
c2f3b82
Compare
🔒 Scanned for secrets using gitleaks 8.29.1
c2f3b82 to
d893eca
Compare
…s-warehouse-dd-8aeacd0d
## What & why MAR (Monthly Active Records) metering for reverse-ETL / Audiences sources produced **no data** in clustered/production deployments: `activation_records_reports` stayed empty and the MAR API returned `[]`. The reporter gated reverse-ETL classification on the job's `source_category` **param**. That param is populated on the gateway web/auth path, but is **empty on the clustered `/internal/v1/batch` ingestion path** (rudder-sources → ingestion-svc → Pulsar → srcrouter → gateway). So every reverse-ETL record was silently skipped — no rows, no skip stats. ## Change Classify reverse-ETL (warehouse) sources from the **source config** (`SourceDefinition.Category`) instead of the job param: - `processor` snapshots a `source_id → category` map once per batch (single lock, category strings only) and passes a lookup `func(sourceID string) string` into the reporter. - `records_reporter.GenerateReportsFromJobs` gates on that lookup (`== "warehouse"`), still reading the fingerprint from the raw pre-strip job. Path-independent (works for `/internal/v1/batch`, `/internal/v1/retl`, single-node/mini) and fail-closed: an unknown/missing `source_id` resolves to `""` and is skipped; a spoofed `source_category` param can't force metering. This supersedes an earlier gateway-side approach (stamping `source_category` in the internal-batch handler). Classifying at the consumer keeps the change contained to the MAR feature and independent of ingestion topology, and mirrors the sibling tracked-users reporter, which already takes a source-config lookup. ## Tests `records_reporter_test.go`: warehouse source metered with an empty `source_category` param; non-warehouse source skipped; a spoofed `source_category=warehouse` param does not win over config; unknown source skipped fail-closed. ## Validation Verified end-to-end in dev (`profiles-qa`): reverse-ETL sync → rows in `activation_records_reports` → flushed to the reporting store → MAR API returns per-connection counts (was `[]`). Linear: [PRO-5810](https://linear.app/rudderstack/issue/PRO-5810)
🤖 I have created a release *beep* *boop* --- ## [1.80.1](v1.80.0...v1.80.1) (2026-07-08) ### Bug Fixes * classify reverse-ETL sources from config for MAR metering ([#7159](#7159)) ([8e026e3](8e026e3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
|
The identifier quoting added to
Safety on this path currently rests entirely on the upstream |
🔒 Scanned for secrets using gitleaks 8.29.1
…s-warehouse-dd-8aeacd0d
🔒 Scanned for secrets using gitleaks 8.29.1
a9c24e2 to
a8fae9b
Compare
|
The datalake job failed due to external Docker Hub connectivity, not a source-code or test-behavior failure. In The remaining datalake validation tests passed, and the logs contain no assertion, compilation, lint, race, or application error to fix in the repository. No code change or push is appropriate for this transient infrastructure failure; the failed job needs to be rerun when Docker Hub connectivity is available. |
|
One more that can be addressed in next PR: In insertIntoLoadTable, the column list still uses warehouseutils.DoubleQuoteAndJoinByComma(sortedColumnKeys), which wraps names with fmt.Sprintf("%q", elem): // warehouse/utils/utils.go:598 |
|
CI failed before the test could run: |
🤖 I have created a release *beep* *boop* --- ## [1.81.0-rc.1](v1.80.0...v1.81.0-rc.1) (2026-07-20) ### Features * run python transformation tests on ephemeral per-request pyt deployments ([#7177](#7177)) ([1008ae7](1008ae7)) * support partition migration job fanout per jobsdb ([#7141](#7141)) ([be42e48](be42e48)) ### Bug Fixes * abort snowpipe events on channel bad request ([#7118](#7118)) ([6c08584](6c08584)) * avoid redundant transformer statTags unmarshalling ([#7182](#7182)) ([c3c283c](c3c283c)) * classify reverse-ETL sources from config for MAR metering ([#7159](#7159)) ([fa7870f](fa7870f)) * detect server-side snowpipe channel failures via per-channel status at stuck threshold ([#7166](#7166)) ([581410c](581410c)) * kafkamanager compilation error ([#7189](#7189)) ([1fb7f6e](1fb7f6e)) * **kafka:** support insecure TLS skip verify config ([#7022](#7022)) ([d01574f](d01574f)) * preserve order when overflowing snowpipe insert batches ([#7178](#7178)) ([9c01fa0](9c01fa0)) * quote postgres warehouse ddl identifiers ([#7127](#7127)) ([5aeb481](5aeb481)) * **router:** emit invalid payload metric ([#7168](#7168)) ([6e2009a](6e2009a)) * update null to #N/A for salesforce bulk upload ([#7151](#7151)) ([1dffd93](1dffd93)) * **warehouse:** use pod identity for rudder-storage flow; keep S3-copy user fallback for user S3 destinations ([#7167](#7167)) ([3f9aa32](3f9aa32)) ### Miscellaneous * add contract tests for test endpoints in pytransformer ([#7147](#7147)) ([3b210ec](3b210ec)) * bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815 ([#7162](#7162)) ([7672f96](7672f96)) * **deps:** bump actions/checkout from 6.0.3 to 7.0.0 ([#7132](#7132)) ([d453c93](d453c93)) * **deps:** bump actions/setup-go from 6.4.0 to 6.5.0 ([#7150](#7150)) ([75d9648](75d9648)) * **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6 ([#7109](#7109)) ([7b2a859](7b2a859)) * **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to 6.2.2 ([#7152](#7152)) ([c984268](c984268)) * **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 ([#7170](#7170)) ([4565d25](4565d25)) * **deps:** bump the frequent group across 1 directory with 4 updates ([#6891](#6891)) ([88a0ddf](88a0ddf)) * support compression in bqstream destinations ([#7142](#7142)) ([0694f12](0694f12)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [1.81.0](v1.80.0...v1.81.0) (2026-07-20) ### Features * run python transformation tests on ephemeral per-request pyt deployments ([#7177](#7177)) ([1008ae7](1008ae7)) * support partition migration job fanout per jobsdb ([#7141](#7141)) ([be42e48](be42e48)) ### Bug Fixes * abort snowpipe events on channel bad request ([#7118](#7118)) ([6c08584](6c08584)) * avoid redundant transformer statTags unmarshalling ([#7182](#7182)) ([c3c283c](c3c283c)) * classify reverse-ETL sources from config for MAR metering ([#7159](#7159)) ([fa7870f](fa7870f)) * detect server-side snowpipe channel failures via per-channel status at stuck threshold ([#7166](#7166)) ([581410c](581410c)) * kafkamanager compilation error ([#7189](#7189)) ([1fb7f6e](1fb7f6e)) * **kafka:** support insecure TLS skip verify config ([#7022](#7022)) ([d01574f](d01574f)) * preserve order when overflowing snowpipe insert batches ([#7178](#7178)) ([9c01fa0](9c01fa0)) * quote postgres warehouse ddl identifiers ([#7127](#7127)) ([5aeb481](5aeb481)) * **router:** emit invalid payload metric ([#7168](#7168)) ([6e2009a](6e2009a)) * update null to #N/A for salesforce bulk upload ([#7151](#7151)) ([1dffd93](1dffd93)) * **warehouse:** use pod identity for rudder-storage flow; keep S3-copy user fallback for user S3 destinations ([#7167](#7167)) ([3f9aa32](3f9aa32)) ### Miscellaneous * add contract tests for test endpoints in pytransformer ([#7147](#7147)) ([3b210ec](3b210ec)) * bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815 ([#7162](#7162)) ([7672f96](7672f96)) * **deps:** bump actions/checkout from 6.0.3 to 7.0.0 ([#7132](#7132)) ([d453c93](d453c93)) * **deps:** bump actions/setup-go from 6.4.0 to 6.5.0 ([#7150](#7150)) ([75d9648](75d9648)) * **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6 ([#7109](#7109)) ([7b2a859](7b2a859)) * **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to 6.2.2 ([#7152](#7152)) ([c984268](c984268)) * **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 ([#7170](#7170)) ([4565d25](4565d25)) * **deps:** bump the frequent group across 1 directory with 4 updates ([#6891](#6891)) ([88a0ddf](88a0ddf)) * support compression in bqstream destinations ([#7142](#7142)) ([0694f12](0694f12)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
insertIntoLoadTable built the column list with DoubleQuoteAndJoinByComma, which uses Go's %q and escapes a double quote as \" instead of doubling it, so a column name containing a quote could break out of the identifier. Quote each column with pq.QuoteIdentifier instead. Raised as a follow-up on #7127. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
insertIntoLoadTable built the column list with DoubleQuoteAndJoinByComma, which uses Go's %q and escapes a double quote as \" instead of doubling it, so a column name containing a quote could break out of the identifier. Quote each column with pq.QuoteIdentifier instead. Raised as a follow-up on #7127. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
insertIntoLoadTable built the column list with DoubleQuoteAndJoinByComma, which uses Go's %q and escapes a double quote as \" instead of doubling it, so a column name containing a quote could break out of the identifier. Quote each column with pq.QuoteIdentifier instead. Raised as a follow-up on #7127. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
insertIntoLoadTable built the column list with DoubleQuoteAndJoinByComma, which uses Go's %q and escapes a double quote as \" instead of doubling it, so a column name containing a quote could break out of the identifier. Quote each column with pq.QuoteIdentifier instead. Raised as a follow-up on #7127. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
…ence check (#7405) # Description Stacked on #7406, which adds the shared helpers; this PR targets that branch and will retarget to `master` once it merges. Most Postgres identifiers in generated DDL and load SQL are already quoted with `DoubleQuoteIdentifier`. Two gaps remained: 1. `schemaExists` interpolated the namespace into a `'…'` string literal: ```sql SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname = '<namespace>'); ``` This PR passes the namespace as a bind parameter (`$1`) instead, so a namespace containing `'` can no longer break out of the literal. 2. `insertIntoLoadTable` built the column list with `warehouseutils.DoubleQuoteAndJoinByComma`, which uses Go's `%q`. Go escapes a double quote as `\"`, which Postgres does not honour inside a quoted identifier, so a column name containing `"` could break out. Each column is now quoted with `DoubleQuoteIdentifier` (follow-up raised on #7127). ## Tests - Integration test `TestIntegration` → `Load Table` → "prevents SQL injection via malicious identifiers" (replaces "quotes identifiers in create table" and the sqlmock-based create-table quoting test): creates a namespace containing `'` and `"` breakout payloads and runs `CreateSchema` twice (the second call must find the existing schema, which fails if the namespace is interpolated into a string literal), then creates a table and columns whose names contain `"` breakout payloads (plus a trailing-backslash column) alongside a control table. It then verifies the control table survives, `AddColumns` works on the malicious table, the names round-trip verbatim through `FetchSchema`, and `DropTable` drops only the targeted table. ## Linear Ticket Resolves INT-6791 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
Description
Fixes a Postgres warehouse SQL injection path by quoting attacker-controlled identifiers in Postgres DDL and correcting the Postgres Blendo casing sanitizer to truncate the sanitized key instead of the raw input.
Added regressions for malicious column names in transformer output and Postgres
ColumnsWithDataTypes/CreateTableSQL generation.Linear Ticket
INT-6631
Security
Validation
go test ./processor/internal/transformer/destination_transformer/embedded/warehouse -run 'Test.*(Safe|Transform|Blendo|Column)'- passgo test ./warehouse/integrations/postgres -run 'Test.*ColumnsWithDataTypes|Test.*CreateTable|Test.*Identifier'- passgo test ./processor/internal/transformer/destination_transformer/embedded/warehouse ./warehouse/integrations/postgres- passrudder-serversource is sha-pinned and not source-verifiable in the local mini stack; no services were started.