-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat(fips): Use nop keystore implementation #279
Conversation
Keystore.Factory and other constuctor functions will return a NopKeystore if the requirefips build tag is set. The NopKeystore will will return ErrNotWritable for any retrievals, and ErrKeystoreUnsupported for create/save/store operations. The NopKeystore uses the same existing constructor name as the regular file keystore so it can be used in-place by callers.
@@ -37,8 +39,24 @@ var ( | |||
|
|||
// ErrNotWritable is returned when the keystore is not writable | |||
ErrNotListing = errors.New("the configured keystore is not listing") | |||
|
|||
// ErrKeystoreDisabled is returned on create, save, and store operations if built with the requirefips flag | |||
ErrKeystoreDisabled = fmt.Errorf("keystore disabled in FIPS mode: %w", errors.ErrUnsupported) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use ErrNotWritable
in place of this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentatively approved. Please wait for at least one more review before merging.
Tests will only succeed once #281 is merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michel-laterman please tell me if I am missing something, but as far as I can tell, the current keystore implementation should be FIPS compliant:
- pbkdf2 with SHA512 is approved
- AES with GCM is approved
I can see all the crypto related calls that we use in the code here.
With all that said, is the keystore implementation not FIPS compliant? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michel-laterman can this unit-test failure happen because FIPS enabled code is not decrypting correctly the blocks of both PKCS1 and PKCS8 keys? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love this change to be as simple as returning always an error from NewFileKeystoreWithPasswordAndStrictPerms when it is compiled for FIPS. However I understand that due to external dependencies that do not handle appropriately an error there an alternative approach, such as the one of this PR is needed. Thus LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michel-laterman instead of implementing a noop keystore, have you thought of removing the command from the fips compliant binaries?
Something similar to what was done for the APM Server elastic/apm-server#15545?
💚 Build Succeeded
History
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add a noop keystore. The implementation itself is ok, the issue is that we're passing an empty password.
Downstream clients should not create a keystore with an empty password in fips mode (e.g. by disabling the keystore)
EDIT: sorry, I missed @simitt comment above, fully agree with what was said about leaving the keystore impl (it would return an error anyway with an empty password in fips mode).
I have an alternate approach (as @kruskall suggested) that needs reviews: elastic/beats#42846 |
What does this PR do?
Keystore.Factory and other constuctor functions will return a NopKeystore if the requirefips build tag is set. The NopKeystore will will return ErrKeyDoesntExists for any retrievals, and ErrKeystoreUnsupported for create/save/store operations. The NopKeystore uses the same existing constructor name as the regular file keystore so it can be used in-place by callers.
Minor refactoring to move unchanged constructors, and the
Factory
method tokeystore.go
, renamedfile_keystore.go
tofile_keystore_nofips.go
to give an addition indicator to developers.Why is it important?
Current keystore implementation is not FIPS compliant.
Checklist
I have added tests that prove my fix is effective or that my feature works