Repository navigation
Reject mailbox payloads the gateway can't return - #1983
Merged
benalleng merged 1 commit intoOct 28, 2026
Merged
Conversation
Collaborator
Coverage Report for CI Build 40742266986Coverage increased (+0.08%) to 87.547%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
caarloshenriq
force-pushed
the
mailroom-mailbox-size-limit
branch
from
October 20, 2026 20:09
d0d2a1f to
88274a2
Compare
benalleng
previously approved these changes
Oct 28, 2026
post_mailbox accepted bodies up to 64 KiB, but every gateway response is padded to BHTTP_REQ_BYTES (8144), and handle_ohttp_gateway cut longer bhttp responses off with resize(). A client reading such a mailbox got a response that decrypted fine but could not be parsed. The same applied to V1 fallback requests, which the receiver fetches through the gateway. Cap mailbox payloads at MAX_MAILBOX_PAYLOAD_BYTES, the largest payload whose 200 response still fits, answering 413 above it. Reject V1 requests that would not fit with original-psbt-rejected. Return an error from the gateway instead of truncating if a response ever exceeds the limit.
caarloshenriq
force-pushed
the
mailroom-mailbox-size-limit
branch
from
October 28, 2026 18:08
88274a2 to
2d8ced8
Compare
Contributor
Author
|
@benalleng I’ve addressed all the nits |
benalleng
approved these changes
Oct 28, 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.
Fixes #1982
post_mailboxaccepted payloads up to 64 KiB, but every gateway response is padded toBHTTP_REQ_BYTES(8144 bytes) and anything longer was silently cut byresize(), so the client got a response it couldn't parse. V1 fallback requests had the same problem, since the receiver fetches them through the gateway.Changes:
MAX_MAILBOX_PAYLOAD_BYTES, the largest payload whose200response fits in the gateway envelope (8137 bytes). Honest v2 payloads are 7168 bytes, so real clients aren't affected.post_mailboxanswers413above it.{psbt}\n{query}wouldn't fit are rejected withoriginal-psbt-rejected.Tests:
largest_mailbox_payload_round_trips_through_gateway: POST + GET of a max-size payload through a real OHTTP round trip.mailbox_payload_too_large_to_return_is_rejected: one byte over gets413.post_v1_too_large_to_relay_returns_rejectoversized_bhttp_response_is_an_error: pins the constant to the bhttp framing.The three rejection tests fail on master.
Reviewer: @benalleng
Disclosure: co-authored by Claude
Pull Request Checklist
Please confirm the following before requesting review: