Bug 2297927 - rpmsign broken: error: sign_hash failed
Summary: rpmsign broken: error: sign_hash failed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ima-evm-utils
Version: 41
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Bruno Meneguele
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: AcceptedFreezeException
Depends On:
Blocks: F41BetaFreezeException
TreeView+ depends on / blocked
 
Reported: 2024-07-15 10:27 UTC by Karel Srot
Modified: 2024-09-04 18:29 UTC (History)
12 users (show)

Fixed In Version: ima-evm-utils-1.6.1-2.fc42 ima-evm-utils-1.6.2-1.fc41
Clone Of:
Environment:
Last Closed: 2024-09-04 18:29:51 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Karel Srot 2024-07-15 10:27:57 UTC
# rpm -q rpm
rpm-4.19.92-2.fc41.x86_64
# rpmsign --addsign --signfiles --fskpath=/etc/keys/privkey_evm.pem /root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm
/root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm:
error: sign_hash failed
error: signFile failed

This is a regression compared to
# rpm -q rpm
rpm-4.19.91-13.fc41.x86_64
[root@vm-10-0-186-98 tmp.UFeskSJtgO]# rpmsign --addsign --signfiles --fskpath=/etc/keys/privkey_evm.pem /root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm
/root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm:
hash(sha256): 562eb1111ef3e3c2ec9c60e53b27af259ff984f31a804d97bfd49df13e843128
evm/ima signature: 264 bytes

FYI, This is identical scenario as in the previously reported bug https://bugzilla.redhat.com/show_bug.cgi?id=2291183 
although the error message is not entirely identical.

The test case source is available at
https://github.com/RedHat-SP-Security/keylime-tests/blob/main/functional/install-rpm-with-ima-signature/test.sh
with IMA keys being generated here
https://github.com/RedHat-SP-Security/keylime-tests/blob/main/Library/test-helpers/lib.sh#L1494

Reproducible: Always

Steps to Reproduce:
1. attempt to sign RPM file using --signfiles
2.
3.
Actual Results:  
Failure

Expected Results:  
Signing succeeds.

Reproducible: Always

Comment 1 Florian Festi 2024-07-24 07:55:50 UTC
Opened upstream as https://github.com/rpm-software-management/rpm/issues/3214

Comment 2 Panu Matilainen 2024-08-12 06:56:21 UTC
The related rpm code hasn't changed at all since the fix to bug 2291183, so I'm more inclined to think this is a regression in ima-evm-utils 1.0.6, to which rawhide was updated in the meanwhile. Especially since this has appeared in rpm build log as a result, so clearly there have been significant changes on the ima-evm-utils side:

/builddir/build/BUILD/rpm-4.19.92-build/rpm-4.19.92/sign/rpmsignfiles.c: In function ‘signFile’:
/builddir/build/BUILD/rpm-4.19.92-build/rpm-4.19.92/sign/rpmsignfiles.c:56:5: warning: ‘sign_hash’ is deprecated [-Wdeprecated-declarations]
   56 |     siglen = sign_hash(algo, fdigest, diglen, key, keypass, signature+1);
      |     ^~~~~~
In file included from /builddir/build/BUILD/rpm-4.19.92-build/rpm-4.19.92/sign/rpmsignfiles.h:12,
                 from /builddir/build/BUILD/rpm-4.19.92-build/rpm-4.19.92/sign/rpmsignfiles.c:17:
/usr/include/imaevm.h:240:23: note: declared here
  240 | IMAEVM_DEPRECATED int sign_hash(const char *algo, const unsigned char *hash,
      |                       ^~~~~~~~~

I'm not saying it's the case here, but it wouldn't be the first piece of software to deprecate a function and break it in the process when the tests no longer cover it.

Comment 3 Karel Srot 2024-08-12 07:59:48 UTC
This is definitely possible since in order to downgrade rpm I had to also downgrade to ima-evm-utils-1.5-5.fc41.

Comment 4 Peter Robinson 2024-08-29 10:26:28 UTC
Can you retest with 1.6.1 please?

Comment 5 Karel Srot 2024-08-29 10:48:18 UTC
Hi Peter,
I have tested with ima-evm-utils-1.6-2.fc41.x86_64, the issue is still present.

rpmsign --addsign --signfiles --fskpath=/etc/keys/privkey_evm.pem /root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm
                out: error: sign_hash failed
                out: error: signFile failed
                out: /root/rpmbuild/RPMS/noarch/rpm-ima-sign-test-1-1.noarch.rpm:

And the same situation is with ima-evm-utils-1.6.1-1.fc41

Comment 6 Stefan Berger 2024-08-29 18:35:38 UTC
I have modified evmctl 1.6 to use the old API sign_hash to create IMA signatures but I cannot recreate the issue with it. So at least in this case the old API seems to still be working fine.

I suppose we can rule out a failure to sign due to usage of SHA-1?

Any chance to hook gdb onto rpmsign? I will try to recreate this with rawhide.

Comment 7 zohar 2024-08-29 19:14:12 UTC
One of the recent changes in RH is building ima-evm-utils with just provider support, not with engine support.  sign_hash() is now limited to engine support.  Could this be the cause of the problem?

Comment 8 Stefan Berger 2024-08-29 20:14:07 UTC
It's an issue occurring during runtime when engines are missing.
PR: https://github.com/linux-integrity/ima-evm-utils/pull/9

Comment 9 Peter Robinson 2024-08-30 07:56:30 UTC
(In reply to zohar from comment #7)
> One of the recent changes in RH is building ima-evm-utils with just provider
> support, not with engine support.  sign_hash() is now limited to engine
> support.  Could this be the cause of the problem?

RHEL-10 drops engine support altogether, and it's deprecated upstream in openssl.

Comment 10 Peter Robinson 2024-08-30 08:13:37 UTC
Scratch build here with the PR patch, Karel can you test pls: https://koji.fedoraproject.org/koji/taskinfo?taskID=122682616

Comment 11 Karel Srot 2024-08-30 09:21:07 UTC
(In reply to Peter Robinson from comment #10)
> Scratch build here with the PR patch, Karel can you test pls:
> https://koji.fedoraproject.org/koji/taskinfo?taskID=122682616

Hello, I can confirm this build fixes the issue. Thank you.

Comment 12 Fedora Update System 2024-08-30 10:36:12 UTC
FEDORA-2024-42aa96c1d5 (ima-evm-utils-1.6.1-2.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-42aa96c1d5

Comment 13 Fedora Update System 2024-08-30 10:47:39 UTC
FEDORA-2024-69fa1ec0bf (ima-evm-utils-1.6.1-2.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-69fa1ec0bf

Comment 14 packager-dashboard-bot 2024-08-30 11:48:55 UTC
Proposed as a Freeze Exception for 41-beta by Fedora user pbrobinson using the blocker tracking app because:

 sign_hash is broken when used with ima. This is used by IoT Edition.

Comment 15 Peter Robinson 2024-08-30 11:49:39 UTC
>  sign_hash is broken when used with ima. This is used by IoT Edition.

That's meant to read "rpm sign_hash"

Comment 16 Fedora Update System 2024-08-30 23:52:30 UTC
FEDORA-2024-42aa96c1d5 (ima-evm-utils-1.6.1-2.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 17 Fedora Update System 2024-08-31 03:38:17 UTC
FEDORA-2024-69fa1ec0bf has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-69fa1ec0bf`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-69fa1ec0bf

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2024-09-01 01:45:44 UTC
FEDORA-2024-360cc548cb has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-360cc548cb`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-360cc548cb

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 19 František Zatloukal 2024-09-03 18:38:50 UTC
Discussed during the 2024-09-03 blocker review meeting: [1]

The decision to classify this bug as a AcceptedFreezeException (Beta) was made:

"This is accepted as it potentially has consequences during compose of IoT and upgrade of IoT systems to Beta, per Peter."

[1] https://meetbot.fedoraproject.org/blocker-review_matrix_fedoraproject-org/2024-09-03/f41-blocker-review.2024-09-03-16.00.log.html

Comment 20 Fedora Update System 2024-09-04 18:29:51 UTC
FEDORA-2024-360cc548cb (ima-evm-utils-1.6.2-1.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.