Skip to content

Redact credentials from server.log#17

Open
average-enjoyer wants to merge 1 commit into
GerritCodeReview:masterfrom
average-enjoyer:redact-credentials-in-log
Open

Redact credentials from server.log#17
average-enjoyer wants to merge 1 commit into
GerritCodeReview:masterfrom
average-enjoyer:redact-credentials-in-log

Conversation

@average-enjoyer

Copy link
Copy Markdown

Problem

run_curl() in main.py writes the full curl command line to server.log before executing it:

[gerrit-mcp-server] Executing: curl --user :<auth_token> -L https://...

For the http_basic auth method, this puts the raw HTTP Basic Auth token in plaintext in a log file on disk on every single request. The gitcookies auth method has the same problem — the session cookie passed via -b <cookie> ends up in the log the same way.

Fix

Mask the credential-bearing arguments before writing the log line. The actual curl invocation is unchanged — only what gets written to server.log is redacted. --user user:token becomes --user user:***REDACTED***, and -b <cookie> becomes
-b ***REDACTED***.

Testing

Ran the server locally with http_basic auth configured, made a real authenticated call against a Gerrit instance get_change_details), and confirmed: - the request still succeeds (auth unaffected) - server.log now shows --user <username>:***REDACTED*** instead of the plaintext token

@google-cla

google-cla Bot commented Jul 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@average-enjoyer
average-enjoyer force-pushed the redact-credentials-in-log branch from d510196 to efa8d43 Compare July 20, 2026 09:18
@average-enjoyer

Copy link
Copy Markdown
Author

@googlebot I signed it!

1 similar comment
@average-enjoyer

Copy link
Copy Markdown
Author

@googlebot I signed it!

run_curl() logged the full curl command line to server.log before
executing it, including the raw HTTP Basic Auth token from
--user <username>:<auth_token> for the http_basic auth method, and
the session cookie from -b <cookie> for the gitcookies auth method.
Both end up sitting in plaintext in a log file on disk.

Mask the credential-bearing arguments before writing the log line.
The actual curl invocation is unchanged; only what gets logged is
redacted.
@average-enjoyer
average-enjoyer force-pushed the redact-credentials-in-log branch from efa8d43 to ce36708 Compare July 20, 2026 09:32
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