fix(streaming): reject oversized ZSTD frames instead of fatal() - #22830
Merged
stelfrag merged 3 commits intoJun 29, 2026
Conversation
…ful failure handling Handle oversized ZSTD frames gracefully by logging an error and failing the connection instead of crashing.
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Peer as Remote Peer (compressed data)
participant Decomp as stream_decompress_zstd()
participant Buffer as Output Buffer (COMPRESSION_MAX_CHUNK)
participant Logger as netdata_log_error
participant Conn as Stream Connection Manager
participant Test as unittest_stream_decompress_bomb_zstd()
participant ZSTD_Comp as ZSTD_compress()
Note over Peer,Conn: Production Flow — ZSTD Frame Handling
Peer->>Decomp: compressed data (may be bomb)
Decomp->>Buffer: decompress into fixed-size buffer
alt InBuffer still has leftover bytes after buffer full
Decomp->>Decomp: detect oversized frame
Note over Decomp,Logger: NEW: graceful handling instead of fatal()
Decomp->>Logger: netdata_log_error("…failing the connection")
Decomp-->>Conn: return 0 (error)
Conn->>Conn: tear down connection / fail stream
else No leftover (normal frame)
Decomp-->>Conn: decompressed_size
Conn->>Conn: continue streaming
end
Note over Test,Conn: Regression Test (unittest_stream_decompress_bomb_zstd())
Test->>ZSTD_Comp: compress 2MB zeros -> bomb frame
ZSTD_Comp-->>Test: compressed bomb (small)
Test->>Decomp: stream_decompress(bomb)
Decomp->>Buffer: decompress, buffer fills, data left
Decomp->>Logger: netdata_log_error (graceful)
Decomp-->>Test: return 0
Test->>Test: assert return == 0 (no crash)
Test->>ZSTD_Comp: compress "the quick brown fox..." -> normal frame
ZSTD_Comp-->>Test: compressed normal
Test->>Decomp: stream_decompress(normal)
Decomp->>Buffer: decompress, fully consumed
Decomp-->>Test: return original length
Test->>Test: assert data matches original
stelfrag
marked this pull request as ready for review
June 23, 2026 07:13
thiagoftsm
approved these changes
Jun 23, 2026
thiagoftsm
left a comment
Contributor
There was a problem hiding this comment.
Replication and streaming are working as expected. LGTM!
|
stelfrag
added a commit
to stelfrag/netdata
that referenced
this pull request
Jul 12, 2026
…ata#22830) * Add regression test for ZSTD decompression-bomb guard to verify graceful failure handling Handle oversized ZSTD frames gracefully by logging an error and failing the connection instead of crashing. * Fix comment to use correct constant name (COMPRESSION_MAX_MSG_SIZE) in ZSTD stream handling * Handle ZSTD compression errors by logging and returning failure gracefully
Merged
Ferroin
pushed a commit
that referenced
this pull request
Jul 15, 2026
* Add regression test for ZSTD decompression-bomb guard to verify graceful failure handling Handle oversized ZSTD frames gracefully by logging an error and failing the connection instead of crashing. * Fix comment to use correct constant name (COMPRESSION_MAX_MSG_SIZE) in ZSTD stream handling * Handle ZSTD compression errors by logging and returning failure gracefully
1 task
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.



Summary
Summary by cubic
Reject oversized ZSTD frames by logging and cleanly failing the stream instead of fatal()-ing the agent. Adds a regression test and improves ZSTD error handling.
stream_decompress_zstd, if compressed bytes remain after filling the output buffer, log withnetdata_log_errorand return 0 to drop the connection.unittest_stream_decompress_bomb_zstd()and wire it intounittest_stream_compressions()(behindENABLE_ZSTD) to verify rejection and a normal-frame round trip; fix comment to referenceCOMPRESSION_MAX_MSG_SIZE.Written for commit 25154f8. Summary will update on new commits.