-
Notifications
You must be signed in to change notification settings - Fork 214
fix(e2e): prevent Kubernetes bearer token leak in error logs #4103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(e2e): prevent Kubernetes bearer token leak in error logs #4103
Conversation
Assisted-by: Cursor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Type(Describe updated until commit 8324024)Bug fix, Enhancement Description
|
| Relevant files | |||
|---|---|---|---|
| Bug fix |
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
|
The image is available at: |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: albarbaro The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
239294c
into
redhat-developer:main
|
@zdrapela: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/cherry-pick release 1.9 |
|
@zdrapela: cannot checkout DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherry-pick release-1.9 |
|
@zdrapela: new pull request created: #4105 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |



Summary
This PR fixes a security issue where the Kubernetes bearer token was being leaked in CI logs when Kubernetes API errors occurred during E2E tests.
Problem
When the
@kubernetes/client-nodelibrary throws anHttpError, the error object contains the full HTTP request/response, including theAuthorization: Bearer <token>header. Logging the full error object (e.g.,console.log(err)) exposed the token in CI logs.Example of leaked data:
Solution
Added a
getKubeApiErrorMessage()helper function that safely extracts only non-sensitive information from Kubernetes API errors:body.message,body.reason,body.code(standard K8s API error fields)Updated all error logging locations in
kube-client.tsto use this safe extraction method instead of logging the full error object.Changes
getKubeApiErrorMessage()utility function with proper TypeScript typingTesting
console.log/console.errorcalls inkube-client.ts"namespaces \"test-ns\" not found, reason: NotFound, code: 404")https://issues.redhat.com/browse/RHDHBUGS-2563