Skip to content

Strip custom credential headers on cross-host redirects - #1763

Open
winstoncrooker wants to merge 1 commit into
databricks:mainfrom
winstoncrooker:strip-cloud-tokens-cross-host-redirect
Open

Strip custom credential headers on cross-host redirects#1763
winstoncrooker wants to merge 1 commit into
databricks:mainfrom
winstoncrooker:strip-cloud-tokens-cross-host-redirect

Conversation

@winstoncrooker

Copy link
Copy Markdown

Summary

When Azure service-principal or GCP service-account auth is configured, the SDK attaches the cloud-provider token to every request as a custom header (X-Databricks-Azure-SP-Management-Token, the Azure ARM management bearer; X-Databricks-GCP-SA-Access-Token, the GCP service-account token). These headers are already treated as secrets by the SDK's own log redaction.

The main HTTP client in httpclient/api_client.go follows redirects with no CheckRedirect. Go's net/http strips only the standard sensitive headers (Authorization, Cookie, WWW-Authenticate) when a redirect changes host; it does not strip these custom headers. So on a cross-host redirect the cloud tokens are forwarded to the redirect target host, even though Authorization would be stripped.

The SDK already avoids this on the Azure tenant-fetch client (config/config.go sets a CheckRedirect); this change brings the main request client in line.

Change

Add a CheckRedirect to the main client that drops the custom credential headers when a redirect changes host, preserves the default 10-redirect limit, and leaves same-host redirects untouched.

Testing

make fmt test lint. Verified at runtime that with the change the tokens are stripped on a cross-host redirect (matching Authorization) and same-host redirects are unaffected.

The main HTTP client follows redirects but net/http only strips the standard
sensitive headers (Authorization, Cookie) when a redirect changes host. The
custom cloud-provider token headers (X-Databricks-Azure-SP-Management-Token,
X-Databricks-GCP-SA-Access-Token) were therefore forwarded to a different host
on a cross-host redirect.

Add a CheckRedirect to the main client that drops these headers when a redirect
changes host, matching how net/http handles Authorization and how the Azure
tenant-fetch client already avoids following redirects.

Signed-off-by: winstoncrooker <winstoncrooker@outlook.com>
@github-actions

Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-go

Inputs:

  • PR number: 1763
  • Commit SHA: ae0c4c45c0dc4f92eca189bdbd0999863b1800c1

Checks will be approved automatically on success.

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