Skip to content

Directory accepts mailbox payloads it can't return: gateway truncates responses over ~8 KiB #1982

Closed

Description

@caarloshenriq

Is there an existing issue for this?

  • I have searched the existing issues

Which crate is this issue for?

payjoin-mailroom

How did you obtain this crate?

Compiled from source

Features

No response

What version of the selected crate are you using?

payjoin-mailroom-0.1.3 master @ 6a6a28d

Current behavior

post_mailbox accepts bodies up to V1_MAX_BUFFER_SIZE (65536 bytes), but handle_ohttp_gateway pads/cuts every bhttp response to BHTTP_REQ_BYTES (8144) with bhttp_bytes.resize(BHTTP_REQ_BYTES, 0) (payjoin-mailroom/src/directory.rs).

When a stored payload doesn't fit, the directory answers 200 with an OHTTP response that decrypts fine but holds a truncated bhttp message, so the client fails to parse it (a field was truncated) instead of getting a clean error.

This also affects V1 fallback: the V1 request ({psbt}\n{query}) reaches the receiver through the same GET, so a V1 original PSBT over ~8 KB in base64 can never be read by the receiver.

Expected behavior

The directory shouldn't store what it can't hand back: reject mailbox payloads (and V1 requests) whose response wouldn't fit, and never truncate a response.

Steps to reproduce

  1. Through the OHTTP gateway, POST /{mailbox_id} with a 65536-byte body. The directory answers 200.
  2. Through the gateway, GET /{mailbox_id}.
  3. Decapsulate the response and parse it as bhttp: it fails because the content was cut at 8144 bytes.

Relevant log output

No response

Operating system and version

MacOS Tahoe Version:26.5.1

Activity

  1. added
    bug
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions