Fix decompression bomb vulnerability via expanded size field#21
Merged
Fix decompression bomb vulnerability via expanded size field#21
Conversation
Agent-Logs-Url: https://github.com/markmnl/fmsgd/sessions/4cb5faf0-906d-4f64-b5dc-0b5612d4eff1 Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/markmnl/fmsgd/sessions/4cb5faf0-906d-4f64-b5dc-0b5612d4eff1 Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
…ze strictly Agent-Logs-Url: https://github.com/markmnl/fmsgd/sessions/4cb5faf0-906d-4f64-b5dc-0b5612d4eff1 Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/markmnl/fmsgd/sessions/4cb5faf0-906d-4f64-b5dc-0b5612d4eff1 Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix decompression bomb vulnerability by adding expanded size support
Fix decompression bomb vulnerability via expanded size field
May 5, 2026
markmnl
approved these changes
May 6, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A compressed payload small enough to pass
MAX_SIZEwire-size checks could expand arbitrarily during decompression, bypassing size limits during hashing, storage, and quota enforcement.Changes
Protocol (SPEC.md)
[expanded size](uint32 LE, present iffzlib-deflateflag set) to message header; same field added to each attachment headerMAX_EXPANDED_SIZEimplementation variable (SHOULD equalMAX_SIZE)MAX_SIZEandMAX_EXPANDED_SIZEexpanded size; mismatch → TERMINATEReceiver (
host.go)readHeader: readsh.ExpandedSizefrom wire whenFlagDeflateset; rejects (code 4) if it exceedsMaxExpandedSizereadAttachmentHeaders: readsatt.ExpandedSizefor each compressed attachment; accumulates total expanded size (uncompressed items contribute their wire size); rejects (code 4) if total exceedsMaxExpandedSizeMaxExpandedSizevar loaded fromFMSG_MAX_EXPANDED_SIZEenv (default:MaxMessageSize)Hash validation (
defs.go)hashPayloadnow counts bytes written during decompression and returns an error if the actual decompressed size doesn't match the declaredexpandedSize— ensuring tampered or malformed payloads are rejected before storageSender (
sender.go)ExpandedSizebefore overwritingSizewith the compressed byte count, so outgoing headers are spec-compliantConfig
.env.example: addedFMSG_MAX_EXPANDED_SIZE=10240