Skip to content

Redact git config values that can carry credentials - #1014

Open
neoLsH wants to merge 1 commit into
kubernetes:masterfrom
neoLsH:redact-git-config-secrets
Open

neoLsH wants to merge 1 commit into
kubernetes:masterfrom
neoLsH:redact-git-config-secrets

Conversation

@neoLsH

@neoLsH neoLsH commented Nov 17, 2026

Copy link
Copy Markdown

--git-config, --git-config-add and the git config dump printed at startup all echo http.extraHeader values verbatim, and that header is the documented way to pass a token. So any of those log lines leaks it.

This redacts, in all three places:

  • http.extraHeader and http.<url>.extraHeader values
  • passwords embedded in url.<base>.insteadOf / .pushInsteadOf keys and values

The --git-config flags are re-rendered from the parsed key/value pairs before logging. If a value can't be parsed, it is redacted wholesale, since we can't tell which part is sensitive. SetupExtraGitConfigs also redacts the config it logs when applying fails.

End-to-end check with a throwaway repo: the startup line shows --git-config=http.extraHeader:REDACTED, the config dump shows "http.extraheader":"REDACTED", and grepping the log for the token comes back empty. The command trace at -v=5 still prints the command as it runs, that part is unchanged.

Tests cover key/value redaction, the parsed dump, and logSafeFlags for both flags.

Fixes #1013

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Nov 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: neoLsH
Once this PR has been reviewed and has the lgtm label, please assign sdowell for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @neoLsH!

It looks like this is your first PR to kubernetes/git-sync 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/git-sync has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 17, 2026
--git-config, --git-config-add and the startup 'git config' dump print
http.extraHeader values verbatim, and that header is the documented way
to pass a token. Redact extraHeader values and password-bearing URLs in
url.<base>.insteadOf keys in all three places, including the error path
when a config fails to apply.
@neoLsH
neoLsH force-pushed the redact-git-config-secrets branch from 4165c05 to d8afbd1 Compare November 17, 2026 09:31
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--git-config values (e.g. http.extraHeader auth tokens) are logged in cleartext at startup

1 participant