Skip to content

fix(warehouse): keep snowflake copy credentials out of logs - #7442

Merged
shekhar-rudder merged 4 commits into
masterfrom
fix/snowflake-idr-copy-log-mask
Oct 5, 2026
Merged

shekhar-rudder merged 4 commits into
masterfrom
fix/snowflake-idr-copy-log-mask

Conversation

@shekhar-rudder

@shekhar-rudder shekhar-rudder commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Description

When a Snowflake destination loads from S3 with temporary AWS credentials (RudderStack-managed object storage, or AWS without a storage integration), the COPY statement carries them in a CREDENTIALS = (AWS_KEY_ID='…' AWS_SECRET_KEY='…' AWS_TOKEN='…') clause.

The identity-mappings load logged that statement verbatim twice, which printed the credentials in plaintext:

  • Copying identity mappings for table (info)
  • Error running COPY for table (error, on failure)

The rest of the integration masked the credentials, but only because each call site remembered to do it. The identity merge-rules log ran its own regex, and this path didn't.

Approach

This PR removes the "remember to mask" requirement instead of adding one more masked call site. Every COPY statement is built from a function that formats it around a given auth clause:

copyStmt, err := sf.newCopyStatement(func(authClause string) string {
	return fmt.Sprintf(`COPY INTO %s FROM %s %s PATTERN = ...`, table, location, authClause)
})

sf.newCopyStatement calls the function twice and keeps both results:

type copyStatement struct {
	loggableSQL string // formatted with the credentials masked
	secretSQL   string // formatted with the real auth clause; never log
}
  • Logging can't leak. String() returns loggableSQL, so %v, %s, %+v and %#v (via GoString) print CREDENTIALS = (AWS_KEY_ID='***' AWS_SECRET_KEY='***' AWS_TOKEN='***'). secretSQL is only passed to the database by execContext/queryContext.
  • One builder. sf.newCopyStatement is the only place the auth clause is built. It replaces authString(), so the credentials never exist as a plain string that could be pasted into SQL.
  • The clause is an ordinary formatting argument, so no other value in the statement (namespace, location) can change where the credentials land.
  • Storage integrations are unaffected. Their name isn't secret, so it's used in both forms and the logs show it as before.
  • Middleware unchanged. It still masks with copyCredentialsRegex, because it sees secretSQL. That regex is now one shared map instead of two inline copies, and a test checks that its output matches the logged form.

All four COPY paths use the new builder: load table, identity merge rules, identity mappings, and TestLoadTable. The type lives in copy_statement.go.

Why not the Redshift pattern (regex-mask at each log call)? That is what this PR first did. It still depends on every future log site masking, and a '[^']*' pattern stops at the first quote inside a value. Here the logged form is built with masked values from the start.

Follow-up (not in this PR): Redshift, Deltalake and ClickHouse build credential-bearing SQL the same way and could move to this pattern.

Linear Ticket

N/A

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

🤖 Generated with Claude Code

shekhar-rudder and others added 2 commits September 30, 2026 14:51
The identity mappings COPY statement was logged verbatim at info level,
and again on failure, including the AWS temporary credentials carried by
its CREDENTIALS clause. The identity merge rules COPY and the SQL
middleware already masked them; this path did not.

Share one copyCredentialsRegex between the middleware and every direct
COPY log, and build the clause through awsCredentialsClause so the test
masks the real format.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ntil it runs

Masking at each log call only works while every caller remembers to do it.
Build every COPY statement as a copyStatement instead: its SQL carries a
placeholder for the auth clause, which is only put in place when the
statement is handed to the database. Logging the statement, through String
or any fmt verb, prints the placeholder, so no log call site can leak the
credentials by forgetting to mask.

newCopyStatement is the only place the auth clause is built, and it rejects
a template whose placeholder does not appear exactly once. The middleware
keeps masking with copyCredentialsRegex, since it sees the final statement.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@shekhar-rudder shekhar-rudder changed the title fix(warehouse): mask credentials in snowflake identity mappings copy log fix(warehouse): keep snowflake copy credentials out of logs Sep 30, 2026
shekhar-rudder and others added 2 commits September 30, 2026 15:38
Pure move: copyStatement, its constructors and the credentials clause and
regex it relies on now live in copy_statement.go, next to their test. No code
changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Replace the placeholder template with a function that formats the COPY
statement around a given auth clause. newCopyStatement calls it twice: once
with the real clause, which only goes to the database, and once with the
credentials masked, which is what the statement logs as.

The auth clause is now an ordinary formatting argument, so the placeholder,
its substitution and the check that guarded against a value carrying a copy
of it all go away. A storage integration name is not a secret, so logs show
it again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.97%. Comparing base (93cd81d) to head (cb26509).

Files with missing lines Patch % Lines
warehouse/integrations/snowflake/snowflake.go 88.88% 5 Missing ⚠️
warehouse/integrations/snowflake/copy_statement.go 80.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7442      +/-   ##
==========================================
+ Coverage   84.49%   84.97%   +0.48%     
==========================================
  Files         622      623       +1     
  Lines       62060    62056       -4     
==========================================
+ Hits        52435    52734     +299     
+ Misses       9622     9319     -303     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shekhar-rudder
shekhar-rudder merged commit f91747b into master Oct 5, 2026
163 of 171 checks passed
@shekhar-rudder
shekhar-rudder deleted the fix/snowflake-idr-copy-log-mask branch October 5, 2026 09:54
This was referenced Oct 12, 2026
mihir20 pushed a commit that referenced this pull request Oct 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.90.0-rc.1](v1.89.0...v1.90.0-rc.1)
(2026-10-12)


### Features

* **processor:** add source_out reporting metric
([#7435](#7435))
([909fba9](909fba9))
* **processor:** allow disabling event schemas v2 per source
([#7429](#7429))
([a8c12b2](a8c12b2))
* **processor:** report dest_transformer diff rows for multiplexing
destination transformations
([#7446](#7446))
([cd95c32](cd95c32))
* **processor:** report dest_transformer succeeded for destinations
without a destination transformation
([#7445](#7445))
([21f7e41](21f7e41))
* **processor:** report user_transformer succeeded for destinations
without a user transformation
([#7440](#7440))
([f424257](f424257))
* **router:** mask live events destination credentials
([#7460](#7460))
([5fa5fe2](5fa5fe2))
* **warehouse:** add Microsoft Fabric destination
([#7441](#7441))
([74940c2](74940c2))


### Bug Fixes

* **batchrouter:** do not abort warehouse jobs on a zero failure
timestamp
([#7426](#7426))
([506f6d5](506f6d5))
* **batchrouter:** recover snowpipe streaming channels for tables
dropped externally
([#7434](#7434))
([93cd81d](93cd81d))
* **destination:** encode Lytics bulk upload URL values
([#7433](#7433))
([08e6937](08e6937))
* **destination:** retry bqstream transport failures
([#7464](#7464))
([cd3dc3e](cd3dc3e))
* **warehouse:** cap deltalake validation schema describes
([#7444](#7444))
([d119779](d119779))
* **warehouse:** keep snowflake copy credentials out of logs
([#7442](#7442))
([f91747b](f91747b))
* **warehouse:** set explicit lineSep for deltalake csv copy
([#7455](#7455))
([cc22d18](cc22d18))


### Miscellaneous

* migrate self-hosted arm64 docker build runners to gha-runner-scale-set
([#7425](#7425))
([5cdffde](5cdffde))
* **processor:** retire the destination-filter reorder, dedup and
gw_ingested reporting flags
([#7450](#7450))
([1040511](1040511))
* pull openapi-generator through the ECR pull-through cache
([#7449](#7449))
([6e9f920](6e9f920))

---
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>
mihir20 pushed a commit that referenced this pull request Oct 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.90.0](v1.89.0...v1.90.0)
(2026-10-12)


### Features

* **processor:** add source_out reporting metric
([#7435](#7435))
([909fba9](909fba9))
* **processor:** allow disabling event schemas v2 per source
([#7429](#7429))
([a8c12b2](a8c12b2))
* **processor:** report dest_transformer diff rows for multiplexing
destination transformations
([#7446](#7446))
([cd95c32](cd95c32))
* **processor:** report dest_transformer succeeded for destinations
without a destination transformation
([#7445](#7445))
([21f7e41](21f7e41))
* **processor:** report user_transformer succeeded for destinations
without a user transformation
([#7440](#7440))
([f424257](f424257))
* **router:** mask live events destination credentials
([#7460](#7460))
([5fa5fe2](5fa5fe2))
* **warehouse:** add Microsoft Fabric destination
([#7441](#7441))
([74940c2](74940c2))


### Bug Fixes

* **batchrouter:** do not abort warehouse jobs on a zero failure
timestamp
([#7426](#7426))
([506f6d5](506f6d5))
* **batchrouter:** recover snowpipe streaming channels for tables
dropped externally
([#7434](#7434))
([93cd81d](93cd81d))
* **destination:** encode Lytics bulk upload URL values
([#7433](#7433))
([08e6937](08e6937))
* **destination:** retry bqstream transport failures
([#7464](#7464))
([cd3dc3e](cd3dc3e))
* **warehouse:** cap deltalake validation schema describes
([#7444](#7444))
([d119779](d119779))
* **warehouse:** keep snowflake copy credentials out of logs
([#7442](#7442))
([f91747b](f91747b))
* **warehouse:** set explicit lineSep for deltalake csv copy
([#7455](#7455))
([cc22d18](cc22d18))


### Miscellaneous

* migrate self-hosted arm64 docker build runners to gha-runner-scale-set
([#7425](#7425))
([5cdffde](5cdffde))
* **processor:** retire the destination-filter reorder, dedup and
gw_ingested reporting flags
([#7450](#7450))
([1040511](1040511))
* pull openapi-generator through the ECR pull-through cache
([#7449](#7449))
([6e9f920](6e9f920))

---
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>
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.

3 participants