Integrity Policy Enforcement LSM (IPE)
Subsystems (10)
Re: [RFC PATCH v9 16/16] documentation: add ipe documentation
In reply to Fan WuQuoted 725 lines · Fan Wu
Documentation/admin-guide/LSM/ipe.rst new file +719
-0@@ -0,0 +1,729 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Integrity Policy Enforcement (IPE) +================================== + +.. NOTE:: + + This is the documentation for admins, system builders, or individuals + attempting to use IPE. If you're looking for more developer-focused + documentation about IPE please see `Documentation/security/ipe.rst` + +Overview +-------- + +IPE is a Linux Security Module which takes a complimentary approach to +access control. Whereas existing mandatory access control mechanisms +base their decisions on labels and paths, IPE instead determines +whether or not an operation should be allowed based on immutable +security properties of the system component the operation is being +performed on. + +IPE itself does not mandate how the security property should be +evaluated, but relies on an extensible set of external property providers +to evaluate the component. IPE makes its decision based on reference +values for the selected properties, specified in the IPE policy. + +The reference values represent the value that the policy writer and the +local system administrator (based on the policy signature) trust for the +system to accomplish the desired tasks. + +One such provider is for example dm-verity, which is able to represent +the integrity property of a partition (its immutable state) with a digest. + +IPE is compiled under ``CONFIG_SECURITY_IPE`` (Security -> Integrity Policy Enforcement (IPE)). + +Use Cases +--------- + +IPE works best in fixed-function devices: devices in which their purpose +is clearly defined and not supposed to be changed (e.g. network firewall +device in a data center, an IoT device, etcetera), where all software and +configuration is built and provisioned by the system owner. + +IPE is a long-way off for use in general-purpose computing: the Linux +community as a whole tends to follow a decentralized trust model, +known as the web of trust, which IPE has no support for as of yet. + +IPE, instead of supporting web of trust, supports PKI, which generally +designates a set of entities that provide a measure of absolute trust. + +Additionally, while most packages are signed today, the files inside +the packages (for instance, the executables), tend to be unsigned. This +makes it difficult to utilize IPE in systems where a package manager is +expected to be functional, without major changes to the package manager +and ecosystem behind it. + +DIGLIM [#diglim]_ is a system that when combined with IPE, could be used to +enable general purpose computing scenarios. + +Known Gaps +---------- + +IPE cannot verify the integrity of anonymous executable memory, such as +the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. +Unfortunately, as this is dynamically generated code, there is no way +for IPE to ensure the integrity of this code to form a trust basis. In all +cases, the return result for these operations will be whatever the admin +configures as the ``DEFAULT`` action for ``EXECUTE``. + +IPE cannot verify the integrity of interpreted languages' programs when +these scripts are invoked via ``<interpreter> <file>``. This is because +the way interpreters execute these files, the scripts themselves are not +evaluated as executable code through one of IPE's hooks, as they are merely +files that are read (as opposed to executable code) [#interpreters]_. + +Threat Model +------------ + +The threat type addressed by IPE is tampering of executable userspace +code beyond the initially booted kernel, and the initial verification of +kernel modules that are loaded in userspace through ``modprobe`` or +``insmod``. + +A bare-minimum example of a threat that should be mitigated by IPE, is +a hostile binary is downloaded with all required binaries (including +a loader, libc, etc). With IPE, this hostile binary should not able to +be executed, nor any of the downloaded binaries. + +Tampering violates integrity, and being unable to verify the integrity, +results in a lack of trust. IPE's role in mitigating this threat is to +verify the integrity (and authenticity) of all executable code and to +deny their use if they cannot be trusted (as integrity verification fails, +or the authorization check fails against the reference value in the policy). +IPE generates audit logs which may be utilized to detect failures resulting +from failure to pass policy. + +Tampering threat scenarios include modification or replacement of +executable code by a range of actors including: + +- Actors with physical access to the hardware +- Actors with local network access to the system +- Actors with access to the deployment system +- Compromised internal systems under external control +- Malicious end users of the system +- Compromised end users of the system +- Remote (external) compromise of the system + +IPE does not mitigate threats arising from malicious authorized +developers (with access to a signing certificate), or compromised +developer tools used by authorized developers (i.e. Return Oriented +Programming attacks). Additionally, IPE draws hard security boundary +between userspace and kernelspace. As a result, IPE does not provide +any protections against a kernel level exploit, and a kernel-level +exploit can disable or tamper with IPE's protections. + +Policy +------ + +IPE policy is a plain-text [#devdoc]_ policy composed of multiple statements +over several lines. There is one required line, at the top of the +policy, indicating the policy name, and the policy version, for +instance:: + + policy_name=Ex_Policy policy_version=0.0.0 + +The policy name is a unique key identifying this policy in a human +readable name. This is used to create nodes under securityfs as well as +uniquely identify policies to deploy new policies vs update existing +policies. + +The policy version indicates the current version of the policy (NOT the +policy syntax version). This is used to prevent rollback of policy to +potentially insecure previous versions of the policy. + +The next portion of IPE policy are rules. Rules are formed by key=value +pairs, known as properties. IPE rules require two properties: "action", +which determines what IPE does when it encounters a match against the +rule, and "op", which determines when that rule should be evaluated. +The ordering is significant, a rule must start with "op", and end with +"action". Thus, a minimal rule is:: + + op=EXECUTE action=ALLOW + +This example will allow any execution. Additional properties are used to +restrict attributes about the files being evaluated. These properties +are intended to be descriptions of systems within the kernel that can +provide a measure of integrity verification, such that IPE can determine +the trust of the resource based on the "value" half of the property. + +Rules are evaluated top-to-bottom. As a result, any revocation rules, +or denies should be placed early in the file to ensure that these rules +are evaluated before a rule with "action=ALLOW" is hit. + +IPE policy supports comments. The character '#' will function as a +comment, ignoring all characters to the right of '#' until the newline. + +The default behavior of IPE evaluations can also be expressed in policy, +through the ``DEFAULT`` statement. This can be done at a global level, +or a per-operation level:: + + # Global + DEFAULT action=ALLOW + + # Operation Specific + DEFAULT op=EXECUTE action=ALLOW + +A default must be set for all known operations in IPE. If you want to +preserve older policies being compatible with newer kernels that can introduce +new operations, please set a global default of 'ALLOW', and override the +defaults on a per-operation basis. + +With configurable policy-based LSMs, there's several issues with +enforcing the configurable policies at startup, around reading and +parsing the policy: + +1. The kernel *should* not read files from userspace, so directly reading + the policy file is prohibited. +2. The kernel command line has a character limit, and one kernel module + should not reserve the entire character limit for its own + configuration. +3. There are various boot loaders in the kernel ecosystem, so handing + off a memory block would be costly to maintain. + +As a result, IPE has addressed this problem through a concept of a "boot +policy". A boot policy is a minimal policy, compiled into the kernel. +This policy is intended to get the system to a state where userspace is +set up and ready to receive commands, at which point a more complex +policy can be deployed via securityfs. The boot policy can be specified +via the Kconfig, ``SECURITY_IPE_BOOT_POLICY``, which accepts a path to +a plain-text version of the IPE policy to apply. This policy will be +compiled into the kernel. If not specified, IPE will be disabled until +a policy is deployed and activated through securityfs. + +Deploying Policies +~~~~~~~~~~~~~~~~~~ + +Policies can be deployed from userspace through securityfs. These policies +are signed through the PKCS#7 message format to enforce some level of +authorization of the policies (prohibiting an attacker from gaining +unconstrained root, and deploying an "allow all" policy). These +policies must be signed by a certificate that chains to the +``SYSTEM_TRUSTED_KEYRING``. Through openssl, the signing can be done via:: + + openssl smime -sign \ + -in "$MY_POLICY" \ + -signer "$MY_CERTIFICATE" \ + -inkey "$MY_PRIVATE_KEY" \ + -noattr \ + -nodetach \ + -nosmimecap \ + -outform der \ + -out "$MY_POLICY.p7b" + +Deploying the policies is done through securityfs, through the +``new_policy`` node. To deploy a policy, simply cat the file into the +securityfs node:: + + cat "$MY_POLICY.p7b" > /sys/kernel/security/ipe/new_policy + +Upon success, this will create one subdirectory under +``/sys/kernel/security/ipe/policies/``. The subdirectory will be the +``policy_name`` field of the policy deployed, so for the example above, +the directory will be ``/sys/kernel/security/ipe/policies/Ex_Policy``. +Within this directory, there will be five files: ``pkcs7``, ``policy``, +``active``, ``update``, and ``delete``. + +The ``pkcs7`` file is read only. Reading will provide the raw PKCS#7 data +that was provided to the kernel, representing the policy. Writing, will +deploy an in-place policy update.If the policy being read is the boot +policy, when read, this will return ENOENT, as this policy is not signed. + +The ``policy`` file is read only. Reading will provide the PKCS#7 inner +content of the policy, which will be the plain text policy. + +The ``active`` file is used to set a policy as the currently active policy. +This file is rw, and accepts a value of ``"1"`` to set the policy as active. +Since only a single policy can be active at one time, all other policies +will be marked inactive. The policy being marked active must have a policy +version greater or equal to the currently-running version. + +The ``update`` file is used to update a policy that is already present in +the kernel. This file is write-only and accepts a PKCS#7 signed policy. +One check will always be performed on this policy: the policy_names must +match with the updated version and the existing version. One additional check +may be made: If the policy being updated is the active policy, the updated +policy must have a policy version greater than or equal to the currently-running +version; This is to prevent rollback attacks. + +The ``delete`` file is used to remove a policy that is no longer needed. +This file is write-only and accepts a value of ``1`` to delete the policy. +On deletion, the securityfs node representing the policy will be removed. +The policy that is currently active cannot be deleted. + +Similarly, the writes to both ``update`` and ``new_policy`` above will +result in an error upon syntactically invalid or untrusted policies. +In the case of ``new_policy``, it will also error if a policy already +exists with the same ``policy_name``. + +Deploying these policies will *not* cause IPE to start enforcing this +policy. Once deployment is successful, a policy can be marked as active, +via ``/sys/kernel/security/ipe/$policy_name/active``. IPE will enforce +whatever policy is marked as active. For our example, we can activate +the ``Ex_Policy`` via:: + + echo 1 > "/sys/kernel/security/ipe/Ex_Policy/active" + +At which point, ``Ex_Policy`` will now be the enforced policy on the +system. + +IPE also provides a way to delete policies. This can be done via the +``delete`` securityfs node, ``/sys/kernel/security/ipe/$policy_name/delete``. +Writing ``1`` to that file will delete that node:: + + echo 1 > "/sys/kernel/security/ipe/$policy_name/delete" + +There is only one requirement to delete a policy: + +1. The policy being deleted must not be the active policy. + +.. NOTE:: + + If a traditional MAC system is enabled (SELinux, apparmor, smack), all + writes to ipe's securityfs nodes require ``CAP_MAC_ADMIN``. + +Modes +~~~~~ + +IPE supports two modes of operation: permissive (similar to SELinux's +permissive mode) and enforce. Permissive mode performs the same checks +as enforce mode, and logs policy violations, but will not enforce the +policy. This allows users to test policies before enforcing them. + +The default mode is enforce, and can be changed via the kernel command +line parameter ``ipe.enforce=(0|1)``, or the securityfs node +``/sys/kernel/security/ipe/enforce``. + +.. NOTE:: + + If a traditional MAC system is enabled (SELinux, apparmor, smack, etcetera), + all writes to ipe's securityfs nodes require ``CAP_MAC_ADMIN``. + +Audit Events +~~~~~~~~~~~~ + +1420 AUDIT_IPE_ACCESS +^^^^^^^^^^^^^^^^^^^^^ +Event Examples:: + + type=1420 audit(1653364370.067:61): path="/root/fs/rw/plain/execve" dev="vdc1" ino=16 rule="DEFAULT op=EXECUTE action=DENY" + type=1300 audit(1653364370.067:61): arch=c000003e syscall=10 success=no exit=-13 a0=7f0bf0644000 a1=4f80 a2=5 a3=7f0bf043d300 items=0 ppid=455 pid=737 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=3 comm="mprotect" exe="/root/host/mprotect" subj=kernel key=(null) + type=1327 audit(1653364370.067:61): proctitle=686F73742F6D70726F7465637400534800527C5700527C5800706C61696E2F657865637665 + + type=1420 audit(1653364735.161:64): rule="DEFAULT op=EXECUTE action=DENY" + type=1300 audit(1653364735.161:64): arch=c000003e syscall=9 success=no exit=-13 a0=0 a1=1000 a2=4 a3=20 items=0 ppid=455 pid=774 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=3 comm="mmap" exe="/root/host/mmap" subj=kernel key=(null) + type=1327 audit(1653364735.161:64): proctitle=686F73742F6D6D617000410058⏎ + +This event indicates that IPE made an access control decision; the IPE specific +record (1420) will always be emitted in conjunction with a ``AUDITSYSCALL`` record. + +Determining whether IPE is in permissive can be derived from the success and exit +field of the AUDITSYSCALL record + + + +Field descriptions: + ++---------------+------------+-----------+-------------------------------------------------------------------------+ +| Field | Value Type | Optional? | Description of Value | ++===============+============+===========+=========================================================================+ +| path | string | Yes | The absolute path to the file that was the subject of the evaluation | ++---------------+------------+-----------+-------------------------------------------------------------------------+ +| ino | integer | Yes | The inode number of the file that was the subject of the evaluation | ++---------------+------------+-----------+-------------------------------------------------------------------------+ +| dev | string | Yes | The device name that the file under evaluation belongs to, e.g. vda | ++---------------+------------+-----------+-------------------------------------------------------------------------+ +| rule | string | No | The exact rule in IPE's policy that the evaluation matched | ++---------------+------------+-----------+-------------------------------------------------------------------------+ + +1403 AUDIT_MAC_POLICY_LOAD +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Event Example:: + + type=1403 audit(1653425529.927:53): policy_name="dmverity_roothash" policy_version=0.0.0 sha256=DC67AC19E05894EFB3170A8E55DE529794E248C2 auid=4294967295 ses=4294967295 lsm=ipe res=1 + type=1300 audit(1653425529.927:53): arch=c000003e syscall=1 success=yes exit=2567 a0=3 a1=5596fcae1fb0 a2=a07 a3=2 items=0 ppid=184 pid=229 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=4294967295 comm="python3" exe="/usr/bin/python3.10" key=(null) + type=1327 audit(1653425529.927:53): PROCTITLE proctitle=707974686F6E3300746573742F6D61696E2E7079002D66002E2E + +This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record for the ``write`` syscall. + ++----------------+------------+-----------+--------------------------------------------------------------+ +| Field | Value Type | Optional? | Description of Value | ++================+============+===========+==============================================================+ +| policy_name | string | No | The policy_name field of the policy. | ++----------------+------------+-----------+--------------------------------------------------------------+ +| policy_version | string | No | The policy_version field of the policy | ++----------------+------------+-----------+--------------------------------------------------------------+ +| sha256 | string | Yes* | A flat hash of the policy. Can be used to identify a policy. | ++----------------+------------+-----------+--------------------------------------------------------------+ +| auid | integer | No | The audit user ID. | ++----------------+------------+-----------+--------------------------------------------------------------+ +| ses | integer | No | The session ID. | ++----------------+------------+-----------+--------------------------------------------------------------+ +| lsm | string | No | The lsm name associated with the event. | ++----------------+------------+-----------+--------------------------------------------------------------+ +| res | integer | No | The operation result. | ++----------------+------------+-----------+--------------------------------------------------------------+ + +1405 AUDIT_MAC_CONFIG_CHANGE +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Event Example:: + + type=1405 audit(1653425583.136:54): old_active_pol_name="Allow_All" old_active_pol_version=0.0.0 old_sha256=DA39A3EE5E6B4B0D3255BFEF95601890AFD80709 new_active_pol_name="dmverity_roothash" new_active_pol_version=0.0.0 new_sha256=DC67AC19E05894EFB3170A8E55DE529794E248C2 auid=4294967295 ses=4294967295 lsm=ipe res=1 + type=1300 audit(1653425583.136:54): SYSCALL arch=c000003e syscall=1 success=yes exit=2 a0=3 a1=5596fcae1fb0 a2=2 a3=2 items=0 ppid=184 pid=229 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=4294967295 comm="python3" exe="/usr/bin/python3.10" key=(null) + type=1327 audit(1653425583.136:54): PROCTITLE proctitle=707974686F6E3300746573742F6D61696E2E7079002D66002E2 + +This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record for the ``write`` syscall. + ++------------------------+------------+-----------+----------------------------------------------------+ +| Field | Value Type | Optional? | Description of Value | ++========================+============+===========+====================================================+ +| old_active_pol_name | string | No | The policy_name field of the old active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| old_active_pol_version | string | No | The policy_version field of the old active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| old_sha256 | string | Yes* | A flat hash of the old active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| new_active_pol_name | string | No | The policy_name field of the new active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| new_active_pol_version | string | No | The policy_version field of the new active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| new_sha256 | string | Yes* | A flat hash of the new active policy. | ++------------------------+------------+-----------+----------------------------------------------------+ +| auid | integer | No | The audit user ID. | ++------------------------+------------+-----------+----------------------------------------------------+ +| ses | integer | No | The session ID. | ++------------------------+------------+-----------+----------------------------------------------------+ +| lsm | string | No | The lsm name associated with the event. | ++------------------------+------------+-----------+----------------------------------------------------+ +| res | integer | No | The operation result. | ++------------------------+------------+-----------+----------------------------------------------------+ + +1404 AUDIT_MAC_STATUS +^^^^^^^^^^^^^^^^^^^^^ + +Event Examples:: + + type=1404 audit(1653425689.008:55): permissive=1 auid=0 ses=4294967295 lsm=ipe res=1 + type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=) + type=1327 audit(1653425689.008:55): proctitle="-bash" + + type=1404 audit(1653425689.008:55): permissive=0 auid=0 ses=4294967295 lsm=ipe res=1 + type=1300 audit(1653425689.008:55): arch=c000003e syscall=1 success=yes exit=2 a0=1 a1=55c1065e5c60 a2=2 a3=0 items=0 ppid=405 pid=441 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=) + type=1327 audit(1653425689.008:55): proctitle="-bash" + +This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record for the ``write`` syscall. + ++------------+------------+-----------+-------------------------------------------------------------------+ +| Field | Value Type | Optional? | Description of Value | ++============+============+===========+===================================================================+ +| permissive | integer | No | The state IPE is being switched to. 1 is permissive, 0 is enforce | ++------------+------------+-----------+-------------------------------------------------------------------+ +| auid | integer | No | The audit user ID. | ++------------+------------+-----------+-------------------------------------------------------------------+ +| ses | integer | No | The session ID. | ++------------+------------+-----------+-------------------------------------------------------------------+ +| lsm | string | No | The lsm name associated with the event. | ++------------+------------+-----------+-------------------------------------------------------------------+ +| res | integer | No | The operation result. | ++------------+------------+-----------+-------------------------------------------------------------------+ + +Success Auditing +^^^^^^^^^^^^^^^^ + +IPE supports success auditing. When enabled, all events that pass IPE +policy and are not blocked will emit an audit event. This is disabled by +default, and can be enabled via the kernel command line +``ipe.success_audit=(0|1)`` or the securityfs node, +``/sys/kernel/security/ipe/success_audit``. + +This is *very* noisy, as IPE will check every userspace binary on the +system, but is useful for debugging policies. + +.. NOTE:: + + If a traditional MAC system is enabled (SELinux, apparmor, smack, etcetera), + all writes to ipe's securityfs nodes require ``CAP_MAC_ADMIN``. + +Properties +---------- + +As explained above, IPE properties are ``key=value`` pairs expressed in +IPE policy. Two properties are built-into the policy parser: 'op' and +'action'. The other properties are determinstic attributes to express +across files. Currently those properties are: '``boot_verified``', +'``dmverity_signature``', '``dmverity_roothash``', '``fsverity_signature``', +'``fsverity_digest``'. A description of all properties supported by IPE +are listed below: + +op +~~ + +Indicates the operation for a rule to apply to. Must be in every rule, +as the first token. IPE supports the following operations: + + ``EXECUTE`` + + Pertains to any file attempting to be executed, or loaded as an + executable. + + ``FIRMWARE``: + + Pertains to firmware being loaded via the firmware_class interface. + This covers both the preallocated buffer and the firmware file + itself. + + ``KMODULE``: + + Pertains to loading kernel modules via ``modprobe`` or ``insmod``. + + ``KEXEC_IMAGE``: + + Pertains to kernel images loading via ``kexec``. + + ``KEXEC_INITRAMFS`` + + Pertains to initrd images loading via ``kexec --initrd``. + + ``POLICY``: + + Controls loading polcies via reading a kernel-space initiated read. + + An example of such is loading IMA policies by writing the path + to the policy file to ``$securityfs/ima/policy`` + + ``X509_CERT``: + + Controls loading IMA certificates through the Kconfigs, + ``CONFIG_IMA_X509_PATH`` and ``CONFIG_EVM_X509_PATH``. + +action +~~~~~~ + + Determines what IPE should do when a rule matches. Must be in every + rule, as the final clause. Can be one of: + + ``ALLOW``: + + If the rule matches, explicitly allow access to the resource to proceed + without executing any more rules. + + ``DENY``: + + If the rule matches, explicitly prohibit access to the resource to + proceed without executing any more rules. + +boot_verified +~~~~~~~~~~~~~ + + This property can be utilized for authorization of the first super-block + that executes a file. This is almost always init. Typically this is used + for systems with an initramfs or other initial disk, where this is unmounted + before the system becomes available, and is not covered by any other property. + The format of this property is:: + + boot_verified=(TRUE|FALSE) + + + .. WARNING:: + + This property will trust any disk where the first execution evaluation + occurs. If you do *NOT* have a startup disk that is unpacked and unmounted + (like initramfs), then it will automatically trust the root filesystem and + potentially overauthorize the entire disk. + +dmverity_roothash +~~~~~~~~~~~~~~~~~ + + This property can be utilized for authorization or revocation of + specific dm-verity volumes, identified via root hash. It has a + dependency on the DM_VERITY module. This property is controlled by the + Kconfig ``CONFIG_IPE_PROP_DM_VERITY``. The format of this property + is:: + + dmverity_roothash=DigestName:HexadecimalString + + The supported DigestNames for dmverity_roothash are [#dmveritydigests]_ [#securedigest]_ : + + + blake2b-512 + + blake2s-256 + + sha1 + + sha256 + + sha384 + + sha512 + + sha3-224 + + sha3-256 + + sha3-384 + + sha3-512 + + md4 + + md5 + + sm3 + + rmd160 + +dmverity_signature +~~~~~~~~~~~~~~~~~~ + + This property can be utilized for authorization of all dm-verity volumes + that have a signed roothash that chains to a keyring specified by dm-verity's + configuration, either the system trusted keyring, or the secondary keyring. + It has an additional dependency on the ``DM_VERITY_VERIFY_ROOTHASH_SIG`` + Kconfig. This property is controlled by the Kconfig + ``CONFIG_IPE_PROP_DM_VERITY``. The format of this property is:: + + dmverity_signature=(TRUE|FALSE) + +fsverity_digest +~~~~~~~~~~~~~~~ + + This property can be utilized for authorization or revocation of + specific fsverity enabled file, identified via its fsverity digest. + It has a dependency on the FS_VERITY module. This property is + controlled by the Kconfig ``CONFIG_IPE_PROP_FS_VERITY``. + The format of this property is:: + + fsverity_digest=DigestName:HexadecimalString + + The supported DigestNames for dmverity_roothash are [#fsveritydigest] [#securedigest]_ : + + + sha256 + + sha512 + +fsverity_signature +~~~~~~~~~~~~~~~~~~ + +Version 1 + + This property can be utilized for authorization of all fsverity enabled + files that is verified by fsverity. The keyring that the signature is + verified against is subject to fsverity's configuration, typically the fsverity + keyring. It has a dependency on the ``CONFIG_FS_VERITY_BUILTIN_SIGNATURES`` + Kconfig. This property is controlled by the Kconfig + ``CONFIG_IPE_PROP_FS_VERITY``. The format of this property is:: + + fsverity_signature=(TRUE|FALSE) + +Policy Examples +--------------- + +Allow all +~~~~~~~~~ + +:: + + policy_name=Allow_All policy_version=0.0.0 + DEFAULT action=ALLOW + +Allow only initial superblock +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=Allow_All_Initial_SB policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE boot_verified=TRUE action=ALLOW + +Allow any signed dm-verity volume and the initial superblock +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=AllowSignedAndInitial policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE boot_verified=TRUE action=ALLOW + op=EXECUTE dmverity_signature=TRUE action=ALLOW + +Prohibit execution from a specific dm-verity volume +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=AllowSignedAndInitial policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE dmverity_roothash=sha256:cd2c5bae7c6c579edaae4353049d58eb5f2e8be0244bf05345bc8e5ed257baff action=DENY + + op=EXECUTE boot_verified=TRUE action=ALLOW + op=EXECUTE dmverity_signature=TRUE action=ALLOW + +Allow only a specific dm-verity volume +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=AllowSignedAndInitial policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE dmverity_roothash=sha256:401fcec5944823ae12f62726e8184407a5fa9599783f030dec146938 action=ALLOW + +Allow any signed fs-verity file +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=AllowSignedFSVerity policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE fsverity_signature=TRUE action=ALLOW + +Prohibit execution of a specific fs-verity file +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + policy_name=ProhibitSpecificFSVF policy_version=0.0.0 + DEFAULT action=DENY + + op=EXECUTE fsverity_digest=sha256:fd88f2b8824e197f850bf4c5109bea5cf0ee38104f710843bb72da796ba5af9e action=DENY + op=EXECUTE boot_verified=TRUE action=ALLOW + op=EXECUTE dmverity_signature=TRUE action=ALLOW + +Additional Information +---------------------- + +- `Github Repository <https://github.com/microsoft/ipe>`_ +- `Design Documentation </security/ipe>`_ + +FAQ +--- + +Q: + What's the difference between other LSMs which provide a measure of + trust-based access control? + +A: + + In general, there's two other LSMs that can provide similar functionality: + IMA, and Loadpin. + + IMA and IPE are functionally very similar. The significant difference between + the two is the policy. [#devdoc]_ + + Loadpin and IPE differ fairly dramatically, as Loadpin controls only the IPE + equivalent of ``KERNEL_READ``, whereas IPE is capable of controlling execution, + on top of ``KERNEL_READ``. The trust model is also different; Loadpin roots its + trust in the initial super-block, instead, IPE roots its trust in the kernel + itself (via ``SYSTEM_TRUSTED_KEYS``). + +----------- + +.. [#diglim] 1: https://lore.kernel.org/bpf/[email protected]/T/ + +.. [#interpreters] There is `some interest in solving this issue <https://lore.kernel.org/lkml/[email protected]/>`_. + +.. [#devdoc] Please see `Documentation/security/ipe.rst` for more on this topic. + +.. [#fsveritydigest] These hash algorithms are based on values accepted by fsverity-utils; + IPE does not impose any restrictions on the digest algorithm itself;
Documentation/admin-guide/LSM/ipe.rst line 729
Quoted 10 lines
Documentation/admin-guide/LSM/ipe.rst new file +10
-0+ thus, this list may be out of date. + +.. [#dmveritydigests] These hash algorithms are based on values accepted by dm-verity, + specifically ``crypto_alloc_ahash`` in ``verity_ctr``; ``veritysetup`` + does support more algorithms than the list above. IPE does not impose + any restrictions on the digest algorithm itself; thus, this list + may be out of date. + +.. [#securedigest] Please ensure you are using cryptographically secure hash functions; + just because something is *supported* does not mean it is *secure*.
What about wordings below instead?
---- >8 ----
Documentation/admin-guide/LSM/ipe.rst +129 -126
@@ -31,7 +31,9 @@ system to accomplish the desired tasks. One such provider is for example dm-verity, which is able to represent the integrity property of a partition (its immutable state) with a digest. -IPE is compiled under ``CONFIG_SECURITY_IPE`` (Security -> Integrity Policy Enforcement (IPE)). +To enable IPE, ensure that ``CONFIG_SECURITY_IPE`` (under +:menuselection:`Security -> Integrity Policy Enforcement (IPE)`) config +option is enabled. Use Cases ---------
@@ -42,11 +44,10 @@ device in a data center, an IoT device, etcetera), where all software and configuration is built and provisioned by the system owner. IPE is a long-way off for use in general-purpose computing: the Linux -community as a whole tends to follow a decentralized trust model, -known as the web of trust, which IPE has no support for as of yet. - -IPE, instead of supporting web of trust, supports PKI, which generally -designates a set of entities that provide a measure of absolute trust. +community as a whole tends to follow a decentralized trust model (known as +the web of trust), which IPE has no support for it yet. Instead, IPE +supports PKI (public key infrastructure), which generally designates a +set of trusted entities that provide a measure of absolute trust. Additionally, while most packages are signed today, the files inside the packages (for instance, the executables), tend to be unsigned. This
@@ -55,10 +56,10 @@ expected to be functional, without major changes to the package manager and ecosystem behind it. DIGLIM [#diglim]_ is a system that when combined with IPE, could be used to -enable general purpose computing scenarios. +enable and support general-purpose computing use cases. -Known Gaps ----------- +Known Limitations +----------------- IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code.
@@ -67,11 +68,12 @@ for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures as the ``DEFAULT`` action for ``EXECUTE``. -IPE cannot verify the integrity of interpreted languages' programs when -these scripts are invoked via ``<interpreter> <file>``. This is because -the way interpreters execute these files, the scripts themselves are not -evaluated as executable code through one of IPE's hooks, as they are merely -files that are read (as opposed to executable code) [#interpreters]_. +IPE cannot verify the integrity of programs written in interpreted +languages when these scripts are invoked by passing these program files +to the interpreter. This is because the way interpreters execute these +files; the scripts themselves are not evaluated as executable code +through one of IPE's hooks, but they are merely text files that are read +(as opposed to compiled executables) [#interpreters]_. Threat Model ------------
@@ -82,17 +84,19 @@ kernel modules that are loaded in userspace through ``modprobe`` or ``insmod``. A bare-minimum example of a threat that should be mitigated by IPE, is -a hostile binary is downloaded with all required binaries (including -a loader, libc, etc). With IPE, this hostile binary should not able to -be executed, nor any of the downloaded binaries. +an untrusted (potentially malicious) binary that is downloaded and +bundled with all required dependencies (including a loader, libc, etc). +With IPE, this binary should not be allowed to be executed, not even any +of its dependencies. -Tampering violates integrity, and being unable to verify the integrity, -results in a lack of trust. IPE's role in mitigating this threat is to -verify the integrity (and authenticity) of all executable code and to -deny their use if they cannot be trusted (as integrity verification fails, -or the authorization check fails against the reference value in the policy). -IPE generates audit logs which may be utilized to detect failures resulting -from failure to pass policy. +Tampering violates integrity, yet lack of trust is caused by being +unable to detect tampering (and by extent verifying the integrity). +IPE's role in mitigating this threat is to verify the integrity (and +authenticity) of all executable code and to deny their use if they +cannot be trusted (as integrity verification fails, or the authorization +check fails against the reference value in the policy). IPE generates +audit logs which may be utilized to detect and analyze failures +resulting from policy violation. Tampering threat scenarios include modification or replacement of executable code by a range of actors including:
@@ -105,13 +109,13 @@ executable code by a range of actors including: - Compromised end users of the system - Remote (external) compromise of the system -IPE does not mitigate threats arising from malicious authorized +IPE does not mitigate threats arising from malicious but authorized developers (with access to a signing certificate), or compromised -developer tools used by authorized developers (i.e. Return Oriented -Programming attacks). Additionally, IPE draws hard security boundary -between userspace and kernelspace. As a result, IPE does not provide -any protections against a kernel level exploit, and a kernel-level -exploit can disable or tamper with IPE's protections. +developer tools used by them (i.e. return-oriented programming attacks). +Additionally, IPE draws hard security boundary between userspace and +kernelspace. As a result, IPE does not provide any protections against a +kernel level exploit, and a kernel-level exploit can disable or tamper +with IPE's protections. Policy ------
@@ -133,11 +137,11 @@ policy syntax version). This is used to prevent rollback of policy to potentially insecure previous versions of the policy. The next portion of IPE policy are rules. Rules are formed by key=value -pairs, known as properties. IPE rules require two properties: "action", +pairs, known as properties. IPE rules require two properties: ``action``, which determines what IPE does when it encounters a match against the -rule, and "op", which determines when that rule should be evaluated. -The ordering is significant, a rule must start with "op", and end with -"action". Thus, a minimal rule is:: +rule, and ``op``, which determines when the rule should be evaluated. +The ordering is significant, a rule must start with ``op``, and end with +``action``. Thus, a minimal rule is:: op=EXECUTE action=ALLOW
@@ -145,14 +149,14 @@ This example will allow any execution. Additional properties are used to restrict attributes about the files being evaluated. These properties are intended to be descriptions of systems within the kernel that can provide a measure of integrity verification, such that IPE can determine -the trust of the resource based on the "value" half of the property. +the trust of the resource based on the value of the property. Rules are evaluated top-to-bottom. As a result, any revocation rules, or denies should be placed early in the file to ensure that these rules -are evaluated before a rule with "action=ALLOW" is hit. +are evaluated before a rule with ``action=ALLOW``. -IPE policy supports comments. The character '#' will function as a -comment, ignoring all characters to the right of '#' until the newline. +IPE policy supports comments. Any line which is prefixed with ``#`` will +be ignored. The default behavior of IPE evaluations can also be expressed in policy, through the ``DEFAULT`` statement. This can be done at a global level,
@@ -166,8 +170,8 @@ or a per-operation level:: A default must be set for all known operations in IPE. If you want to preserve older policies being compatible with newer kernels that can introduce -new operations, please set a global default of 'ALLOW', and override the -defaults on a per-operation basis. +new operations, set a global default of ``ALLOW``, then override the +defaults on a per-operation basis (as above). With configurable policy-based LSMs, there's several issues with enforcing the configurable policies at startup, around reading and
@@ -182,14 +186,14 @@ parsing the policy: off a memory block would be costly to maintain. As a result, IPE has addressed this problem through a concept of a "boot -policy". A boot policy is a minimal policy, compiled into the kernel. -This policy is intended to get the system to a state where userspace is -set up and ready to receive commands, at which point a more complex -policy can be deployed via securityfs. The boot policy can be specified -via the Kconfig, ``SECURITY_IPE_BOOT_POLICY``, which accepts a path to -a plain-text version of the IPE policy to apply. This policy will be -compiled into the kernel. If not specified, IPE will be disabled until -a policy is deployed and activated through securityfs. +policy". A boot policy is a minimal policy which is compiled into the +kernel. This policy is intended to get the system to a state where +userspace is set up and ready to receive commands, at which point a more +complex policy can be deployed via securityfs. The boot policy can be +specified via ``SECURITY_IPE_BOOT_POLICY`` config option, which accepts +a path to a plain-text version of the IPE policy to apply. This policy +will be compiled into the kernel. If not specified, IPE will be disabled +until a policy is deployed and activated through securityfs. Deploying Policies ~~~~~~~~~~~~~~~~~~
@@ -199,7 +203,7 @@ are signed through the PKCS#7 message format to enforce some level of authorization of the policies (prohibiting an attacker from gaining unconstrained root, and deploying an "allow all" policy). These policies must be signed by a certificate that chains to the -``SYSTEM_TRUSTED_KEYRING``. Through openssl, the signing can be done via:: +``SYSTEM_TRUSTED_KEYRING``. With openssl, the policy can be signed by:: openssl smime -sign \ -in "$MY_POLICY" \
@@ -224,12 +228,12 @@ the directory will be ``/sys/kernel/security/ipe/policies/Ex_Policy``. Within this directory, there will be five files: ``pkcs7``, ``policy``, ``active``, ``update``, and ``delete``. -The ``pkcs7`` file is read only. Reading will provide the raw PKCS#7 data +The ``pkcs7`` file is read-only. Reading it returns the raw PKCS#7 data that was provided to the kernel, representing the policy. Writing, will -deploy an in-place policy update.If the policy being read is the boot -policy, when read, this will return ENOENT, as this policy is not signed. +deploy an in-place policy update. If the policy being read is the boot +policy, this will return ``ENOENT``, as it is is not signed. -The ``policy`` file is read only. Reading will provide the PKCS#7 inner +The ``policy`` file is read-only. Reading it returns the PKCS#7 inner content of the policy, which will be the plain text policy. The ``active`` file is used to set a policy as the currently active policy.
@@ -238,44 +242,42 @@ Since only a single policy can be active at one time, all other policies will be marked inactive. The policy being marked active must have a policy version greater or equal to the currently-running version. -The ``update`` file is used to update a policy that is already present in -the kernel. This file is write-only and accepts a PKCS#7 signed policy. -One check will always be performed on this policy: the policy_names must -match with the updated version and the existing version. One additional check -may be made: If the policy being updated is the active policy, the updated -policy must have a policy version greater than or equal to the currently-running -version; This is to prevent rollback attacks. +The ``update`` file is used to update a policy that is already present +in the kernel. This file is write-only and accepts a PKCS#7 signed +policy. One check will always be performed on this policy: the +``policy_names`` must match with the updated version and the existing +version. There is also an additional check: if the policy being updated +is the active policy, the updated policy must have a policy version +greater than or equal to the currently-running version. This is to +prevent rollback attacks. The ``delete`` file is used to remove a policy that is no longer needed. This file is write-only and accepts a value of ``1`` to delete the policy. On deletion, the securityfs node representing the policy will be removed. The policy that is currently active cannot be deleted. -Similarly, the writes to both ``update`` and ``new_policy`` above will -result in an error upon syntactically invalid or untrusted policies. -In the case of ``new_policy``, it will also error if a policy already -exists with the same ``policy_name``. +Similarly, writing to both ``update`` and ``new_policy`` results in +syntax or untrusted policy error. In the case of the latter, it will +also error out if a policy already exists with the same ``policy_name``. Deploying these policies will *not* cause IPE to start enforcing this -policy. Once deployment is successful, a policy can be marked as active, -via ``/sys/kernel/security/ipe/$policy_name/active``. IPE will enforce -whatever policy is marked as active. For our example, we can activate -the ``Ex_Policy`` via:: +policy. Once deployment is successful, a policy can be activated, by +``/sys/kernel/security/ipe/$policy_name/active``. IPE will enforce +active policies. For example, the ``Ex_Policy`` can be activated by:: echo 1 > "/sys/kernel/security/ipe/Ex_Policy/active" -At which point, ``Ex_Policy`` will now be the enforced policy on the +From above point on, ``Ex_Policy`` is now the enforced policy on the system. IPE also provides a way to delete policies. This can be done via the ``delete`` securityfs node, ``/sys/kernel/security/ipe/$policy_name/delete``. -Writing ``1`` to that file will delete that node:: +Writing ``1`` to that file deletes the policy:: echo 1 > "/sys/kernel/security/ipe/$policy_name/delete" -There is only one requirement to delete a policy: - -1. The policy being deleted must not be the active policy. +There is only one requirement to delete a policy: the policy being deleted +must be inactive. .. NOTE::
@@ -286,9 +288,9 @@ Modes ~~~~~ IPE supports two modes of operation: permissive (similar to SELinux's -permissive mode) and enforce. Permissive mode performs the same checks -as enforce mode, and logs policy violations, but will not enforce the -policy. This allows users to test policies before enforcing them. +permissive mode) and enforced. In permissive mode, all events are +checked and policy violations are logged, but the policy is not really +enforced. This allows users to test policies before enforcing them. The default mode is enforce, and can be changed via the kernel command line parameter ``ipe.enforce=(0|1)``, or the securityfs node
@@ -314,11 +316,12 @@ Event Examples:: type=1300 audit(1653364735.161:64): arch=c000003e syscall=9 success=no exit=-13 a0=0 a1=1000 a2=4 a3=20 items=0 ppid=455 pid=774 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=3 comm="mmap" exe="/root/host/mmap" subj=kernel key=(null) type=1327 audit(1653364735.161:64): proctitle=686F73742F6D6D617000410058⏎ -This event indicates that IPE made an access control decision; the IPE specific -record (1420) will always be emitted in conjunction with a ``AUDITSYSCALL`` record. +This event indicates that IPE made an access control decision; the IPE +specific record (1420) is always emitted in conjunction with a +``AUDITSYSCALL`` record. -Determining whether IPE is in permissive can be derived from the success and exit -field of the AUDITSYSCALL record +Determining whether IPE is in permissive or enforced mode can be derived +from ``success`` property and exit code of the ``AUDITSYSCALL`` record.
@@ -327,13 +330,13 @@ Field descriptions: +---------------+------------+-----------+-------------------------------------------------------------------------+ | Field | Value Type | Optional? | Description of Value | +===============+============+===========+=========================================================================+ -| path | string | Yes | The absolute path to the file that was the subject of the evaluation | +| path | string | Yes | The absolute path to the evaluated file | +---------------+------------+-----------+-------------------------------------------------------------------------+ -| ino | integer | Yes | The inode number of the file that was the subject of the evaluation | +| ino | integer | Yes | The inode number of the evaluated file | +---------------+------------+-----------+-------------------------------------------------------------------------+ -| dev | string | Yes | The device name that the file under evaluation belongs to, e.g. vda | +| dev | string | Yes | The device name of the evaluated file, e.g. vda | +---------------+------------+-----------+-------------------------------------------------------------------------+ -| rule | string | No | The exact rule in IPE's policy that the evaluation matched | +| rule | string | No | The matched policy rule | +---------------+------------+-----------+-------------------------------------------------------------------------+ 1403 AUDIT_MAC_POLICY_LOAD
@@ -350,11 +353,11 @@ This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record +----------------+------------+-----------+--------------------------------------------------------------+ | Field | Value Type | Optional? | Description of Value | +================+============+===========+==============================================================+ -| policy_name | string | No | The policy_name field of the policy. | +| policy_name | string | No | The policy name | +----------------+------------+-----------+--------------------------------------------------------------+ -| policy_version | string | No | The policy_version field of the policy | +| policy_version | string | No | The policy version | +----------------+------------+-----------+--------------------------------------------------------------+ -| sha256 | string | Yes* | A flat hash of the policy. Can be used to identify a policy. | +| sha256 | string | Yes* | The policy hash | +----------------+------------+-----------+--------------------------------------------------------------+ | auid | integer | No | The audit user ID. | +----------------+------------+-----------+--------------------------------------------------------------+
@@ -379,17 +382,17 @@ This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record +------------------------+------------+-----------+----------------------------------------------------+ | Field | Value Type | Optional? | Description of Value | +========================+============+===========+====================================================+ -| old_active_pol_name | string | No | The policy_name field of the old active policy. | +| old_active_pol_name | string | No | The name of previous active policy | +------------------------+------------+-----------+----------------------------------------------------+ -| old_active_pol_version | string | No | The policy_version field of the old active policy. | +| old_active_pol_version | string | No | The version of previous active policy | +------------------------+------------+-----------+----------------------------------------------------+ -| old_sha256 | string | Yes* | A flat hash of the old active policy. | +| old_sha256 | string | Yes* | The hash of previous active policy | +------------------------+------------+-----------+----------------------------------------------------+ -| new_active_pol_name | string | No | The policy_name field of the new active policy. | +| new_active_pol_name | string | No | The name of current active policy | +------------------------+------------+-----------+----------------------------------------------------+ -| new_active_pol_version | string | No | The policy_version field of the new active policy. | +| new_active_pol_version | string | No | The version of current active policy | +------------------------+------------+-----------+----------------------------------------------------+ -| new_sha256 | string | Yes* | A flat hash of the new active policy. | +| new_sha256 | string | Yes* | The hash of current active policy | +------------------------+------------+-----------+----------------------------------------------------+ | auid | integer | No | The audit user ID. | +------------------------+------------+-----------+----------------------------------------------------+
@@ -415,19 +418,19 @@ Event Examples:: This record will always be emitted in conjunction with a ``AUDITSYSCALL`` record for the ``write`` syscall. -+------------+------------+-----------+-------------------------------------------------------------------+ -| Field | Value Type | Optional? | Description of Value | -+============+============+===========+===================================================================+ -| permissive | integer | No | The state IPE is being switched to. 1 is permissive, 0 is enforce | -+------------+------------+-----------+-------------------------------------------------------------------+ -| auid | integer | No | The audit user ID. | -+------------+------------+-----------+-------------------------------------------------------------------+ -| ses | integer | No | The session ID. | -+------------+------------+-----------+-------------------------------------------------------------------+ -| lsm | string | No | The lsm name associated with the event. | -+------------+------------+-----------+-------------------------------------------------------------------+ -| res | integer | No | The operation result. | -+------------+------------+-----------+-------------------------------------------------------------------+ ++------------+------------+-----------+-------------------------------------------------------------------------------------+ +| Field | Value Type | Optional? | Description of Value | ++============+============+===========+=====================================================================================+ +| permissive | integer | No | The state IPE is being switched to. 1 is in permissive mode; 0 is in enforced mode. | ++------------+------------+-----------+-------------------------------------------------------------------------------------+ +| auid | integer | No | The audit user ID. | ++------------+------------+-----------+-------------------------------------------------------------------------------------+ +| ses | integer | No | The session ID. | ++------------+------------+-----------+-------------------------------------------------------------------------------------+ +| lsm | string | No | The lsm name associated with the event. | ++------------+------------+-----------+-------------------------------------------------------------------------------------+ +| res | integer | No | The operation result. | ++------------+------------+-----------+-------------------------------------------------------------------------------------+ Success Auditing ^^^^^^^^^^^^^^^^
@@ -435,8 +438,8 @@ Success Auditing IPE supports success auditing. When enabled, all events that pass IPE policy and are not blocked will emit an audit event. This is disabled by default, and can be enabled via the kernel command line -``ipe.success_audit=(0|1)`` or the securityfs node, -``/sys/kernel/security/ipe/success_audit``. +``ipe.success_audit=(0|1)`` or +``/sys/kernel/security/ipe/success_audit`` securityfs file. This is *very* noisy, as IPE will check every userspace binary on the system, but is useful for debugging policies.
@@ -538,9 +541,9 @@ dmverity_roothash This property can be utilized for authorization or revocation of specific dm-verity volumes, identified via root hash. It has a - dependency on the DM_VERITY module. This property is controlled by the - Kconfig ``CONFIG_IPE_PROP_DM_VERITY``. The format of this property - is:: + dependency on the DM_VERITY module. This property is controlled by + the ``CONFIG_IPE_PROP_DM_VERITY`` config option. The format of this + property is:: dmverity_roothash=DigestName:HexadecimalString
@@ -564,11 +567,11 @@ dmverity_roothash dmverity_signature ~~~~~~~~~~~~~~~~~~ - This property can be utilized for authorization of all dm-verity volumes - that have a signed roothash that chains to a keyring specified by dm-verity's - configuration, either the system trusted keyring, or the secondary keyring. - It has an additional dependency on the ``DM_VERITY_VERIFY_ROOTHASH_SIG`` - Kconfig. This property is controlled by the Kconfig + This property can be utilized for authorization of all dm-verity + volumes that have a signed roothash that chains to a keyring + specified by dm-verity's configuration, either the system trusted + keyring, or the secondary keyring. It depends on + ``DM_VERITY_VERIFY_ROOTHASH_SIG`` config option and is controlled by ``CONFIG_IPE_PROP_DM_VERITY``. The format of this property is:: dmverity_signature=(TRUE|FALSE)
@@ -578,9 +581,8 @@ fsverity_digest This property can be utilized for authorization or revocation of specific fsverity enabled file, identified via its fsverity digest. - It has a dependency on the FS_VERITY module. This property is - controlled by the Kconfig ``CONFIG_IPE_PROP_FS_VERITY``. - The format of this property is:: + It depends on ``FS_VERITY`` config option and is controlled by + ``CONFIG_IPE_PROP_FS_VERITY``. The format of this property is:: fsverity_digest=DigestName:HexadecimalString
@@ -594,12 +596,13 @@ fsverity_signature Version 1 - This property can be utilized for authorization of all fsverity enabled - files that is verified by fsverity. The keyring that the signature is - verified against is subject to fsverity's configuration, typically the fsverity - keyring. It has a dependency on the ``CONFIG_FS_VERITY_BUILTIN_SIGNATURES`` - Kconfig. This property is controlled by the Kconfig - ``CONFIG_IPE_PROP_FS_VERITY``. The format of this property is:: + This property can be utilized for authorization of all fsverity + enabled files that is verified by fsverity. The keyring that the + signature is verified against is subject to fsverity's configuration, + typically the fsverity keyring. It depends on + ``CONFIG_FS_VERITY_BUILTIN_SIGNATURES`` is controlled controlled by + the Kconfig ``CONFIG_IPE_PROP_FS_VERITY``. The format of this + property is:: fsverity_signature=(TRUE|FALSE)
@@ -704,7 +707,7 @@ A: Loadpin and IPE differ fairly dramatically, as Loadpin controls only the IPE equivalent of ``KERNEL_READ``, whereas IPE is capable of controlling execution, on top of ``KERNEL_READ``. The trust model is also different; Loadpin roots its - trust in the initial super-block, instead, IPE roots its trust in the kernel + trust in the initial super-block, whereas trust in IPE is stemmed from kernel itself (via ``SYSTEM_TRUSTED_KEYS``). -----------
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Re: [RFC PATCH v9 16/16] documentation: add ipe documentation
Quoted 3 lines · Bagas Sanjaya
On Mon, Jan 30, 2023 at 02:57:31PM -0800, Fan Wu wrote:
What about wordings below instead?
Thanks for the review!
Documentation/admin-guide/LSM/ipe.rst This example will allow any execution. Additional properties are used to · line 159
Quoted 5 lines
Documentation/admin-guide/LSM/ipe.rst +2
-2-IPE policy supports comments. The character '#' will function as a -comment, ignoring all characters to the right of '#' until the newline. +IPE policy supports comments. Any line which is prefixed with ``#`` will +be ignored.
This one is actually incorrect. The '#' can also appear at the end of a rule. So it is not only prefixed to a line.
Other than this part, everything looks great, I will take them in the next version.
-Fan
Quoted 7 lines
-----------
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 273 lines · Fan Wu
Overview:
---------IPE is a Linux Security Module which takes a complimentary approach to access control. Whereas existing mandatory access control mechanisms base their decisions on labels and paths, IPE instead determines whether or not an operation should be allowed based on immutable security properties of the system component the operation is being performed on.
IPE itself does not mandate how the security property should be evaluated, but relies on an extensible set of external property providers to evaluate the component. IPE makes its decision based on reference values for the selected properties, specified in the IPE policy.
The reference values represent the value that the policy writer and the local system administrator (based on the policy signature) trust for the system to accomplish the desired tasks.
One such provider is for example dm-verity, which is able to represent the integrity property of a partition (its immutable state) with a digest.
IPE is compiled under
CONFIG_SECURITY_IPE.Use Cases
---------IPE works best in fixed-function devices: Devices in which their purpose is clearly defined and not supposed to be changed (e.g. network firewall device in a data center, an IoT device, etcetera), where all software and configuration is built and provisioned by the system owner.
IPE is a long-way off for use in general-purpose computing: the Linux community as a whole tends to follow a decentralized trust model, known as the web of trust, which IPE has no support for as of yet. There are exceptions, such as the case where a Linux distribution vendor trusts only their own keys, where IPE can successfully be used to enforce the trust requirement.
Additionally, while most packages are signed today, the files inside the packages (for instance, the executables), tend to be unsigned. This makes it difficult to utilize IPE in systems where a package manager is expected to be functional, without major changes to the package manager and ecosystem behind it.
DIGLIM[1] is a system that when combined with IPE, could be used to enable general purpose computing scenarios.
Policy:
-------IPE policy is a plain-text policy composed of multiple statements over several lines. There is one required line, at the top of the policy, indicating the policy name, and the policy version, for instance:
policy_name=Ex_Policy policy_version=0.0.0
The policy version indicates the current version of the policy. This is used to prevent roll-back of policy to potentially insecure previous versions of the policy.
The next portion of IPE policy, are rules. Rules are formed by key=value pairs, known as properties. IPE rules require two keys: "action", which determines what IPE does when it encounters a match against the policy and "op", which determines when that rule should be evaluated.
Thus, a minimal rule is:
op=EXECUTE action=ALLOW
This example rule will allow any execution. A rule is required to have the "op" property as the first token of a rule, and the "action" as the last token of the rule.
Additional properties are used to restrict attributes about the files being evaluated. These properties are intended to be deterministic attributes that are resident in the kernel.
For example:
op=EXECUTE dmverity_signature=FALSE action=DENY
This rule with property
dmverity_signaturewill deny any file not from a signed dmverity volume to be executed.All available properties for IPE described in the documentation patch of this series.
Rules are evaluated top-to-bottom. As a result, any revocation rules, or denies should be placed early in the file to ensure that these rules are evaluated before a rule with "action=ALLOW" is hit.
Any unknown syntax in IPE policy will result in a fatal error to parse the policy.
Additionally, a DEFAULT operation must be set for all understood operations within IPE. For policies to remain completely forwards compatible, it is recommended that users add a "DEFAULT action=ALLOW" and override the defaults on a per-operation basis.
For more information about the policy syntax, see the kernel documentation page.
Early Usermode Protection:
--------------------------IPE can be provided with a policy at startup to load and enforce. This is intended to be a minimal policy to get the system to a state where userspace is setup and ready to receive commands, at which point a policy can be deployed via securityfs. This "boot policy" can be specified via the config,
SECURITY_IPE_BOOT_POLICY, which accepts a path to a plain-text version of the IPE policy to apply. This policy will be compiled into the kernel. If not specified, IPE will be disabled until a policy is deployed and activated through the method above.Policy Examples:
----------------Allow all:
policy_name=Allow_All policy_version=0.0.0
DEFAULT action=ALLOWAllow only initial superblock:
policy_name=Allow_All_Initial_SB policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE boot_verified=TRUE action=ALLOW
Allow any signed dm-verity volume and the initial superblock:
policy_name=AllowSignedAndInitial policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE boot_verified=TRUE action=ALLOW
op=EXECUTE dmverity_signature=TRUE action=ALLOWProhibit execution from a specific dm-verity volume, while allowing all signed volumes and the initial superblock:
policy_name=ProhibitSingleVolume policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE dmverity_roothash=sha256:401fcec5944823ae12f62726e8184407a5fa9599783f030dec146938 action=DENY op=EXECUTE boot_verified=TRUE action=ALLOW
op=EXECUTE dmverity_signature=TRUE action=ALLOWAllow only a specific dm-verity volume:
policy_name=AllowSpecific policy_version=0.0.0
DEFAULT action=DENYop=EXECUTE dmverity_roothash=sha256:401fcec5944823ae12f62726e8184407a5fa9599783f030dec146938 action=ALLOW
Allow any signed fs-verity file
policy_name="AllowSignedFSVerity" policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE fsverity_signature=TRUE action=ALLOW
Deny a specific fs-verity file:
policy_name="ProhibitSpecificFSVF" policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE fsverity_digest=sha256:fd88f2b8824e197f850bf4c5109bea5cf0ee38104f710843bb72da796ba5af9e action=DENY op=EXECUTE boot_verified=TRUE action=ALLOW
op=EXECUTE dmverity_signature=TRUE action=ALLOWDeploying Policies:
-------------------First sign a plain text policy, with a certificate that is present in the
SYSTEM_TRUSTED_KEYRINGof your test machine. Through openssl, the signing can be done via:openssl smime -sign -in "$MY_POLICY" -signer "$MY_CERTIFICATE" \ -inkey "$MY_PRIVATE_KEY" -outform der -noattr -nodetach \ -out "$MY_POLICY.p7s"Then, simply cat the file into the IPE's "
new_policy" securityfs node:cat "$MY_POLICY.p7s" >
/sys/kernel/security/ipe/new_policyThe policy should now be present under the policies/ subdirectory, under its "
policy_name" attribute.The policy is now present in the kernel and can be marked as active, via the securityfs node:
echo 1 > "
/sys/kernel/security/ipe/$MY_POLICY_NAME/active"This will now mark the policy as active and the system will be enforcing $MY_POLICY_NAME.
There is one requirement when marking a policy as active, the
policy_versionattribute must either increase, or remain the same as the currently running policy.Policies can be updated via:
cat "$MY_UPDATED_POLICY.p7s" > \ "/sys/kernel/security/ipe/policies/$MY_POLICY_NAME/update"Additionally, policies can be deleted via the "delete" securityfs node. Simply write "1" to the corresponding node in the policy folder:
echo 1 > "
/sys/kernel/security/ipe/policies/$MY_POLICY_NAME/delete"There is only one requirement to delete policies, the policy being deleted must not be the active policy.
NOTE: Any securityfs write to IPE's nodes will require
CAP_MAC_ADMIN.Integrations:
-------------This patch series adds support for fsverity via digest and signature (
fsverity_signatureandfsverity_digest), dm-verity by digest and signature (dmverity_signatureanddmverity_roothash), and trust for the initramfs (boot_verified).Please see the documentation patch for more information about the integrations available.
Testing:
--------KUnit Tests are available. Recommended kunitconfig:
CONFIG_KUNIT=y
CONFIG_SECURITY=y
CONFIG_SECURITYFS=y
CONFIG_PKCS7_MESSAGE_PARSER=y
CONFIG_SYSTEM_DATA_VERIFICATION=y
CONFIG_FS_VERITY=y
CONFIG_FS_VERITY_BUILTIN_SIGNATURES=y
CONFIG_BLOCK=y
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_VERITY=y
CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG=y
CONFIG_NET=y
CONFIG_AUDIT=y
CONFIG_AUDITSYSCALL=y
CONFIG_SECURITY_IPE=y
CONFIG_IPE_PROP_DM_VERITY=y
CONFIG_IPE_PROP_FS_VERITY=y
CONFIG_SECURITY_IPE_KUNIT_TEST=ySimply run:
make ARCH=um mrproper
./tools/testing/kunit/kunit.pyrun --kunitconfig <path/to/config>And the tests will execute and report the result. For more indepth testing, it will require you to create and mount a dm-verity volume or fs-verity enabled file.
Documentation:
--------------There is both documentation available on github at
https://microsoft.github.io/ipe, and Documentation in this patch series, to be added in-tree.Known Gaps:
-----------
Quoted 8 lines
IPE has two known gaps:
1. IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. Unfortunately, as this is dynamically generated code, there is no way for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures the DEFAULT action for "EXECUTE".
I think it would be useful to handle special cases, for example you could allow a process that created a file with memfd to use it, at the condition that nobody else writes it.
This would be required during the boot, otherwise services could fail to start (depending on the policy).
Quoted 8 lines
2. IPE cannot verify the integrity of interpreted languages' programs when these scripts invoked via ``<interpreter> <file>``. This is because the way interpreters execute these files, the scripts themselves are not evaluated as executable code through one of IPE's hooks. Interpreters can be enlightened to the usage of IPE by trying to mmap a file into executable memory (+X), after opening the file and responding to the error code appropriately. This also applies to included files, or high value files, such as configuration files of critical system components.
Ok, it is a well known issue. Hopefully, it will be fixed soon.
Roberto
Quoted 254 lines
Appendix:
---------A. IPE Github Repository: https://github.com/microsoft/ipe
B. IPE Users' Guide:Documentation/admin-guide/LSM/ipe.rstReferences:
-----------1: https://lore.kernel.org/bpf/[email protected]/T/
FAQ:
----Q: What is the difference between IMA and IPE?
A: See the documentation patch for more on this topic.
Previous Postings
-----------------v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v7: https://lore.kernel.org/all/1634151995-16266-1-git-send-email-deven.desai@linux.microsoft.com/
v8: https://lore.kernel.org/all/1654714889-26728-1-git-send-email-deven.desai@linux.microsoft.com/Changelog:
----------v2:
Split the second patch of the previous series into two. Minor corrections in the cover-letter and documentation comments regardingCAP_MAC_ADMINchecks in IPE.v3:
Address various comments by Jann Horn. Highlights:
Switch various audit allocators toGFP_KERNEL. Utilizercu_access_pointer()in various locations. Strip out the caching system for properties
Strip comments from headers
Move functions around in patches
Remove kernel command line parameters
Reconcile the race condition on the delete node for policy by
expanding the policy critical section.Address a few comments by Jonathan Corbet around the documentation
pages for IPE.Fix an issue with the initialization of IPE policy with a "-0"
version, caused by not initializing the hlist entries before freeing.v4:
Address a concern around IPE's behavior with unknown syntax.
Specifically, make any unknown syntax a fatal error instead of a warning, as suggested by Mickaël Salaün.
Introduce a new securityfs node, $securityfs/ipe/property_config,
which provides a listing of what properties are enabled by the kernel and their versions. This allows usermode to predict what policies should be allowed.
Strip some comments from c files that I missed.
Clarify some documentation comments around 'boot_verified'.
While this currently does not functionally change the property itself, the distinction is important when IPE can enforce verified reads. Additionally, 'KERNEL_READ' was omitted from the documentation. This has been corrected.
Change SecurityFS and SHA1 to a reverse dependency.
Update the cover-letter with the updated behavior of unknown syntax. Remove all sysctls, making an equivalent function in securityfs. Rework the active/delete mechanism to be a node under the policy in
$securityfs/ipe/policies.
The kernel command line parameters ipe.enforce and ipe.success_audit
have returned as this functionality is no longer exposed through sysfs.v5:
Correct some grammatical errors reported by Randy Dunlap. Fix some warnings reported by kernel test bot.
Change convention aroundsecurity_bdev_setsecurity.-ENOSYS
is now expected if an LSM does not implement a particular @name, as suggested by Casey Schaufler.
Minor string corrections related to the move from sysfs to securityfs Correct a spelling of an #ifdef for the permissive argument. Add the kernel parameters re-added to the documentation. Fix a minor bug where the mode being audited on permissive switch
was the original mode, not the mode being swapped to.
Cleanup doc comments, fix some whitespace alignment issues.v6:
Change if statement condition insecurity_bdev_setsecurityto be
more concise, as suggested by Casey Schaufler and Al Viro
Drop the 6th patch in the series, "dm-verity move signature check..."
due to numerous issues, and it ultimately providing no real value.
Fix the patch tree - the previous iteration appears to have been in a
torn state (patches 8+9 were merged). This has since been corrected.v7:
* Reword cover letter to more accurate convey IPE's purpose and latest updates.
* Refactor series to:
1. Support a context structure, enabling:
1. Easier Testing via KUNIT
2. A better architecture for future designs
2. Make parser code cleaner
* Move patch 01/12 to [14/16] of the series
* Split up patch 02/12 into four parts:
1. context creation [01/16]
2. audit [07/16]
3. evaluation loop [03/16]
4. access control hooks [05/16]
5. permissive mode [08/16]
* Split up patch 03/12 into two parts:
1. parser [02/16]
2. userspace interface [04/16]
* Reword and refactor patch 04/12 to [09/16]
* Squash patch 05/12, 07/12, 09/12 to [10/16]
* Squash patch 08/12, 10/12 to [11/16]
* Change audit records to MAC region (14XX) from Integrity region (18XX)
* Add FSVerity Support
* Interface changes:
1. "raw" was renamed to "pkcs7" and made read only
2. "raw"'s write functionality (update a policy) moved to "update"
3. introduced "version", "policy_name" nodes.
4. "content" renamed to "policy"
5. The boot policy can now be updated like any other policy.
* Add additional developer-level documentation
* Update admin-guide docs to reflect changes.
* Kunit tests
* DroppedCONFIG_SECURITY_IPE_PERMISSIVE_SWITCH- functionality can easily come later with a small patch.
* Use partition0 forblock_devicefor dm-verity patchv8:
* Add changelog information to individual commits
* A large number of changes to the audit patch.
* splitfs/&security/changes to two separate patches.
* splitblock/,security/&drivers/md/changes to separate patches.
* Add some historical context to what lead to the creation of IPE in the documentation patch.
* Cover-letter changes suggested by Roberto Sassu.v9:
* Rewrite IPE parser to use kernelmatch_tableparser.
* Adapt existing IPE properties to the new parser.
* Removeipe_context, quote policy syntax,kernel_readfor simplicity.
* Add new function in the security file system to delete IPE policy.
* Make IPE audit builtin and change several audit formats.
* Makeboot_verifiedproperty builtinDeven Bowers (13):
security: add ipe lsm
ipe: add policy parser
ipe: add evaluation loop and introduce 'boot_verified' as a trust
provider
ipe: add userspace interface
ipe: add LSM hooks on execution and kernel read uapi|audit|ipe: add ipe auditing support
ipe: add permissive toggle
block|security: add LSM blob toblock_device
dm-verity: consume root hash digest and signature data via LSM hook
ipe: add support for dm-verity as a trust provider
scripts: add boot policy generation program
ipe: kunit test for parser
documentation: add ipe documentationFan Wu (3):
security: add new securityfs delete function
fsverity: consume builtin signature via LSM hook
ipe: enable support for fs-verity as a trust providerDocumentation/admin-guide/LSM/index.rst | 1 + Documentation/admin-guide/LSM/ipe.rst | 729 ++++++++++++++++++ .../admin-guide/kernel-parameters.txt | 12 + Documentation/security/index.rst | 1 + Documentation/security/ipe.rst | 436 +++++++++++ MAINTAINERS | 8 + block/bdev.c | 7 + drivers/md/dm-verity-target.c | 25 +- drivers/md/dm-verity-verify-sig.c | 16 +- drivers/md/dm-verity-verify-sig.h | 10 +- fs/verity/fsverity_private.h | 2 +- fs/verity/open.c | 13 +- fs/verity/signature.c | 1 + include/linux/blk_types.h | 3 + include/linux/dm-verity.h | 19 + include/linux/fsverity.h | 2 + include/linux/lsm_hook_defs.h | 5 + include/linux/lsm_hooks.h | 12 + include/linux/security.h | 23 + include/uapi/linux/audit.h | 1 + scripts/Makefile | 1 + scripts/ipe/Makefile | 2 + scripts/ipe/polgen/.gitignore | 1 + scripts/ipe/polgen/Makefile | 6 + scripts/ipe/polgen/polgen.c | 145 ++++ security/Kconfig | 11 +- security/Makefile | 1 + security/inode.c | 25 + security/ipe/.gitignore | 1 + security/ipe/Kconfig | 75 ++ security/ipe/Makefile | 32 + security/ipe/audit.c | 279 +++++++ security/ipe/audit.h | 19 + security/ipe/digest.c | 144 ++++ security/ipe/digest.h | 26 + security/ipe/eval.c | 424 ++++++++++ security/ipe/eval.h | 60 ++ security/ipe/fs.c | 242 ++++++ security/ipe/fs.h | 17 + security/ipe/hooks.c | 275 +++++++ security/ipe/hooks.h | 42 + security/ipe/ipe.c | 97 +++ security/ipe/ipe.h | 22 + security/ipe/policy.c | 259 +++++++ security/ipe/policy.h | 93 +++ security/ipe/policy_fs.c | 459 +++++++++++ security/ipe/policy_parser.c | 545 +++++++++++++ security/ipe/policy_parser.h | 11 + security/ipe/policy_tests.c | 294 +++++++ security/security.c | 70 ++ 50 files changed, 4988 insertions(+), 16 deletions(-) create mode 100644 Documentation/admin-guide/LSM/ipe.rst create mode 100644 Documentation/security/ipe.rst create mode 100644 include/linux/dm-verity.h create mode 100644 scripts/ipe/Makefile create mode 100644 scripts/ipe/polgen/.gitignore create mode 100644 scripts/ipe/polgen/Makefile create mode 100644 scripts/ipe/polgen/polgen.c create mode 100644 security/ipe/.gitignore create mode 100644 security/ipe/Kconfig create mode 100644 security/ipe/Makefile create mode 100644 security/ipe/audit.c create mode 100644 security/ipe/audit.h create mode 100644 security/ipe/digest.c create mode 100644 security/ipe/digest.h create mode 100644 security/ipe/eval.c create mode 100644 security/ipe/eval.h create mode 100644 security/ipe/fs.c create mode 100644 security/ipe/fs.h create mode 100644 security/ipe/hooks.c create mode 100644 security/ipe/hooks.h create mode 100644 security/ipe/ipe.c create mode 100644 security/ipe/ipe.h create mode 100644 security/ipe/policy.c create mode 100644 security/ipe/policy.h create mode 100644 security/ipe/policy_fs.c create mode 100644 security/ipe/policy_parser.c create mode 100644 security/ipe/policy_parser.h create mode 100644 security/ipe/policy_tests.c
Quoted 10 lines · Roberto Sassu
Quoted 8 lines · Fan Wu
IPE has two known gaps:
1. IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. Unfortunately, as this is dynamically generated code, there is no way for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures the DEFAULT action for "EXECUTE".
Quoted 7 lines
I think it would be useful to handle special cases, for example you could allow a process that created a file with memfd to use it, at the condition that nobody else writes it.
This would be required during the boot, otherwise services could fail to start (depending on the policy).
Thanks for the suggestion. I agree with your opinion and I think supporting memfd is possible but restricting read/write needs more hooks. We would like to avoid adding more complexity to this initial posting as necessary. We will consider this as a future work and will post follow-on patches in the future.
-Fan
Quoted 13 lines
Quoted 8 lines
2. IPE cannot verify the integrity of interpreted languages' programs when these scripts invoked via ``<interpreter> <file>``. This is because the way interpreters execute these files, the scripts themselves are not evaluated as executable code through one of IPE's hooks. Interpreters can be enlightened to the usage of IPE by trying to mmap a file into executable memory (+X), after opening the file and responding to the error code appropriately. This also applies to included files, or high value files, such as configuration files of critical system components.
Ok, it is a well known issue. Hopefully, it will be fixed soon.
Roberto
Quoted 15 lines · Fan Wu
Quoted 14 lines · Roberto Sassu
Quoted 8 lines · Fan Wu
IPE has two known gaps:
1. IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. Unfortunately, as this is dynamically generated code, there is no way for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures the DEFAULT action for "EXECUTE".
I think it would be useful to handle special cases, for example you could allow a process that created a file with memfd to use it, at the condition that nobody else writes it.
Quoted 8 lines
Quoted 3 lines
This would be required during the boot, otherwise services could fail to start (depending on the policy).
Thanks for the suggestion. I agree with your opinion and I think supporting memfd is possible but restricting read/write needs more hooks. We would like to avoid adding more complexity to this initial posting as necessary. We will consider this as a future work and will post follow-on patches in the future.
Ok, maybe it is necessary to specify better the scope of IPE, why the current implementation can be considered as complete.
If we say, IPE can only allow/deny operations on system components with immutable security properties, clearly memfd as a component cannot fullfill this goal due to the non-immutability. This would apply to any component allowing modifications.
How to address this? What is the immutable property then?
In the case of memfd, intuitively, a useful property for integrity could be for example that the content can be accessed/modified by only one process. No other (possibly malicious) processes can tamper with that file.
So, it is true, to make this property immutable more hooks are needed. But should it be something that IPE does? Or it should be done by an external component (another LSM) that does the enforcement and reports to IPE that the property is true? Theoretically (with a proper policy), existing LSMs could be used for that purpose too.
I would say more the second, it should not be IPE job, so that IPE can exclusively focus on evaluating properties, not making sure that the properties are immutable.
Roberto
Quoted 15 lines
-Fan
Quoted 13 lines
Quoted 8 lines
2. IPE cannot verify the integrity of interpreted languages' programs when these scripts invoked via ``<interpreter> <file>``. This is because the way interpreters execute these files, the scripts themselves are not evaluated as executable code through one of IPE's hooks. Interpreters can be enlightened to the usage of IPE by trying to mmap a file into executable memory (+X), after opening the file and responding to the error code appropriately. This also applies to included files, or high value files, such as configuration files of critical system components.
Ok, it is a well known issue. Hopefully, it will be fixed soon.
Roberto
Quoted 46 lines · Roberto Sassu
Quoted 15 lines · Fan Wu
Quoted 14 lines · Roberto Sassu
Quoted 8 lines · Fan Wu
IPE has two known gaps:
1. IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. Unfortunately, as this is dynamically generated code, there is no way for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures the DEFAULT action for "EXECUTE".
I think it would be useful to handle special cases, for example you could allow a process that created a file with memfd to use it, at the condition that nobody else writes it.
Quoted 8 lines
Quoted 3 lines
This would be required during the boot, otherwise services could fail to start (depending on the policy).
Thanks for the suggestion. I agree with your opinion and I think supporting memfd is possible but restricting read/write needs more hooks. We would like to avoid adding more complexity to this initial posting as necessary. We will consider this as a future work and will post follow-on patches in the future.
Ok, maybe it is necessary to specify better the scope of IPE, why the current implementation can be considered as complete.
If we say, IPE can only allow/deny operations on system components with immutable security properties, clearly memfd as a component cannot fullfill this goal due to the non-immutability. This would apply to any component allowing modifications.
How to address this? What is the immutable property then?
In the case of memfd, intuitively, a useful property for integrity could be for example that the content can be accessed/modified by only one process. No other (possibly malicious) processes can tamper with that file.
So, it is true, to make this property immutable more hooks are needed. But should it be something that IPE does? Or it should be done by an external component (another LSM) that does the enforcement and reports to IPE that the property is true? Theoretically (with a proper policy), existing LSMs could be used for that purpose too.
Quoted 6 lines
I would say more the second, it should not be IPE job, so that IPE can exclusively focus on evaluating properties, not making sure that the properties are immutable.
Roberto
I think the issue here is not about the scope of IPE but the use cases of IPE.
We use IPE on fixed-function devices, which are completely locked down. In our system, IPE denies all anonymous memory execution so memfd will not work on our system.
Therefore, to make memfd useable with IPE we must add more properties.
-Fan