Skip to content

Handle empty or malformed cacertificate attribute in CA objects#55

Open
0x4meliorate wants to merge 1 commit intocoffeegist:mainfrom
0x4meliorate:main
Open

Handle empty or malformed cacertificate attribute in CA objects#55
0x4meliorate wants to merge 1 commit intocoffeegist:mainfrom
0x4meliorate:main

Conversation

@0x4meliorate
Copy link
Copy Markdown

If a snapshot contains a CA object whose cacertificate attribute is empty or malformed, BOFHound will crash when it tries to parse it as a valid X.509 certificate. This edge case can occur when a CA is partially configured, decommissioned, or when the snapshot tool is unable to retrieve the full certificate blob and substitutes a placeholder value instead. The fix wraps the parsing attempt in a try/except block so that if parsing fails, BOFHound falls back to using the certificate's SHA1 thumbprint as the name instead and continues processing, rather than throwing an unhandled exception and dying.

If a snapshot contains a CA object whose cacertificate attribute is empty or malformed, BOFHound will crash when it tries to parse it as a valid X.509 certificate. This edge case can occur when a CA is partially configured, decommissioned, or when the snapshot tool is unable to retrieve the full certificate blob and substitutes a placeholder value instead. The fix wraps the parsing attempt in a try/except block so that if parsing fails, BOFHound falls back to using the certificate's SHA1 thumbprint as the name instead and continues processing, rather than throwing an unhandled exception and dying.
@laxa
Copy link
Copy Markdown

laxa commented Mar 10, 2026

Thank you for the patch, I had this crash in my context, but it also failed afterward in the code, at https://github.com/coffeegist/bofhound/blob/main/bofhound/ad/adds.py#L1353, it seems related to the underlying issue.
Would you mind fixing this issue as well? If not, I'll probably do a PR on my side when yours is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants