This repository was archived by the owner on Jun 1, 2026. It is now read-only.
security: CWE-409: prevent decompression bombs — VC-53739#3
Open
torresashjiancyber wants to merge 1 commit into
Open
security: CWE-409: prevent decompression bombs — VC-53739#3torresashjiancyber wants to merge 1 commit into
torresashjiancyber wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enforce a 64 MiB decompression limit for OpenPGP Compressed Data Packets to prevent decompression bomb attacks (CWE-409).
Finding
CWE-409: Improper Handling of Highly Compressed Data
CVSS 4.0: 5.1 (AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N)
pgpdump processes OpenPGP Compressed Data Packets (tag 8) without enforcing a decompression size limit. An attacker can supply a small compressed input that expands to gigabytes of output (e.g., 1 KB → 1 GB compression ratio), causing the process to exhaust available memory (decompression bomb / zip bomb).
The vulnerability exists in both zlib (DEFLATE) and bzip2 decompression paths:
inflate_gzip()in buffer.c (lines 222-261)inflate_bzip2()in buffer.c (lines 265-306)Neither function tracked total decompressed bytes or enforced a maximum output size.
Remediation
Added decompression bomb protection to buffer.c:
MAX_DECOMPRESS_SIZEconstant set to 64 MiB (67,108,864 bytes)total_decompressedcounter to track cumulative decompressed outputCompressed_Data_Packet()inflate_gzip()andinflate_bzip2()after each decompression chunkThe fix is minimal and focused:
Verification
Files changed: buffer.c
Diff: 1 file changed, 22 insertions(+), 3 deletions(-)