Skip to content

gossip: tighter per-ALPN frame ceiling to bound iroh-gossip allocation (#577 M3 follow-up) #660

Closed

Description

@thiras

PR #659 ships the validation-side cap for #577 M3 (MAX_TRAILING_BYTES = 4 KiB + oversize_trailing_bytes rejection metric). That's detection-only: by the time `validate_envelope` runs, iroh-gossip has already allocated the full padded message (~up to its per-message ceiling, currently 16 MiB) and pushed it into our subscriber loop as `msg.content: Bytes`.

The deeper fix — bound the upstream allocation so it never happens — needs a size knob on the gossip subscribe path. Two options worth investigating:

  1. Patch iroh-gossip to accept a per-subscription max-message-size, or expose its existing internal cap as a tunable. (Upstream change.)
  2. Wire a Rust-side framing check before iroh-gossip allocates, if their layering allows. Probably requires a fork or PR upstream.

Context links:

Acceptance criteria

  • Gossip subscriber's per-message allocation is bounded to a deCDN-controlled value (proposal: same 4 KiB scale as `MAX_TRAILING_BYTES`, or maybe 16 KiB to leave headroom for legitimate envelope growth past the trailing-bytes cap).
  • New ADR or amendment to ADR 013 documents the per-ALPN policy and any iroh-gossip version dependency.
  • Regression test (likely needs a custom iroh-gossip fixture) that an oversized inbound gossip message is rejected at the framing layer, not at envelope validation.

🤖 Generated with Claude Code

Activity

  1. added
    kind:security
    rust
    on May 21, 2026
  2. added
    prio:high
    kind:test
    on May 21, 2026
  3. github-actions commented on May 21, 2026

    @github-actions

    🎯 Triage report

    This is a well-scoped security hardening task that follows up on PR #659's detection-only envelope cap. The core problem: iroh-gossip allocates up to its internal 16 MiB ceiling before validate_envelope can reject an oversized message, meaning a malicious peer can force large heap allocations. The fix requires either an upstream iroh-gossip API change to expose a per-subscription size knob, or a pre-allocation framing intercept (likely via fork/PR upstream).

    📊 Assessment

    Dimension Value Reasoning
    Type Task Follow-up hardening work with clear prerequisites and defined acceptance criteria
    Labels high, testing added (existing: security, technical, rust) Memory exhaustion via malicious peer is a real DoS vector; regression test is an explicit acceptance criterion
    Coding agent Needs more info The two implementation paths (upstream iroh-gossip PR vs. fork/intercept) represent a design decision that needs resolution before code can be written confidently

    🔗 Similar issues

    No distinct duplicate issues found — searches returned only this issue. Related context is in PR #659 and issue #577.

    💡 Notes and suggestions

    Implementation decision needed first: The issue offers two paths; maintainers should pick one before assigning to a coding agent:

    • Option A — upstream PR: File an iroh-gossip issue/PR to add subscribe_with_max_size(topic, peers, max_bytes: usize). Cleanest long-term; may be slow to merge.
    • Option B — local wrapper/fork: Add a size-check shim in crates/gossip/src/service.rs around the msg.content bytes immediately after receipt but before passing to the envelope validator. This doesn't prevent allocation but bounds it at the deCDN layer; a fork could intercept earlier.

    Candidate size values:

    • The issue proposes 4 KiB (same as MAX_TRAILING_BYTES) or 16 KiB with headroom. Given NodeAnnounce gossip messages are tiny (public key + addr + metadata), 4–8 KiB is defensible; 16 KiB aligns with ADR 013's existing language.

    Sub-task checklist:

    • Investigate iroh-gossip 0.98 API surface for any existing size cap knob
    • Decide: upstream PR vs. local wrapper vs. fork
    • Implement chosen approach in crates/gossip/src/service.rs
    • Add/amend ADR 013 with per-ALPN ceiling policy and iroh-gossip version dependency
    • Write regression test with custom iroh-gossip fixture for the framing-layer rejection

    Key file: crates/gossip/src/service.rs — gossip.subscribe(topic_id, Vec::new()) call site

    Generated by Agentic Triage for issue #660 · ● 1.8M · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. self-assigned this
    on May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:securitykind:testprio:highrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions