Configuring fapolicyd to allow only SAP HANA executables
Abstract
Making open source more inclusive Copy linkLink copied to clipboard!
Red Hat is committed to replacing problematic language in our code and documentation. We are beginning with these four terms: master, slave, blacklist, and whitelist. Due to the enormity of this endeavor, these changes will be gradually implemented over upcoming releases. For more details on making our language more inclusive, see our CTO Chris Wright’s message.
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We appreciate your feedback on our documentation. Let us know how we can improve it.
Submitting feedback through Jira (account required)
- Make sure you are logged in to the Jira website.
- Click on this link to provide feedback.
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the dialogue.
Chapter 1. Introduction to fapolicyd Copy linkLink copied to clipboard!
The fapolicyd software framework controls the execution of applications based on a user-defined policy. This is one of the most efficient ways to prevent running untrusted and possibly malicious applications on the system. For more information, refer to Blocking and allowing applications by using fapolicyd in the Security hardening guide for RHEL 9.
The procedures described below put all detected SAP HANA executables into fapolicyd trust files, which contain all names, sizes, and checksums of trusted files. SAP HANA binaries and shell scripts can only be executed if they are contained in the fapolicyd trust files. So, if you execute SAP HANA binaries or shell scripts that are not contained in the fapolicyd trust files, undesirable effects, including corruption or loss of data, could happen. You must carefully test all the steps and do proper verification on a non-production system first.
Chapter 2. Protecting SAP HANA installation by using fapolicyd Copy linkLink copied to clipboard!
You can perform the following steps to protect a SAP HANA installation:
-
Installing the
fapolicydpackage. -
Setting the integrity checking to
sha256hashes. -
Adding custom
fapolicydrules to protect shell scripts. - Marking the SAP HANA files as trusted.
-
Enabling the
fapolicydservice.
2.1. Installing the fapolicyd package Copy linkLink copied to clipboard!
Procedure
Install the
fapolicydpackage:dnf install fapolicyd
# dnf install fapolicydCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Use the following command to verify that the
fapolicydservice is installed but not currently running:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Setting the integrity checking to sha256 hashes Copy linkLink copied to clipboard!
By default, fapolicyd verifies the file names when deciding if an application has to be blocked from execution. You can modify this setting to sha256 for a higher level of protection.
Prerequisites
-
The
fapolicydpackage is installed on your system.
Procedure
Open the
/etc/fapolicyd/fapolicyd.conffile in a text editor of your choice, for example:vi /etc/fapolicyd/fapolicyd.conf
# vi /etc/fapolicyd/fapolicyd.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the integrity option and change the default value of
nonetosha256:integrity = sha256.For the change to become effective, you need to restart the
fapolicydservice. Do not restart thefapolicydnow, as you have to make more changes to thefapolicydconfiguration.
Verification
Verify the correct entry:
fapolicyd-cli --check-config Daemon config is OK
# fapolicyd-cli --check-config Daemon config is OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The SAP HANA benchmark was tested on RHEL 9.2. While doing so, initially fapolicyd was disabled and then enabled to evaluate the performance implications of fapolicyd. To allow the tests to run, a total of 19,184 entries were added to the fapolicyd trust files. In 99% of the tests, the performance impact was 5% or less, with the vast majority of the tests experiencing a slowdown of 1-3%.
However, certain workloads may experience a higher performance penalty. Therefore, you must thoroughly evaluate performance within your specific environment to identify potential impacts accurately.
2.3. Adding custom fapolicyd rules to protect shell scripts Copy linkLink copied to clipboard!
By default, fapolicyd blocks binary executable files and certain programs (e.g., Python) from being executed. To also protect shell scripts in the SAP HANA installation directories, you have to add new custom rules.
Prerequisites
-
The
fapolicydpackage is installed on your system.
Procedure
-
Change to the directory
/etc/fapolicyd/rules.d. Add a new file with a file name starting with
71(proposed file name:71-sap-shellscript.rules) so the rule is placed between the rules of the files70-trusted-lang.rulesand72-shell.rules, with the following content:Deny shell script execution and sourcing under SAP HANA directories deny_audit perm=any all : ftype=text/x-shellscript dir=/hana/,/usr/sap/ trust=0
# Deny shell script execution and sourcing under SAP HANA directories deny_audit perm=any all : ftype=text/x-shellscript dir=/hana/,/usr/sap/ trust=0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the ownership of the file to those of the other files in
/etc/fapolicyd/rules.d:chown root:fapolicyd 71-sap-shellscript.rules
# chown root:fapolicyd 71-sap-shellscript.rulesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the following commands to confirm that new rules have been defined, and then load the new rules:
fagenrules --check /usr/sbin/fagenrules: Rules have changed and should be updated fagenrules --load
# fagenrules --check /usr/sbin/fagenrules: Rules have changed and should be updated # fagenrules --loadCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the rules are updated:
fagenrules --check /usr/sbin/fagenrules: No change
# fagenrules --check /usr/sbin/fagenrules: No changeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.4. Marking the SAP HANA files as trusted Copy linkLink copied to clipboard!
Prerequisite
-
The
fapolicydpackage is installed on your system.
Procedure
- Install the SAP HANA software if not already done.
Use the following commands to add all the SAP HANA files to the
fapolicydtrust database. We recommend using a separate trust file for each directory tree, for example,hanaandusr_sap:fapolicyd-cli --file add /hana --trust-file hana fapolicyd-cli --file add /usr/sap --trust-file usr_sap
# fapolicyd-cli --file add /hana --trust-file hana # fapolicyd-cli --file add /usr/sap --trust-file usr_sapCopy to Clipboard Copied! Toggle word wrap Toggle overflow This creates two files, named
hanaandusr_sap, in the directory/etc/fapolicyd/trust.d, which contains entries for all files under/hanaand/usr/sap.For an SAP HANA installation on a freshly installed RHEL system, the SAP HANA installer creates the directories
/hanaand/usr/sap, so we can trust that all the files in these directories are valid SAP files.In any other case, there might be files in those directories that the SAP HANA installer has not created.
Therefore, you should carefully verify that all the files in the trust files
/etc/fapolicyd/trust.d/hanaand/etc/fapolicyd/trust.d/usr_sapare valid SAP files. One of the possible ways is explained below:- Perform a fresh SAP HANA installation on another freshly installed RHEL system.
- Repeat step 2 on that system.
- Compare the resulting trust files of both systems.
2.5. Enabling the fapolicyd service Copy linkLink copied to clipboard!
Prerequisites
-
The
fapolicydpackage is installed and not currently running on your system. - You have completed all the previous steps.
Procedure
Enable and start the
fapolicydservice:systemctl enable --now fapolicyd
# systemctl enable --now fapolicydCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
The
fapolicydservice now protects the SAP HANA system. Scripts and binaries in/hanaor/usr/sapthat are not in thefapolicydtrust files are blocked, and non-root users cannot execute these files.
Verification
Verify that the
fapolicydservice is up and running:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the non-root users, including the SAP HANA administrator user (example:
h70adm), cannot execute any new scripts and binary programs in/hanaand/usr/sap:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Recreating the fapolicyd trust files when updating SAP HANA Copy linkLink copied to clipboard!
Prerequisites
-
The
fapolicydpackage is installed on your system. - You have verified that there are no new executables in the SAP HANA software directories, so you do not accidentally add software from unknown sources. For more information, refer to Marking the SAP HANA files as trusted.
Procedure
Stop
fapolicydbefore performing the SAP HANA software update:systemctl stop fapolicyd
# systemctl stop fapolicydCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create a backup of the existing
fapolicydtrust files/etc/fapolicyd/trust.d/hanaand/etc/fapolicyd/trust.d/usr_sap, and then remove these files. - Perform the SAP HANA software update.
-
Repeat procedure section’s step 2 of Marking the SAP HANA files as trusted, to recreate the
fapolicydtrust files for SAP HANA. Start
fapolicyd:systemctl start fapolicyd
# systemctl start fapolicydCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 4. Troubleshooting issues related to fapolicyd Copy linkLink copied to clipboard!
For diagnosing issues related to fapolicyd, you can:
-
check the file
/var/log/fapolicyd-access.logforfapolicydaccess statistics, and/or, -
run
fapolicydin debug mode.
For more information on diagnosing fapolicyd related issues, refer to Troubleshooting problems related to fapolicyd.
Chapter 5. Additional information Copy linkLink copied to clipboard!
After adding more files to the
fapolicydtrust file, use the following command to update thefapolicyddatabase:fapolicyd-cli --update
# fapolicyd-cli --updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow After removing entries from the
fapolicydtrust file, you have to restartfapolicydinstead:systemctl restart fapolicyd
# systemctl restart fapolicydCopy to Clipboard Copied! Toggle word wrap Toggle overflow