KARAF/etc/de.virtimo.bpc.core.security.checks.cfg |:tabs-sync-option: :page-aliases: admin/operation/security-checks/keystore-file-permissions-check.adoc

Karaf File Permissions Check

The Karaf File Permissions Check verifies whether security-critical files and directories of the Apache Karaf runtime environment on the server are protected against unauthorized access.

The check examines four areas:

  • Keystore file

  • Truststore file

  • Configuration directory etc/ including all files it contains

  • Deployment directory deploy/ including all files it contains

Security Relevance

Keystore and Truststore

The keystore stores the BPC server’s private keys and certificates for TLS encryption. The truststore contains the trusted certificates (CA certificates) used to validate remote parties. If unauthorized accounts or processes on the operating system gain read access to the keystore, private keys can be compromised and encrypted data traffic can be intercepted or manipulated (man-in-the-middle attack). Write access allows certificates and keys to be replaced without detection. Therefore, by default, the keystore and truststore files must be accessible only to the owner account (the user account under which the Apache Karaf or BPC process is running).

Configuration directory etc/

The directory etc/ contains the central configuration files for the Karaf container and the BPC system. These include, for example, user management, service configurations, and security policies. If unauthorized individuals or processes have write access to this directory or the files it contains, they can manipulate configurations and circumvent the system’s security mechanisms.

Deployment directory deploy/

Apache Karaf continuously monitors the directory deploy/ and automatically installs artifacts stored there (e.g., OSGi bundles or feature files) at runtime (hot deployment). Write permissions for unauthorized users pose a critical security risk, as attackers can use them to inject arbitrary code and execute it with the privileges of the BPC service (Remote Code Execution, Privilege Escalation).

Configuring the Check

By default, the check requires that the keystore and truststore be accessible only to the process owner and that no write permissions be granted to the group (group) or others (others) for etc/ and deploy/.

Parameter

Default value Description allowGroupAccess
Example KARAF/etc/de.virtimo.bpc.core.security.checks.cfg
# Karaf File Permissions Security Check Configuration
allowGroupAccess=true

If allowGroupAccess=true is configured:

  • group members are allowed read and write access to keystore and truststore files (execution rights remain prohibited); other accounts (others) continue to have no access whatsoever.

  • Group members may have write permissions for the directories etc/ and deploy/ as well as for the files contained therein; other accounts (others) must continue to have no write permissions.

Security Procedure

To ensure the required permissions, the file permissions on the operating system must be adjusted:

  • Unix Systems

  • Windows Systems

On Unix and Linux systems, the permissions for the keystore and truststore should be set to 0600 (only the owner may read and write) or 0400 (only the owner may read):

# Dateiberechtigungen für Keystore und Truststore auf Eigentümer beschränken (rw-------)
chmod 600 /pfad/zu/keystore.jks
chmod 600 /pfad/zu/truststore.jks

# Sicherstellen, dass das BPC-Dienstkonto Eigentümer ist
chown bpc:bpc /pfad/zu/keystore.jks
chown bpc:bpc /pfad/zu/truststore.jks

For the directories etc/ and deploy/, as well as all files contained therein, write permissions for “Others” (and, by default, for the group) must be revoked:

# Verzeichnisberechtigungen anpassen (z. B. rwxr-x---)
chmod 750 /pfad/zu/karaf/etc
chmod 750 /pfad/zu/karaf/deploy

# Schreibrechte für Gruppe und Andere rekursiv von allen enthaltenen Dateien entfernen
chmod -R go-w /pfad/zu/karaf/etc
chmod -R go-w /pfad/zu/karaf/deploy

# Sicherstellen, dass das BPC-Dienstkonto Eigentümer ist
chown -R bpc:bpc /pfad/zu/karaf/etc /pfad/zu/karaf/deploy
If allowGroupAccess=true is configured, write permissions for the group are permitted. In this case, it is sufficient to simply remove write permissions for “Others” (chmod -R o-w /pfad/zu/karaf/etc /pfad/zu/karaf/deploy).

On Windows systems (NTFS), access permissions are controlled via Access Control Lists (ACLs). By default, newly created files inherit permissions from the parent directory, which typically grants access rights to groups such as Benutzer (BUILTIN\Users) or Jeder.

To restrict access to the keystore and truststore to the process owner, inheritance must be disabled and access must be explicitly restricted to the service account (e.g., %USERNAME%):

rem Vererbung deaktivieren und bestehende Rechte entfernen, nur dem aktuellen Benutzerkonto Zugriff gewähren:
icacls "C:\pfad\zu\keystore.jks" /inheritance:r /grant:r "%USERNAME%:(R,W)"
icacls "C:\pfad\zu\truststore.jks" /inheritance:r /grant:r "%USERNAME%:(R,W)"

If Apache Karaf is running as a Windows service under the system account (NT AUTHORITY\SYSTEM), access can also be granted to the service account:

icacls "C:\pfad\zu\keystore.jks" /grant:r "SYSTEM:(R,W)"
icacls "C:\pfad\zu\truststore.jks" /grant:r "SYSTEM:(R,W)"

Write permissions for non-administrative accounts and groups (such as BUILTIN\Users or Everyone) should be removed from the directories etc\ and deploy\:

rem Schreibrechte für unberechtigte Standard-Gruppen auf etc und deploy rekursiv entfernen:
icacls "C:\pfad\zu\karaf\etc" /remove:g "BUILTIN\Users" /t
icacls "C:\pfad\zu\karaf\deploy" /remove:g "BUILTIN\Users" /t

Evaluation Criteria for the Check

The check awards a maximum of 4 points (1 point per test area):

  • Keystore (1 point): The keystore file is configured in Pax-Web, exists, and is protected against unauthorized access.

  • Trust Store (1 point): The truststore file is configured in Pax-Web, exists, and is protected against unauthorized access.

  • etc/ directory (1 point): The directory etc/ and all files it contains are not writable by others (and, without allowGroupAccess, are not writable by group).

  • deploy/ directory (1 point): The directory deploy/ and all files it contains cannot be written to via others (nor, without allowGroupAccess, via group).