Use non-crypto rand for audit IDs to avoid FIPS overhead#2704
Conversation
…erhead In FIPS mode, uuid.New() calls crypto/rand.Read() which goes through the FIPS-validated OpenSSL DRBG and getrandom() syscall on every API request. Audit IDs are correlation tokens with no security properties, so this cryptographic strength is unnecessary and expensive. Replace with uuid.NewRandomFromReader() backed by math/rand/v2, which uses a lock-free ChaCha8 source. This preserves the UUID v4 format for backward compatibility while eliminating the FIPS crypto overhead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Skipping CI for Draft Pull Request. |
|
@sdodson: the contents of this pull request could not be automatically validated. The following commits could not be validated and must be approved by a top-level approver:
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sdodson The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Exercises the real WithAuditInit UUID generation path (no Audit-ID request header) and asserts the result parses as a valid UUID v4 with RFC 4122 variant. This catches format regressions when changing the random source backing audit ID generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@sdodson: the contents of this pull request could not be automatically validated. The following commits could not be validated and must be approved by a top-level approver:
Comment |
Summary
uuid.New()callscrypto/rand.Read()which routes through the FIPS-validated OpenSSL DRBG andgetrandom()syscall on every API request. Audit IDs are correlation tokens with no security properties, so this cryptographic strength is unnecessary and expensive.uuid.NewRandomFromReader()backed bymath/rand/v2, which uses a lock-free ChaCha8 source. This preserves the UUID v4 format for backward compatibility while eliminating the FIPS crypto overhead.I've since found out that this approach is proposed upstream in google/uuid#206 and in addition to not being subject to FIPS mode implementation from golang-fips/go it's 10x faster in general than even the non FIPS implementation. The author there notes that their path is actually cryptographically secure, but I'm still not sure we require that in the first place.
Additional detail, this should be safe in Go 1.22 and later which adds math/rand/v2.
Test plan
TestWithAuditIDtests passstaging/src/k8s.io/apiserver/pkg/endpoints/filters/test suite passesgetrandom()syscall frequency under FIPS mode withstrace🤖 Generated with Claude Code