fix: sanitize error messages to prevent credential leakage#11178
Closed
WhiteElephantIsNotARobot wants to merge 1 commit into
Closed
fix: sanitize error messages to prevent credential leakage#11178WhiteElephantIsNotARobot wants to merge 1 commit into
WhiteElephantIsNotARobot wants to merge 1 commit into
Conversation
The GitHub Action was leaking sensitive environment variables and tokens into PR comments when shell errors occurred. This fix adds a sanitizeErrorMessage() function that: - Redacts base64-encoded tokens (Authorization headers, x-access-token) - Redacts GitHub tokens (ghp_, gho_, ghr_, ghs_ prefixes) - Redacts common API keys and secrets (GITHUB_TOKEN, AWS keys, etc.) - Redacts URLs with embedded credentials - Truncates long lines containing base64-like patterns This prevents exposure of credentials like GITHUB_TOKEN, ACTIONS_ID_TOKEN_REQUEST_TOKEN, and user-provided API keys when errors occur during shell command execution. Fixes #11166
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a security vulnerability where sensitive environment variables and tokens were being leaked into PR comments when shell errors occurred in the GitHub Action.
Security Impact
Severity: High
The GitHub Action was posting raw
stderroutput from shell commands to PR comments. This could expose:GITHUB_TOKENACTIONS_ID_TOKEN_REQUEST_TOKENACTIONS_ID_TOKEN_REQUEST_URLZHIPU_API_KEY)GITHUB_*context variablesFix
Added a
sanitizeErrorMessage()function that sanitizes error messages before posting them to PR comments:ghp_,gho_,ghr_,ghs_prefixeshttps://token@github.compatternsChanges
github/index.tsto callsanitizeErrorMessage()on shell error stderrsanitizeErrorMessage()function with comprehensive regex-based redactionTesting
The function handles:
Fixes #11166