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

Error installing packages when FIPS is enabled #2505

Open
clopmz opened this issue Oct 26, 2022 · 8 comments · May be fixed by #3747
Open

Error installing packages when FIPS is enabled #2505

clopmz opened this issue Oct 26, 2022 · 8 comments · May be fixed by #3747
Assignees
Labels
Area: Build/Platform Complexity: Modest A cup of tea and an evening (or two) with Zeek. Type: Bug 🐛 Unexpected behavior or output.

Comments

@clopmz
Copy link

clopmz commented Oct 26, 2022

Host: RedHat Enterprise Linux 9
Zeek release: 5.0.2
OpenSSL version: 3.0.1

When you try to install af_packet package under a RHEL9 host with FIPS enabled returns the following error:

$ more testing/zeek-af_packet-plugin/clones/zeek-af_packet-plugin/zkg.test_command.stderr
scripts.show-plugin ... failed
  % 'btest-diff output' failed unexpectedly (exit code 1)
  % cat .diag
  == File ===============================
  == Diff ===============================
  --- /tmp/test-diff.57126.output.baseline.tmp	2022-10-26 09:01:57.467293567 +0000
  +++ /tmp/test-diff.57126.output.tmp	2022-10-26 09:01:57.460293516 +0000
  @@ -1,11 +0,0 @@
  -Zeek::AF_Packet - Packet acquisition via AF_Packet (dynamic, version)
  -    [Packet Source] AF_PacketReader (interface prefix "af_packet"; supports live input)
  -    [Type] AF_Packet::FanoutMode
  -    [Constant] AF_Packet::buffer_size
  -    [Constant] AF_Packet::enable_hw_timestamping
  -    [Constant] AF_Packet::enable_fanout
  -    [Constant] AF_Packet::enable_defrag
  -    [Constant] AF_Packet::fanout_mode
  -    [Constant] AF_Packet::fanout_id
  -    [Constant] AF_Packet::link_type
  -
  =======================================

  % cat .stderr
  internal error: EVP_DigestInit failed

1 of 1 test failed

Testing against openssl framework confirms some type of problem when FIPS is enabled:

$ zeek -e 'print md5_hash("zeek"); print sha1_hash("zeek"); print sha256_hash("zeek")'
internal error: EVP_DigestInit failed
Aborted (core dumped)

Disbling FIPS framework, all it is working ok.

@0xxon 0xxon added this to the 5.2.0 milestone Jan 11, 2023
@0xxon 0xxon added Complexity: Modest A cup of tea and an evening (or two) with Zeek. Type: Bug 🐛 Unexpected behavior or output. Area: Build/Platform labels Jan 11, 2023
@0xxon
Copy link
Member

0xxon commented Jan 11, 2023

For anyone who wants to reproduce this - the magic commands you have to use to make libraries like libpcap-devel available on RHEL9 are (at least for me):

subscription-manager config --rhsm.manage_repos=1
subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms

This is the backtrace of the command line mentioned in the ticket, after enabling FIPS-mode with fips-mode-setup --enable:

#0  0x00007ffff6e1f54c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007ffff6dd2ce6 in raise () from /lib64/libc.so.6
#2  0x00007ffff6da67f3 in abort () from /lib64/libc.so.6
#3  0x000000000108040b in zeek::Reporter::InternalError (this=<optimized out>, fmt=fmt@entry=0x23e832f "EVP_DigestInit failed") at ../src/Reporter.cc:236
#4  0x0000000000f5fc0e in zeek::detail::hash_init (alg=alg@entry=zeek::detail::Hash_MD5) at ../src/digest.cc:48
#5  0x0000000000f5fc77 in zeek::detail::calculate_digest (out=0x2bedab0 <zeek::detail::KeyedHash::shared_hmac_md5_key> "", len=64,
    data=0x7fffffffd980 "\231\255\"\212dx\303T\017\021,I\037w\254\264\371\355\376Іbo\244G\340Z\320N\\8ԃ\303\062t\356P\201A\227)\261\366\002\200YR\350\257\351\307\374\216h\250\322\065 l\270+|j\326\354\266m\273\221D\312\032W+`i+", <incomplete sequence \306>, alg=zeek::detail::Hash_MD5) at ../src/digest.cc:81
#6  zeek::detail::internal_md5 (
    data=data@entry=0x7fffffffd980 "\231\255\"\212dx\303T\017\021,I\037w\254\264\371\355\376Іbo\244G\340Z\320N\\8ԃ\303\062t\356P\201A\227)\261\366\002\200YR\350\257\351\307\374\216h\250\322\065 l\270+|j\326\354\266m\273\221D\312\032W+`i+", <incomplete sequence \306>, len=len@entry=64, out=out@entry=0x2bedab0 <zeek::detail::KeyedHash::shared_hmac_md5_key> "")
    at ../src/digest.cc:69
#7  0x000000000106b773 in zeek::detail::KeyedHash::InitializeSeeds (seed_data=...) at /usr/include/c++/11/array:261
#8  0x0000000000f627aa in zeek::util::detail::init_random_seed (read_file=<optimized out>, write_file=0x0, use_empty_seeds=<optimized out>) at ../src/util.cc:486
#9  0x0000000000f938c5 in zeek::detail::setup (argc=argc@entry=3, argv=argv@entry=0x7fffffffe4b8, zopts=zopts@entry=0x0) at ../src/zeek-setup.cc:634
#10 0x0000000000e38fe2 in main (argc=3, argv=0x7fffffffe4b8) at ../src/main.cc:23

@0xxon
Copy link
Member

0xxon commented Jan 11, 2023

I tried taking a stab at this today - and unless I am missing something, there might not be an easy workaround anymore to get MD5 to work with OpenSSL.

If true, I am not entirely sure what this means for us. We could add our own MD5 library. However, while that is a technical workaround, I am not sure if this might render the system no longer fips compliant - I am not sure there still is a caveout for using MD5 for non-security use in the current iteration of FIPS. If someone has any information on that, I would be curious.

The second alternative - which might be preferable - would be to make sure that Zeek is able to run without requiring the use of MD5.

@0xxon 0xxon removed this from the 5.2.0 milestone Jan 11, 2023
@0xxon 0xxon removed their assignment Jan 11, 2023
@timwoj
Copy link
Contributor

timwoj commented Jan 11, 2023

The second alternative - which might be preferable - would be to make sure that Zeek is able to run without requiring the use of MD5.

I like this one. Are we losing anything by dropping it?

@micrictor
Copy link
Contributor

Replacing MD5 in the IP address anonymization routines would be a breaking change for users that supply their own HMAC seeds for predictable outputs for the same inputs across restarts. I've never seen anonymization used this way, only ever in anonymizing the output of a PCAP for sharing, but it's worth knowing.

I am not sure there still is a caveout for using MD5 for non-security use in the current iteration of FIPS.

It's my understanding that it's still permitted to use MD5 for non-security applications in 140-3. The above example, though, would qualify as a security application, as it's used to protect identifiable information.

@micrictor
Copy link
Contributor

Installing packages while FIPS is enabled can be addressed by using the -fips context flag, similar to how OpenSSL's own X509 implementation does it in src/digest.cc when OpenSSL >= 3.0.0 is in use.

Plugins that use MD5Vals or scripts that use the md5_hash methods would still be broken in FIPS mode, as those rely on MD5_Init for OpenSSL >= 3.0.0 because OpaqueVals need to have their entire state serializable.

@ckreibich
Copy link
Member

I'm putting this on the radar again, for 7.0. It also strikes me as the right direction to strip MD5 functionality from Zeek in this setting. This doesn't look too daunting per se — MD5 isn't particularly entrenched in the code — but it certainly brings up other technical/maintainability/UX questions.

@ckreibich ckreibich self-assigned this Apr 23, 2024
@MP-Corelight
Copy link

+1 interest in FIPS compliance for Zeek.

@bbannier bbannier self-assigned this May 17, 2024
@bbannier bbannier linked a pull request May 21, 2024 that will close this issue
@ckreibich
Copy link
Member

Turns out there's a quick way to reproduce on Fedora, since its OpenSSL supports toggling via an env var:

$ zeek -e 'print md5_hash("zeek"); print sha1_hash("zeek"); print sha256_hash("zeek")'
cfc17d3ae3f66d99e60b5f6a2a93c239
e274c2b93298a8c267b5442538911f456b7058d9
6e349f5b2a04d4f0c538ea1e8dd8a95067fd2c32f150a152816f14dcfdae0364
$ OPENSSL_FORCE_FIPS_MODE=1 zeek -e 'print md5_hash("zeek"); print sha1_hash("zeek"); print sha256_hash("zeek")'
internal error: EVP_DigestInit failed
Aborted (core dumped)

@bbannier bbannier linked a pull request Jun 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Build/Platform Complexity: Modest A cup of tea and an evening (or two) with Zeek. Type: Bug 🐛 Unexpected behavior or output.
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

7 participants