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

Add support to define a callback for FIPS test failures before aborting the process #2162

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

Conversation

andrewhop
Copy link
Contributor

@andrewhop andrewhop commented Feb 4, 2025

Description of changes:

This change adds an optional callback that applications linking with AWS-LC can define to get alerted to FIPS failures during their use of AWS-LC. This does not change how AWS-LC shuts down in the event of a CAST/PCT failure. This callback only provides access to a better log message. Previously applications using AWS-LC could register a signal handler using sigaction, but there was no way to distinguish between a FIPS specific abort and a general error. The same is true for atexit hooks.

This PR also undoes the optional change in 5553a20 and instead defines a new AWS_LC_FIPS_Failure in non-FIPS builds which just logs the error to stderr.

Testing

This change adds a new gtest application that checks the callback function is called with the expected message and is used with break-kat.go and the runtime PCT environment variables to ensure the callback is passed the expected message.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 18 lines in your changes missing coverage. Please review.

Project coverage is 79.04%. Comparing base (5553a20) to head (2050f2c).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crypto/fipsmodule/self_check/self_check.c 70.58% 15 Missing ⚠️
crypto/fipsmodule/bcm.c 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2162   +/-   ##
=======================================
  Coverage   79.04%   79.04%           
=======================================
  Files         612      612           
  Lines      106065   106071    +6     
  Branches    14994    14995    +1     
=======================================
+ Hits        83837    83842    +5     
+ Misses      21576    21575    -1     
- Partials      652      654    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

void BORINGSSL_FIPS_abort(void) {
WEAK_SYMBOL_FUNC(void, AWS_LC_fips_failure_callback, (const char* message))
#include <unistd.h>
void AWS_LC_FIPS_failure(const char* message) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please correct me if I'm wrong, but this will break our next FIPS validation. If we allow someone outside the boundary to register a callback our lab will not be able to prove that we stop processing events when a PCT or self-tests fails. When we detect a failure we need to abort immediately as defined in ISO 19790 section 7.3.3, b), 7.3.3 c), and 7.5. This needs to be wrapped in a #ifdef so we don't expose it when we are building as a 140-3 level 1 module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no different than the current behavior: an application using AWS-LC can install a custom signal handler to perform any logging/cleanup before the abort terminates the process. However, with this callback the application gets a clearer signal if the abort is a FIPS anomaly or a different SIGABRT.

andrewhop added a commit that referenced this pull request Feb 10, 2025
…age (#2182)

### Description of changes: 
In preparation for the callback change in
#2162 this change updates all the
places that could abort to pass a message to a new abort function that
explains why it's about to abort.

### Testing:
The existing test-break-kat.go will ensure all the KATs still fail as
expected and the messages they print match.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
@andrewhop andrewhop force-pushed the fips_callback branch 2 times, most recently from 62d5a7b to 035dd7d Compare February 11, 2025 01:34
@andrewhop andrewhop marked this pull request as ready for review February 11, 2025 06:57
@andrewhop andrewhop requested a review from a team as a code owner February 11, 2025 06:57
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.

4 participants