Skip to content

x-pack/libbeat/common/cloudfoundry: Use xxhash instead of SHA1 in FIPS mode #43964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shmsr
Copy link
Member

@shmsr shmsr commented Apr 16, 2025

Proposed commit message

Drop usage of SHA1 and replace with a better algorithm when running in FIPS mode (-requirefips).

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 16, 2025
@shmsr shmsr self-assigned this Apr 16, 2025
@botelastic
Copy link

botelastic bot commented Apr 16, 2025

This pull request doesn't have a Team:<team> label.

Copy link
Contributor

mergify bot commented Apr 16, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @shmsr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

package cloudfoundry

import (
"crypto/sha256"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we need a cryptographic function ? If not, I'd suggest we use a non-cryptographic func (e.g. xxhash) to make this more future-proof.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense. I'll do this.

// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build !requirefips
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Can we update the cache key for everyone ? Would this be considered a breaking change ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also not sure about this. Since sha1.Sum is deterministic, it will always produce the same hash for a fixed input (in this case, the APIAddress). This deterministic behavior means the system might create or reuse a (persistent) cache based on this hash value.

For users who already have that persistent cache in place, changing this logic could potentially be a breaking change. Although it's just a cache implementation detail, I haven't deeply investigated this issue since I haven't worked with cloudfoundry before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to better understand the implications of changing the cache key so we could assess whether it makes sense to use a single implementation to FIPS and non-FIPS.

@shmsr shmsr marked this pull request as ready for review April 17, 2025 07:15
@shmsr shmsr requested a review from a team as a code owner April 17, 2025 07:15
@shmsr shmsr requested review from belimawr and faec April 17, 2025 07:15
@shmsr shmsr changed the title x-pack/libbeat/common/cloudfoundry: Use SHA224 instead of SHA1 in FIPS mode x-pack/libbeat/common/cloudfoundry: Use xxhash instead of SHA1 in FIPS mode Apr 17, 2025
Copy link
Contributor

@belimawr belimawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it ends up being just a variation of the same question asked by @kruskall: what happens if someone upgrades Beats to the FIPS version? Is this upgrade even supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants