Integrity Measurement Architecture

Also known as: IMA

On this page 7

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.

FunctionPolicy actionWhat it doesTypical goal
IMA-MeasurementmeasureRecords the file hash in a measurement list and extends a TPM PCRRemote attestation
IMA-AppraisalappraiseCompares the hash or signature with the security.ima extended attributeLocal enforcement
IMA-AuditauditWrites file hashes to the system audit logForensics and logging
IMA-HashhashStores a fresh file hash in security.imaLabeling a file system
The four IMA functions

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.

TemplateFields recordedUse case
imaSHA-1 digest and file name (legacy)Old systems only
ima-ngDigest with algorithm name and file nameDefault modern measurement
ima-sigDigest, file name and file signatureAttestation of signed files
ima-bufDigest and raw buffer dataMeasuring kernel command line or keys
Common IMA measurement templates

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 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.

MechanismProtection scopeWhen it checksMain limitation
IMAIndividual files chosen by policyAt access time, in the kernelPolicy design is complex
EVMFile metadata and extended attributesAt access time, with IMANeeds a trusted key or HMAC secret
dm-verityEntire read-only block deviceOn every block readDoes not suit writable data
AIDEFiles listed in a databasePeriodic scan in user spaceDetects changes only after the fact
Secure BootBoot loader and kernel imageBefore the kernel startsEnds where user space begins
IMA and neighboring integrity tools

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.

  1. Boot with ima_policy=tcb and review the measurement list to learn what the system actually loads.
  2. Sign packages or files with evmctl ima_sign, or install distribution packages that ship IMA signatures in RPM headers.
  3. Use ima_appraise=fix temporarily to write missing security.ima attributes.
  4. Load a custom policy and the verification keys from the initramfs, then boot with ima_appraise=enforce.
  5. 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.

GoalRecommended setupReason
Prove system state to a remote verifierMeasurement with ima-sig and a TPMPCR 10 makes the log tamper-evident
Block unsigned executables locallySignature appraisal in enforce modeUnsigned code fails with an error
Detect changes on mutable filesHash appraisal protected by EVMHashes alone can be rewritten by root
Gather evidence for incident responseIMA-Audit with auditdHashes appear in the audit trail
Choosing an IMA configuration

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, not execve, 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.