Container image diffing is the process of comparing two container images to identify what changed between them. Practitioners use it to inspect added, removed or modified files, layers and metadata, often during build, release or security review. It helps spot unexpected changes in software supply chains.
How container image diffing works
Container image diffing compares two images at the layer, file and metadata level so teams can see what changed between builds or releases. That makes it easier to separate intended updates from accidental drift, and to spot when a new layer introduces something that should not be present in a production image.
The comparison is usually more useful when it is anchored to a known baseline, such as a previous signed release, a golden image or a trusted digest. Without that reference, a diff can still show change, but it cannot tell you whether the new state is better, riskier or simply different.
What diffing reveals in practice
Good diffing is not just a file listing. It can expose added binaries, removed configuration, changed package metadata, modified entrypoints, new environment values and layer-level artifacts left behind by the build process. Those details matter because container images often carry more than application code, including runtime dependencies and build-time traces.
Diffing also helps reveal whether an image was rebuilt cleanly or modified in a way that bypassed the expected pipeline. When paired with image provenance and signing checks, it can show whether the image you are reviewing still matches the artifact that was approved, rather than a similarly named tag that now points elsewhere.
For teams standardising container hardening, the most valuable diffs are the ones that explain why an image became larger, more permissive or more exposed, not just which bytes changed. A narrow, well-understood delta is easier to review than a broad one filled with packaging noise or inherited layers.
Why image diffs matter for software supply chains
Container image diffing is especially important in supply-chain review because an image is often the final packaged outcome of code, dependencies, scripts and build tooling. A small change in the Dockerfile or base image can have a large effect on runtime behaviour, attack surface and trust.
Diffing helps detect unexpected additions such as shells, package managers, debugging tools, copied credentials or altered startup files. It also supports review of base-image refreshes, where an apparently routine update can silently change libraries, certificates or operating assumptions. In this sense, diffing is a practical control for understanding whether a release still reflects the intended build path. Where organisations need a formal baseline for container image risk, NIST SP 800-190 Container Security gives the broader container security context for image, registry, orchestrator and runtime controls.
Diffing is also valuable when release integrity matters more than content alone. If the image changed outside the expected pipeline, the diff can be the first clue that the artifact was rebuilt, repackaged or tampered with after approval.
Interpreting a diff without false confidence
A container image diff shows change, not intent. A harmless package update, a needed certificate refresh and a malicious implant can all create visible differences. The practical challenge is to distinguish expected change from suspicious change by comparing the diff with the build record, source change, provenance data and deployment context.
That is why diffing works best as part of a review chain rather than as a standalone signal. The same output can support release engineering, incident review and security validation, but only if teams know what baseline they are comparing against and who is responsible for approving the delta.
For that reason, many teams use diffing alongside image signing, registry policy and vulnerability review. If the diff reveals a change that cannot be explained by the release ticket or build logs, the image should be treated as untrusted until the discrepancy is resolved.
Risk and Threat Considerations
Container image diffing becomes important when attackers, compromised build systems or sloppy release processes introduce changes that are hard to see from the outside. An image can still start successfully while carrying unexpected tools, altered startup logic or embedded secrets, so the main risk is not visual obscurity but false trust in a familiar tag or name.
Failure mechanism: A malicious or accidental change lands in the final image through a rebuild, repackaging step, base-image swap or registry overwrite, and reviewers rely on the label rather than the artifact contents.
Impact: The altered image may expose credentials, weaken runtime security, enable persistence or create a supply-chain foothold that survives into production deployments.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-190, SLSA and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-190 | Container image, registry, orchestrator and runtime security | Defines the container security context in which image drift and tampering are reviewed. |
| Recommendation — Use container security controls to compare image changes against trusted baselines and approved build paths. | ||
| SLSA | Build provenance and software supply-chain integrity | Image diffing supports release integrity checks and provenance review for built artifacts. |
| Recommendation — Require provenance evidence so image deltas can be explained against a trusted build chain. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Supports secure release validation and review of changed software artifacts before deployment. |
| Recommendation — Review container image changes as part of secure release validation before deployment. | ||
Practitioner Guidance
Why practitioners should care: Use image diffing at release time, not only after incidents, so you can explain why an artifact changed before it reaches runtime. Pair the diff with provenance, signing and registry controls so the review covers both content and trust.
What to watch for: Pay close attention to new shells, package managers, startup scripts, certificate stores, environment values and any file that looks out of place for the image’s stated purpose. When the diff is unexpectedly broad, treat that as a review failure, not a cosmetic issue.
Practitioner takeaway: The most useful diffs are the ones that can be reconciled with a known build path; if you cannot explain the delta, do not assume the image is safe just because it is recognizable.
Related resources from NHI Mgmt Group
- Guide: Container Image Security Guide
- Why do image scanners miss some container supply chain attacks?
- What is the difference between static image security and runtime container security?
- Why do container pipelines create security risk beyond the image itself?
- What breaks when security fixes require a new container image every time?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org