Skip to content

Remove openssl.SetFIPS(true) call#1513

Merged
qmuntal merged 10 commits intomicrosoft/mainfrom
dev/qmuntal/nosetfipss
Jan 28, 2025
Merged

Remove openssl.SetFIPS(true) call#1513
qmuntal merged 10 commits intomicrosoft/mainfrom
dev/qmuntal/nosetfipss

Conversation

@qmuntal
Copy link
Member

@qmuntal qmuntal commented Jan 24, 2025

As agreed in https://github.com/microsoft/go-lab/blob/main/docs/adr/0012-remove-gofips.md, we shouldn't try to modify the OpenSSL FIPS mode.

This PR removes the openssl.SetFIPS(true) call and update our build scripts to enable FIPS mode system-wide.

Our CI Mariner 2 image is not FIPS-enabled by default, so we need to force FIPS mode by setting OPENSSL_FORCE_FIPS_MODE. That flag should be passes to the TestScript child processes as they only inherit a filtered set of environment variables, which includes GODEBUG.

Note that since we switched from GOFIPS to GODEBUG=fips140, our test FIPS test coverage has increased, as GOFIPS was not being passed to TestScript child processes, making them not aware of the required FIPS mode.

Also, this is unlikely that users need to update their code to also pass OPENSSL_FORCE_FIPS_MODE to child processes that don't inherit all environment variables. Mainly because they should be running a FIPS-enabled Mariner image on production. If they don't, possible for testing purposes, then child processes won't inherit the GODEBUG env var neither.

For #1445.

@qmuntal
Copy link
Member Author

qmuntal commented Jan 24, 2025

Looks like Mariner 2 hasn't ported forward-ported the code to enable FIPS mode from the config file. OpenSSL only officially supports FIPS mode in v1.0.2, so the relevant code was removed in OpenSSL 1.1. Will have to find another way.

@qmuntal qmuntal closed this Jan 24, 2025
@qmuntal qmuntal reopened this Jan 24, 2025
@qmuntal qmuntal marked this pull request as ready for review January 24, 2025 19:33
@qmuntal qmuntal requested a review from a team as a code owner January 24, 2025 19:33
@qmuntal qmuntal requested a review from a user January 24, 2025 19:33
@qmuntal qmuntal requested review from dagood, gdams and mertakman January 24, 2025 19:34
@dagood
Copy link
Member

dagood commented Jan 24, 2025

Also, this is unlikely that users need to update their code to also pass OPENSSL_FORCE_FIPS_MODE to child processes that don't inherit all environment variables. Mainly because they should be running a FIPS-enabled Mariner image on production. If they don't, possible for testing purposes, then child processes won't inherit the GODEBUG env var neither.

To make sure I have this right: for a user to run a test with forced FIPS mode, this will work:

GODEBUG=fips140=on OPENSSL_FORCE_FIPS_MODE=1 go test .

For the user to have an issue with passthrough, they'd have to be using yet another custom test runner that passes through GODEBUG but not OPENSSL_FORCE_FIPS_MODE.

@qmuntal qmuntal requested a review from dagood January 28, 2025 08:32
@qmuntal
Copy link
Member Author

qmuntal commented Jan 28, 2025

Also, this is unlikely that users need to update their code to also pass OPENSSL_FORCE_FIPS_MODE to child processes that don't inherit all environment variables. Mainly because they should be running a FIPS-enabled Mariner image on production. If they don't, possible for testing purposes, then child processes won't inherit the GODEBUG env var neither.

To make sure I have this right: for a user to run a test with forced FIPS mode, this will work:

GODEBUG=fips140=on OPENSSL_FORCE_FIPS_MODE=1 go test .

For the user to have an issue with passthrough, they'd have to be using yet another custom test runner that passes through GODEBUG but not OPENSSL_FORCE_FIPS_MODE.

Yep, that's accurate.

@qmuntal qmuntal merged commit cefe8e6 into microsoft/main Jan 28, 2025
35 checks passed
@qmuntal qmuntal deleted the dev/qmuntal/nosetfipss branch January 28, 2025 09:40
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.

3 participants