Skip to content

Add configurable UDP connection ID validation policy #1136

Closed

Description

@josecelano

Goal

Allow operators to disable UDP connection ID validation for a specific UDP tracker listener when compatibility with non-compliant clients is more important than the anti-spoofing and replay protection provided by BEP 15 connection IDs. Strict validation remains the secure default.

Background

Some BitTorrent clients reuse expired connection IDs or otherwise do not follow BEP 15 connection ID semantics. Torrust already provides the per-listener cookie_lifetime setting to widen the valid time window, but it cannot support clients that reuse IDs indefinitely.

The original reports that motivated this issue remain relevant:

Security Constraint

An expiration-only bypass is not a safe middle ground with the current cookie design. Connection IDs use non-authenticated encryption, and the client fingerprint is mixed through wrapping arithmetic rather than a MAC. The narrow timestamp window therefore contributes to the probabilistic forgery resistance. A random or wrong-fingerprint ID can decode to a normal timestamp classified as expired, so accepting every expired result would accept more than known, previously valid cookies.

Design

  • Add a per-listener connection_id_validation enum to configuration schema v3.
  • Support strict and disabled values; omitted values default to strict.
  • Apply the policy consistently to announce and scrape requests through a shared UDP core authentication boundary.
  • Keep connect behavior unchanged: both policies continue issuing connection IDs.
  • In disabled mode, skip only connection ID validation. All other request validation, authorization, and tracker policy checks remain active.
  • In disabled mode, do not emit connection-cookie errors or increment connection-ID error metrics or IP-ban counters for the bypassed check.
  • Emit a startup warning identifying each listener with validation disabled and the reduced anti-spoofing/replay protection.
  • Do not add an expiration-only mode.
  • Add the option only to schema v3; schema v2 and consumer migration remain unchanged until final cleanup issue Configuration overhaul final cleanup: remove global re-exports, migrate consumers to explicit versioned imports #1980.

EPIC Placement

This is subissue 7 of 11 in #1978, immediately after #1453. It is not functionally dependent on #1453, but that issue establishes the related global UDP ban-cleanup boundary before this issue adds a per-listener validation policy.

Acceptance Criteria

  • Schema v3 exposes exactly strict and disabled serialized policy values.
  • Omitting the setting defaults to strict behavior.
  • Strict mode preserves existing announce, scrape, error metric, and banning behavior.
  • Disabled mode bypasses only connection ID validation for announce and scrape.
  • Connect requests continue issuing connection IDs in both modes.
  • Disabled mode produces no connection-cookie errors, connection-ID metric increments, or IP-ban increments for the bypassed check.
  • Strict and disabled listeners can run simultaneously and independently.
  • Startup logs warn for every listener with disabled validation.
  • Schema v2 behavior and public types remain unchanged.
  • Automated and manual verification evidence is recorded.

Specification

The full implementation and verification specification is maintained in docs/issues/open/1136-1978-configurable-udp-connection-id-validation-policy.md.

cc @da2ce7

Activity

  1. josecelano commented on Dec 19, 2024

    @josecelano
    MemberAuthor

    I did not remember (because it was added by @da2ce7) there is already a configuration option to increase the lifetime of the cookie:

    [[udp_trackers]]
    bind_address = "0.0.0.0:6969"
    
      [udp_trackers.cookie_lifetime]
      secs = 120
      nanos = 0

    @da2ce7 suggested to add a flag to ignore connection ID on the weekly meeting.

    [[udp_trackers]]
    bind_address = "0.0.0.0:6969"
    connection_id_validation_enabled = true # deafults to `true`
    
      [udp_trackers.cookie_lifetime]
      secs = 120
      nanos = 0
  2. changed the title [-]Consider config option to increase connection ID expiration in UDP tracker[/-] [+]Consider config option to ignore connection ID expiration in UDP tracker[/+] on Dec 26, 2024
  3. changed the title [-]Consider config option to ignore connection ID expiration in UDP tracker[/-] [+]Add configurable UDP connection ID validation policy[/+] on Jul 20, 2026
  4. added a commit that references this issue on Jul 20, 2026
  5. self-assigned this
    on Jul 27, 2026
  6. added 2 commits that reference this issue on Jul 28, 2026
  7. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions