security: CWE-532: Redact secrets from debug output — VC-53781#400
Open
torresashjiancyber wants to merge 1 commit into
Open
security: CWE-532: Redact secrets from debug output — VC-53781#400torresashjiancyber wants to merge 1 commit into
torresashjiancyber wants to merge 1 commit into
Conversation
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
Fixes CWE-532 (Insertion of Sensitive Information into Log File) by applying the same redaction logic used in the verbose stream to the debug stream. When
$DebugPreference='Continue'is active, sensitive credentials and keys are now masked with***hidden***instead of being written in cleartext.Finding
CWE: CWE-532 (Insertion of Sensitive Information into Log File)
Severity: High
CVSS: 5.6 (CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N)
The central HTTP transport function serialized full request and response objects to
Write-Debugwithout applying theWrite-VerboseWithSecretredaction that the adjacent verbose path uses. This exposed:Authorizationheader)tppl-api-keyheader)body.password)refresh_token)CertificateDatacontaining base64 PKCS#12 with private keys)When debug output is enabled (common in troubleshooting and CI pipelines), these secrets are captured by PowerShell transcripts, CI log collectors, and stream redirection, allowing any local reader of the logs to obtain reusable credentials and key material.
Affected locations:
Invoke-TrustRestMethod.ps1:210,214— Request dump without redactionInvoke-TrustRestMethod.ps1:253— Response dump without redactionImport-TrustCertificate.ps1:248,342— Certificate data dump including private keysRemediation
Applied MINIMAL, FOCUSED fix:
Created
Write-DebugWithSecrethelper (VenafiPS/Private/Write-DebugWithSecret.ps1)Write-VerboseWithSecretredaction helperWrite-Debuginstead ofWrite-Verbose), preference gate ($DebugPreferenceinstead of$VerbosePreference)Authorization,tppl-api-key,Password,password,refresh_token,access_token,CertificateData,dekEncryptedPassword,PrivateKeyData, etc.***hidden***Updated
Invoke-TrustRestMethod.ps1Write-Debug -Message ($params | ConvertTo-Json -Depth 10)with$params | Write-DebugWithSecret$response | ConvertTo-Json -Depth 10 | Write-Debugwith$response | Write-DebugWithSecretUpdated
Import-TrustCertificate.ps1Write-Debug ($allCerts | ConvertTo-Json)with count-only messagesCertData,KeyData) are not in the shared deny-list; count-only message preserves diagnostic value without exposing key materialBehavior:
$DebugPreference -ne 'SilentlyContinue'Verification
Post-fix trace:
{"Headers":{"Authorization":"***hidden***"},"Body":{"password":"***hidden***"}}{"access_token":"***hidden***","refresh_token":"***hidden***","CertificateData":"***hidden***"}Processing 5 certificate(s) with private keys(no key material serialized)Related: VC-53601, VC-53597