Skip to content
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

FIPS Build #42402

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

FIPS Build #42402

wants to merge 3 commits into from

Conversation

michel-laterman
Copy link
Contributor

Proposed commit message

Enable FIPS compliant builds when the env var FIPS=true is set.

Artifacts are built with the microsfot/go toolchain with the env var GOEXPERIMENT=systemcrypto and the build tag "-tags=requirefips".
In order to run the resulting binary, the system must have a FIPS compliant crypto provider.

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.

Disruptive User Impact

None

How to test this PR locally

TODO

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 22, 2025
Copy link
Contributor

mergify bot commented Jan 22, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @michel-laterman? 🙏.
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

Copy link
Contributor

mergify bot commented Jan 22, 2025

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Jan 22, 2025
@michel-laterman
Copy link
Contributor Author

michel-laterman commented Jan 22, 2025

Currently FIPS binaries built with FIPS=true mage build do not behave as expected.

For reference, I can build elastic-agent binaries with the changes in elastic/elastic-agent#6565 in a VM using the microsoft/go toolchain, and when I try to run them with no provider it will immediatly panic with the error panic: opensslcrypto: can't enable FIPS mode for OpenSSL 3.0.13 30 Jan 2024: openssl: FIPS mode not supported by any provider

The beats I build with these changes do not panic (and I expect it to in this case).

EDIT: running the binary with the env var GOFIPS=1 yeilds the expected error

Comment on lines +54 to +58
// ParseExtraFlags returns the ExtraFlags param where all flags that are go build tags are joined by a comma.
//
// For example if given -someflag=val1 -tags=buildtag1 -tags=buildtag2
// It will return -someflag=val1 -tags=buildtag1,buildtag2
func (b BuildArgs) ParseExtraFlags() []string {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When building agentbeat without this parsing, it results in two -tags= values being sent to the go build command. one tag gets ignored; this resulted in the behaviour in my previous comment where I then had to adjust a runtime env var to get the binary in compliance.

Parsing the extra flags to join all -tags= flags is required in order to send -tags=agentbeat,requirefips which produced a binary that works as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

How does this interact with the build tags for testing? I'm thinking of "integration" as an example. I'm assuming we will need tests that require both a testing build tag and the fips build tag.

testArgs = append(testArgs, "-tags", params)

@michel-laterman michel-laterman added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jan 24, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 24, 2025
@michel-laterman michel-laterman marked this pull request as ready for review February 12, 2025 18:05
@michel-laterman michel-laterman requested a review from a team as a code owner February 12, 2025 18:05
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@cmacknz
Copy link
Member

cmacknz commented Feb 12, 2025

Similar to the agent PR, this needs to be built as part of CI and we need to have a test that confirms the binary is actually FIPS compliant and links in the FIPS OpenSSL in the expected way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants