Chapter 2. Protecting SAP HANA installation by using fapolicyd
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
# 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 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
# 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