Skip to content

Security review: recover corrupt caches #1382

Open
buildpacks/lifecycle-private
#16
@natalieparellano

Description

@natalieparellano

Summary

In the security review, this is LOW-2: Denial-of-Service (DoS) provoked by removing build cache tarballs or altering the OCI image manifest. The action plan asks us to ensure that

If a tarball is missing, a solution should be found by either rebuilding the corresponding tarball or wiping out the cache in order to continue the containerization process without errors, or, a second execution should be possible without errors

Further context from the initial report:

It appears that if a tarball referenced in the io.buildpacks.lifecycle.cache.metadata file is absent on the container filesystem (mounted host volume), the application containerization process quit without wiping out the cache content.


Proposal

  • See here where the restorer will fail if the cache does not contain a layer with the expected diffID:
    rc, err := cache.RetrieveLayer(sha)
  • See here where the exporter blows up if a cached layer has no contents:
    return fmt.Errorf("layer '%s' is cache=true but has no contents", fsLayer.Identifier())
    (we should keep this one?)
  • When the first error is encountered, we should wipe the cache.

Alternatively, we considered updating the cache metadata to exclude the layer/tarball that is missing. But, we are not sure if this scenario is common enough to warrant such a surgical approach.


Related

RFC #___


Context

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions