fix: handle hex.DecodeString error in FormatOID() instead of silently discarding#720
Open
srpatcha wants to merge 2 commits intozigbee-alliance:masterfrom
Open
fix: handle hex.DecodeString error in FormatOID() instead of silently discarding#720srpatcha wants to merge 2 commits intozigbee-alliance:masterfrom
srpatcha wants to merge 2 commits intozigbee-alliance:masterfrom
Conversation
Malformed hex strings in certificate subject fields silently produced corrupt decoded output. In a compliance ledger this is a security concern. Now skips malformed entries instead.
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.
Fix silently ignored hex decode error in certificate subject parsing
Problem
FormatOID()inx/pki/x509/x509.gosilently discards the error fromhex.DecodeString(). When a malformed hex string is encountered in a certificate subject field, the function produces corrupt output instead of signaling an error. In a compliance ledger, this is a security concern as it can mask certificate tampering or corruption.Root Cause
Line 156:
decoded, _ := hex.DecodeString(value)uses the blank identifier to discard the error. Ifvaluecontains non-hex characters,decodedwill be an incomplete or empty byte slice, and the resulting subject field will contain corrupt data that is silently accepted into the ledger.Fix
Changed to
decoded, err := hex.DecodeString(value)with anif err != nil { continue }guard. Malformed entries are now skipped rather than producing corrupt output, preserving the original subject value.Testing
Impact
Affects all users of the distributed compliance ledger's PKI module. Malformed certificates could have corrupt subject fields stored without any error indication.