Skip to main content

Impact & Risk Analysis

  • Severity: Medium
  • CIS Benchmark: CIS 4.7
  • Impact: Stale Package Cache. Adding update instructions (like apt-get update) in a single line causes the update layer to be cached. If you build the image later, Docker reuses this cached layer, meaning your package lists are not refreshed. This can prevent fresh security updates from being applied or cause build failures if the referenced package version no longer exists in the repository.

Common Misconfiguration

Using OS package manager update instructions (such as apt-get update or yum update) alone or in a distinct RUN instruction separate from the installation command.

Vulnerable Example

Secure Example

Audit Procedure

Step 1: Run the command below to get the list of images:
Step 2: Run the command below against each image in the list above, looking for any update instructions which are incorporated in a single line:
Alternatively, if you have access to the Dockerfile for the image, verify that there are no update instructions configured alone or in a single line.

Remediation

You should use update instructions together with install instructions and version pinning for packages while installing them. This will prevent caching and force the extraction of the required versions. Alternatively, you could use the --no-cache flag during the docker build process to avoid using cached layers: