fix(iperf3): bound the results JSON_read to reject an oversized length - #44
Merged
Merged
Conversation
get_results passed 0 as max_size, so a server SERVER_ERROR byte misread as a length went straight to calloc instead of being rejected, masking the real server-side error as ENOMEM on the client. Fixes #43 Signed-off-by: Pau Capdevila <pau@githedgehog.com>
|
🚀 Temp artifacts published: |
There was a problem hiding this comment.
Pull request overview
Bounds iperf3’s client-side results JSON read during image build to prevent a corrupted/aborted control-channel exchange from being interpreted as a multi‑GiB JSON length and triggering misleading ENOMEM errors.
Changes:
- Patch iperf3 3.21 at build time to call
JSON_read(test->ctrl_sck, 1024 * 1024)instead of unboundedJSON_read(..., 0)for results. - Add a build-time grep guard to ensure the sed-based patch is applied (or fail loudly if upstream changes).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
|
@pau-hedgehog is there a fix or bug in upstream? If not we should file and contribute |
Frostman
approved these changes
Aug 31, 2026
This was referenced Aug 31, 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.
get_results in iperf3's src/iperf_api.c passed 0 as max_size to JSON_read, disabling its size check. A server abort mid-results-exchange writes the control-channel SERVER_ERROR state byte, 0xFE, which a client already blocked in get_results misreads as the high byte of a length, exactly 0xFE000000 (3.97 GiB). On the ~700 MB VMs fabricator's release-test runs on, that calloc is refused and the client reports Cannot allocate memory instead of the server's real error, discussed in detail in #43 and githedgehog/fabricator#1746.
This patches the get_results call site to pass a 1 MiB bound, the same treatment the params-read call site a few hundred lines earlier in the same file already gets with MAX_PARAMS_JSON_STRING (8 KB). 1 MiB comfortably covers a results JSON for iperf3's max of 128 streams while staying far below the corrupted 0xFE000000 length, so it rejects the corruption without risking a legitimate result. The sed is anchored to the exact current line and followed by a grep -q that fails the build if it doesn't match, so a future upstream bump either carries the patch or breaks the build loudly instead of silently reverting to unbounded.
Validation:
docker build --target builder) and confirmed the grep guard passes, meaning the sed matched.Fixes #43