Skip to content

Harden mailroom against metadata side channels #1421

@DanGould

Description

@DanGould

Summary

Three changes to reduce metadata the directory operator can observe about payjoin sessions. None require protocol changes.

1. Unify mailbox TTL to a single value

Problem: Read mailboxes expire in 10 minutes (DEFAULT_READ_TTL), unread in 7 days (DEFAULT_UNREAD_TTL_BELOW_CAPACITY). An operator can stat mailbox files on disk: if a file disappears quickly, the receiver is online. The 70x gap makes this obvious.

Fix: Replace the three TTL constants in files.rs:24-30 with a single DEFAULT_TTL of 24 hours. Remove the read/unread distinction in pruning logic (files.rs:509-510). Prune all mailboxes based on creation time only.

Why 24 hours: Matches the default receiver session lifetime (TWENTY_FOUR_HOURS_DEFAULT_EXPIRATION in payjoin/src/core/receive/v2/mod.rs:70). A mailbox that outlives its session serves no purpose.

Why one config, not two: The privacy issue is the gap between read and unread TTLs. Two separate configs can drift apart and reintroduce the gap. One value eliminates this by construction.

Capacity-based eviction can still apply as a storage pressure mechanism, but should not depend on read status.

2. Normalize V1 metric paths

Problem: middleware.rs:42 records the full URL path as a metric label. V2 requests all share /.well-known/ohttp-gateway, but V1 requests use /{shortid}, so every unique mailbox ID becomes a permanent label in the metrics backend. This copies per-session identifiers into a system with no TTL, surviving the in-memory take() cleanup.

Fix: Before recording metrics, replace V1 paths with a fictional static label like /v1. All V1 requests share one counter. Individual ShortIds stay out of the observability pipeline.

Context

Found during adversarial analysis of the relay/directory trust model. Both are low-severity on their own (the directory doesn't know who owns a mailbox in V2), but they compound with other information sources and violate the data minimization intent of the existing code. Easy fixes imo for someone to just pick up based on this script.

Disclosure: co-authored by Claude

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueDoes NOT mean "an LLM can do this." Please discuss the constraints and intended approach.payjoin-mailroom

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions