Integrity Measurement Architecture (IMA) is the Linux kernel subsystem that calculates cryptographic hashes of files before they are executed, memory-mapped or read, and then records, verifies or audits those measurements according to a policy. In Linux security, IMA provides file-level runtime integrity: it extends the chain of trust that starts with measured or secure boot into user space, so that a system can prove, or enforce, that only expected code and configuration were loaded.
IMA has been part of the mainline kernel since version 2.6.30 and works together with the Extended Verification Module (EVM), the Trusted Platform Module (TPM) and the kernel keyrings. It is not a mandatory access control system such as SELinux or AppArmor; it answers a different question, namely whether a file is exactly what it should be, not who may access it.
How IMA measures and verifies files
IMA works through kernel hooks placed on file operations such as execve, mmap with execute permission, kernel module loading and firmware loading. When a hooked operation matches a rule in the IMA policy, the kernel reads the file, computes a digest (typically SHA-256) and caches the result in the inode until the file changes.
What happens with the digest depends on the action named by the matching policy rule. IMA supports four distinct functions, which can be combined, and each one serves a different security goal.
| Function | Policy action | What it does | Typical goal |
|---|---|---|---|
| IMA-Measurement | measure | Records the file hash in a measurement list and extends a TPM PCR | Remote attestation |
| IMA-Appraisal | appraise | Compares the hash or signature with the security.ima extended attribute | Local enforcement |
| IMA-Audit | audit | Writes file hashes to the system audit log | Forensics and logging |
| IMA-Hash | hash | Stores a fresh file hash in security.ima | Labeling a file system |
Measurement results appear in the runtime measurement list under /sys/kernel/security/ima/ascii_runtime_measurements. Each entry is also extended into PCR 10 of the TPM, so the list cannot be silently edited: a verifier recomputes the PCR value from the list and compares it with a signed TPM quote.
IMA policy, templates and signatures
The IMA policy decides which files are measured or appraised. Built-in policies are selected with the ima_policy= boot parameter (for example tcb, appraise_tcb or secure_boot), and a custom policy can be written to /sys/kernel/security/ima/policy once, typically from the initramfs. Rules match on hook, file owner, file system magic, LSM label and other attributes.
Templates define what each measurement record contains. The choice matters for attestation, because the verifier must parse the same fields the kernel produces.
| Template | Fields recorded | Use case |
|---|---|---|
ima | SHA-1 digest and file name (legacy) | Old systems only |
ima-ng | Digest with algorithm name and file name | Default modern measurement |
ima-sig | Digest, file name and file signature | Attestation of signed files |
ima-buf | Digest and raw buffer data | Measuring kernel command line or keys |
For appraisal, the security.ima attribute holds either a plain hash or a digital signature. Signatures are created with evmctl and verified against keys loaded into the .ima keyring, which in hardened setups accepts only keys signed by a built-in or machine owner key. File signatures are far stronger than hashes, because an attacker with root access can recompute a hash but cannot forge a signature without the private key.
IMA compared with related Linux integrity mechanisms
IMA is one of several integrity tools in Linux, and each covers a different layer. Confusing them leads to gaps, such as assuming that a signed root file system also protects writable configuration files.
| Mechanism | Protection scope | When it checks | Main limitation |
|---|---|---|---|
| IMA | Individual files chosen by policy | At access time, in the kernel | Policy design is complex |
| EVM | File metadata and extended attributes | At access time, with IMA | Needs a trusted key or HMAC secret |
| dm-verity | Entire read-only block device | On every block read | Does not suit writable data |
| AIDE | Files listed in a database | Periodic scan in user space | Detects changes only after the fact |
| Secure Boot | Boot loader and kernel image | Before the kernel starts | Ends where user space begins |
The key distinction is enforcement at access time. AIDE or OpenSCAP can report a modified binary hours later, whereas IMA appraisal prevents the modified binary from running at all. Kernel lockdown and Linux Security Modules complement IMA by restricting what root can do to bypass it.
Deploying IMA in practice
A sound deployment begins in measurement-only mode, moves to appraisal in fix mode to label files, and only then switches to enforcing appraisal. Skipping these stages is the most common reason for systems that fail to boot.
- Boot with
ima_policy=tcband review the measurement list to learn what the system actually loads. - Sign packages or files with
evmctl ima_sign, or install distribution packages that ship IMA signatures in RPM headers. - Use
ima_appraise=fixtemporarily to write missingsecurity.imaattributes. - Load a custom policy and the verification keys from the initramfs, then boot with
ima_appraise=enforce. - Connect the measurement list to a remote attestation service such as Keylime for continuous verification.
The following decision table summarizes which configuration fits common goals.
| Goal | Recommended setup | Reason |
|---|---|---|
| Prove system state to a remote verifier | Measurement with ima-sig and a TPM | PCR 10 makes the log tamper-evident |
| Block unsigned executables locally | Signature appraisal in enforce mode | Unsigned code fails with an error |
| Detect changes on mutable files | Hash appraisal protected by EVM | Hashes alone can be rewritten by root |
| Gather evidence for incident response | IMA-Audit with auditd | Hashes appear in the audit trail |
Limitations and common mistakes with IMA
IMA is powerful but narrow, and its guarantees hold only within clear limits. Practitioners should understand these failure modes before relying on it.
- Interpreted scripts pass through
read, notexecve, so a policy that measures only executables misses Python or shell code unless interpreters cooperate. - Hash-only appraisal without EVM gives little protection against a root attacker, who can rewrite both the file and its attribute.
- Performance overhead is usually small after caching, but the first access of large files and frequent rewrites of measured files add latency.
- Measurement lists grow with every new file, which complicates attestation on long-running hosts.
- Package updates break appraisal unless every updated file arrives with a valid signature.
A frequent misconception is that IMA detects attacks in memory. It does not: IMA checks files at load time, so exploits that inject code into a running process are outside its scope and need controls such as Seccomp, Landlock or exploit mitigations.
Understanding it simply
IMA works like a checkpoint guard who checks a fingerprint of every program before it is allowed to run. The kernel calculates a unique fingerprint of the file and compares it with the one that the trusted publisher signed.
If the fingerprints match, the program runs. If someone has changed even one byte, the guard notices and can refuse to start the program or write the event into a tamper-proof logbook. That logbook can later be shown to another computer to prove that the machine is still running only approved software.
Applied in practice
A utility company runs about 200 Linux gateways in remote substations. Its security team enables IMA with a policy that appraises every executable, kernel module and file in /etc, signs all software in the build pipeline with a dedicated key and loads only that key into the .ima keyring. The gateways also send their measurement lists and TPM quotes to a central Keylime verifier every few minutes.
During a maintenance visit, a contractor copies an unsigned diagnostic tool onto one gateway and tries to run it. The kernel denies execution with a permission error, and the verifier flags the attempt through the audit record. The team investigates within the hour, confirms that no production binary changed, and approves a signed version of the tool through the normal pipeline. The outcome is verifiable integrity across the whole fleet without a manual file scan.