Skip to content

#2102 Redact proxy credentials from worker logs - #2151

Merged
rzo1 merged 3 commits into
apache:mainfrom
Riddhish1:fix/proxy-credential-redaction
Sep 15, 2026
Merged

rzo1 merged 3 commits into
apache:mainfrom
Riddhish1:fix/proxy-credential-redaction

Conversation

@Riddhish1

Copy link
Copy Markdown
Contributor

Redact proxy credentials from worker logs

The problem

SCProxy.toString() included the proxy username and password when credentials were configured:

http://user:password@proxy.example.com:8080

HttpProtocol passed this value to LOG.debug() for every proxied fetch. When DEBUG logging was enabled, proxy credentials were therefore written to worker logs and could be shipped to central log aggregation.

These credentials may belong to paid third-party proxy services and should not be exposed to everyone with access to worker logs.

What this PR changes

Redact credentials in SCProxy.toString()

Authenticated proxies are now rendered as:

http://user:***@proxy.example.com:8080

Unauthenticated proxies continue to render normally:

http://proxy.example.com:8080

Proxy credentials remain available through getUsername() and getPassword() for the actual authentication flow. Equality and hashing are also unchanged because they operate directly on the proxy fields.

Remove proxy stringification from OkHttp logging

The OkHttp protocol now logs only the proxy endpoint:

fetching with proxy <url> - proxy.example.com:8080

This prevents the logging path from depending on the proxy's rendered representation.

Compatibility impact

The rendered value of SCProxy.toString() is no longer a credential-bearing connection string. This is intentional because toString() may be used implicitly by logging and diagnostics.

No production code in this repository requires the full connection string from toString(). Proxy construction and authentication continue to use the individual proxy getters.

Tests

Updated the existing proxy tests to verify the redacted representation for authenticated proxies while preserving the existing endpoint format for unauthenticated proxies.

The tests also continue to verify that:

  • Proxy usernames and passwords are parsed correctly.
  • Proxy authentication fields remain available through their getters.
  • Proxy equality and hash codes still include credentials.
  • Single-proxy manager configuration continues to work.
  • Metadata proxy overrides continue to work.
  • Multi-proxy rotation and lookup behavior are unchanged.
  • OkHttp proxy handling remains thread-safe.

Verification

mvn -pl core test \
  -Dtest=SCProxyTest,SingleProxyManagerTest,MultiProxyManagerTest,HttpProtocolProxyConcurrencyTest

Result:

Tests run: 42, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Also verified:

git diff --check

@rzo1 rzo1 added this to the 4.0.0 milestone Sep 13, 2026

@dpol1 dpol1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The String constructor still includes the rejected connection string in its exception; could we omit it there too, since it may contain credentials?

Findings flagged by Claude

@Riddhish1

Copy link
Copy Markdown
Contributor Author

LGTM. The String constructor still includes the rejected connection string in its exception; could we omit it there too, since it may contain credentials?

Findings flagged by Claude

Addressed

@rzo1
rzo1 merged commit 55efcf2 into apache:main Sep 15, 2026
2 checks passed
@rzo1

rzo1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

thx @Riddhish1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants