---
title: "Scan every image before it ships · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/image-scanning
id: ENG-70
level: Required
applies: servers
risk: takeover
updated: 2026-10-27
build: a2a6bdfed830
tokens: 847
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Scan every image before it ships

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: ENG-70
- Level: Required
- Chapter: [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md)
- Rule: Scan each built image for known holes in CI, and fail the build on high or critical ones that have a fix.
- Check: Build an image from an old base with a known fixed hole on a branch. The scan step fails and names it.
- Risk: An account or system taken over
- Applies when: The project runs its own servers, virtual machines or containers.
- How: Run a scanner such as Trivy, Grype or Docker Scout against the final image, not only the source. Update the base digest or the package that the scanner names. Publish a bill of materials as the [provenance rule](https://agentwranglers.se/playbook/application-security/supply-chain/sbom-and-provenance.md) describes. Pin the scanner itself by digest, as [Use Trivy to scan images and dependencies](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/trivy.md) explains after its 2026 compromise.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Shell example

```sh
trivy image --exit-code 1 --severity HIGH,CRITICAL --ignore-unfixed shop:latest
```

## Sources

- [NIST SP 800-190 Application Container Security Guide](https://csrc.nist.gov/pubs/sp/800/190/final)

## Related rules

- ENG-68 [Pin each base image by digest](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/pinned-base-images.md) in Engineering
- APS-75 [Publish what is in each release](https://agentwranglers.se/playbook/application-security/supply-chain/sbom-and-provenance.md) in Application security
- STK-61 [Use Trivy to scan images and dependencies](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/trivy.md) in Software choices
- INF-84 [Rescan the images that are running every day](https://agentwranglers.se/playbook/infrastructure/containers-and-orchestration/rescan-running-images.md) in Infrastructure and environments
- MED-14 [Run media tools in a sandbox with no network](https://agentwranglers.se/playbook/files-and-media/video-and-audio/media-tool-sandbox.md) in Files and media

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/image-scanning">Agent Wranglers engineering playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Pass build secrets as mounts instead of layers](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/build-secrets.md)
- Next: [Block pushes that contain secrets](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/secret-push-protection.md)
- [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md)
