23.2. Enabling kernel’s runtime integrity monitoring through IMA-signature based appraisal
Starting from RHEL 9, all package files are signed per file and users can make sure only authorized package files are accessed by enabling the signature-based IMA appraisal.
Enable the signature-based IMA appraisal:
ima-setup --policy=/usr/share/ima/policies/01-appraise-executable-and-lib-signatures
This command:
-
Stores package file signature in
security.imafor all installed packages. -
Includes the
dracutintegrity module to load the IMA code signing key to kernel. -
Copies the policy to
/etc/ima/ima-policyso systemd loads it at boot time.
Verification
-
The
ipcommand can be successfully executed. If
ipis copied to/tmp, by default, it loses itssecurity.imaand thereforeipcommand is not executed.# cp /usr/sbin/ip /tmp # /tmp/ip -bash: /tmp/ip: Permission denied # /tmp/ip doesn't have security.ima # getfattr -m security.ima -d /tmp/ip # whereas /usr/sbin/ip has # getfattr -m security.ima /usr/sbin/ip # file: usr/sbin/ip security.ima=0sAwIE0zIESQBnMGUCMQCLXZ7ukyDcguLgPYwzXU16dcVrmlHxOta7vm7EUfX07Nf0xnP1MyE//AZaqeNIKBoCMFHNDOuA4uNvS+8OOAy7YEn8oathfsF2wsDSZi+NAoumC6RFqIB912zkRKxraSX8sA==
If the sample policy 01-appraise-executable-and-lib-signatures does not meet your requirements, you can create and use a custom policy.