Skip to content

fix: guard ReadTarEntry against decompression bombs (OOM)#2593

Open
jkutner wants to merge 1 commit into
mainfrom
fix/decompression-bomb-oom
Open

fix: guard ReadTarEntry against decompression bombs (OOM)#2593
jkutner wants to merge 1 commit into
mainfrom
fix/decompression-bomb-oom

Conversation

@jkutner
Copy link
Copy Markdown
Member

@jkutner jkutner commented May 6, 2026

Summary

  • Add maxTarEntrySize constant (4 MB) to pkg/archive/archive.go
  • ReadTarEntry now rejects entries whose declared header.Size exceeds the limit before reading any data
  • A secondary io.LimitReader + byte-count check catches malformed archives where the header size is understated
  • Two new unit tests cover both rejection paths

Motivation

A malicious or malformed buildpack image could include a tar entry (e.g. buildpack.toml / lifecycle.toml) with an arbitrarily large payload. ReadTarEntry previously called io.ReadAll with no bound, allowing a decompression bomb to exhaust heap memory. This is CVSS 3.1 score 6.5.

Test plan

  • go test ./pkg/archive/... -run TestArchive/Archive/#ReadTarEntry — all 6 cases pass
  • make build — binary builds cleanly
  • make lint — 0 issues
  • make tidy — no changes

@github-actions github-actions Bot added this to the 0.41.0 milestone May 6, 2026
@github-actions github-actions Bot added the type/enhancement Issue that requests a new feature or improvement. label May 6, 2026
@jkutner
Copy link
Copy Markdown
Member Author

jkutner commented May 7, 2026

@jjbustamante can you take a look at this? It's meant to address pack OOM via decompression bomb in buildpack descriptor read, but i'm not sure if this will cause other issues.

@jkutner jkutner marked this pull request as ready for review May 7, 2026 01:07
@jkutner jkutner requested review from a team as code owners May 7, 2026 01:07
…riptor read

Signed-off-by: Joe Kutner <jpkutner@gmail.com>
@jkutner jkutner force-pushed the fix/decompression-bomb-oom branch from f40c8b3 to feac3f5 Compare May 7, 2026 12:54
@jjbustamante
Copy link
Copy Markdown
Member

jjbustamante commented May 15, 2026

@jjbustamante can you take a look at this? It's meant to address pack OOM via decompression bomb in buildpack descriptor read, but i'm not sure if this will cause other issues.

I have issues with accessing the maintainers message (it is attached to my Broadcom email account) could you send me the Of Out Memory message? @jkutner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement Issue that requests a new feature or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants