Skip to content

fix(logging): drop presigned query from request errors and debug URLs - #454

Merged
vuanhphung merged 2 commits into
mainfrom
fix/redact-presigned-urls-in-logs
Nov 16, 2026
Merged

vuanhphung merged 2 commits into
mainfrom
fix/redact-presigned-urls-in-logs

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

CloudFetch presigned URLs carry their credential in the query string (Azure SAS sig=, S3 X-Amz-Signature). reqwest's error Display prints the request URL (error sending request for url (…)), and the HTTP client copies that text into its retry warning and the returned error. So a timed-out or reset CloudFetch download wrote a usable signed URL to a default-on warn line, and the Node.js and Python kernel bindings forward that line to the console. The per-request and chunk-download debug lines printed the full URL too.

This strips the query from the URL inside the reqwest error before it is formatted, keeping scheme, host and path so a blocked storage host is still visible. Each request's debug line logs the URL only up to ?, and the "Downloading chunk" debug line drops the URL (the request line already shows host and path).

Testing:

  • tests/presigned_url_logging.rs sends a CloudFetch request with ?sig=… to a closed port with one retry, capturing DEBUG logs. It fails if either half is reverted: without the error fix the returned error contains ?sig=SECRET, and without the debug change the request line does. It runs in its own binary because, in the unit-test binary, tests that open a session install a global tracing subscriber and a thread-local capture misses events.
  • cargo +stable fmt --all --check, cargo clippy --all-targets -- -D warnings and cargo test pass.
  • Live, on Node.js driver main f436057, SEA, against an Azure warehouse, running databricks-driver-test CLOUDFETCH-003 (stalled download) and CLOUDFETCH-004 (connection reset), serial, each failure injected before response headers:
Kernel napi binding Runs Tests Console lines with sig= / X-Amz-*
main ca0e096 1 2 passing 2: both Chunk 1 download failed (attempt 1/5): … error sending request for url (https://…blob.core.windows.net/…/results_…?sig=…)
this PR 3 2 passing each 0 in each run; the same two warnings end at …/results_<id>): operation timed out and …): client error (SendRequest)

Not in this PR:

  • Hardening that has no demonstrated exposure: redacting SEA response bodies quoted in parse-failure errors, the signature echo in an S3 SignatureDoesNotMatch body, URLs in a JSON error envelope's message, user:password@ in a proxy URL, and redacting Debug impls for CloudFetchLink/ExternalLink. The chunk_downloader.rs build and body-read errors carry no URL, so they need no change.
  • The same leak in other drivers: Go (internal/rows/arrowbased/batchloader.go:518-519 wraps a *url.Error with the signed URL), pure Python (common/unified_http_client.py:306,316, cloudfetch/downloader.py:166-171), and the legacy C# driver in apache/arrow-adbc (CloudFetchDownloader.cs:483).

This pull request and its description were written by Isaac.

@oss-reviewer-bot oss-reviewer-bot 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.

Verdict: 1 Low

Looks good: redaction is applied at the main places URLs get logged or put into errors, and the tests would fail if the redaction were removed. One low finding: a request-build error path in the HTTP client's retry loop still formats the raw reqwest error.

Comment thread src/client/http.rs Resolved

@oss-reviewer-bot oss-reviewer-bot 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.

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot 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.

Verdict: 1 Low

Looks good. The redaction is applied in the right places, and the tests are real regressions (each would fail without its redaction). One low issue: redact_url gets the host wrong when a URL with no path has an @ in its query. Nit, not in this diff: CloudFetchLink derives Debug (src/types/cloudfetch.rs:110), so any future {:?} of a link would print the presigned URL. A redacting Debug impl would close that gap.

Comment thread src/util/redact.rs Resolved
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Re the review-body nit on CloudFetchLink's derived Debug: done in 154c956, for ExternalLink as well, since StatementExecutionResponse and the result types derive Debug over it. Both now print the URL through redact_url and list only the header names, because CloudFetch header values can be SSE-C keys. No current code formats either type with {:?} (I checked every non-test {:?} site), so this guards future code. Test: test_link_debug_redacts_url_and_header_values, which fails with the URL printed raw.

@oss-reviewer-bot oss-reviewer-bot 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.

Verdict: 1 Low

Looks good: the redaction is solid and well tested. One low-severity gap: an unencoded / in a proxy password gets past userinfo redaction, which matters most on the invalid-proxy-URL error path.

Comment thread src/util/redact.rs Resolved

@oss-reviewer-bot oss-reviewer-bot 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.

Verdict: 1 Low

The redaction looks correct and well tested. I have one low-severity concern: the parsed-envelope message arm of http_error still skips redaction. I checked the other URL and error formatting sites (the retry loop, the chunk downloader, the SEA parse errors, the proxy config, and the Azure redirect probe, which isn't presigned), and none of them leak a credential.

Comment thread src/client/http.rs Resolved

@oss-reviewer-bot oss-reviewer-bot 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.

Verdict: 2 Low

The redaction approach is sound and well tested; I found 2 low-severity gaps in what redact_response_body catches. The request-URL, reqwest-error and Debug paths look complete, and every non-2xx body goes through http_error.

Comment thread src/util/redact.rs Resolved
Comment thread src/util/redact.rs Resolved
reqwest's error Display prints the request URL, so a timed-out or reset
CloudFetch download put the SAS/S3 signature into the retry warning and
the returned error. Strip the query from the URL inside the reqwest
error, log each request's URL only up to `?`, and drop the URL from the
chunk download debug line.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Rewritten to the minimal fix (3c23246, rebased on main ca0e096). The only change is on the request-error path: the query is stripped from the URL inside the reqwest error, the per-request debug URL stops at ?, and the chunk debug line no longer prints the URL. src/util/redact.rs, the response-body/S3/envelope redaction, the SEA parse-failure edits, the proxy userinfo redaction, the link Debug impls and the chunk_downloader.rs error rewrites are gone, so the earlier review threads refer to code that is no longer in the PR. The description lists what was dropped as not in this PR.

@oss-reviewer-bot oss-reviewer-bot 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.

✅ No issues identified by the review bot.

The log-capturing test failed about one in three full runs (and every run
of the client::http subset): tests in the unit-test binary that open a
session install a process-global tracing subscriber, and the test's
thread-local capture then missed the retry warning and request lines.
Move it to tests/presigned_url_logging.rs, where it is the only test and
installs the global subscriber itself, like tests/klog_bridge.rs.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@oss-reviewer-bot oss-reviewer-bot 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.

✅ No issues identified by the review bot.

This branch had an error being deployed

1 failed deployment
azure-prod — aa946092 Deployed Nov 16, 2026 by oss-reviewer-bot[bot] via followup #3372
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.

1 participant