Skip to content

fix(tracker): bound peer IDs and addresses on join - #141

Merged
mytrashcan merged 3 commits into
mainfrom
fix/tracker-peer-id-limits
Oct 20, 2026
Merged

mytrashcan merged 3 commits into
mainfrom
fix/tracker-peer-id-limits

Conversation

@mytrashcan

Copy link
Copy Markdown
Owner

Problem

POST /api/v1/broadcasts/:id/peers checked only that id and address are non-empty strings, so either could be close to 1 MB (the body limit). Both are repeated in every peer_list, in peer_joined, and in each inventory update about the peer: the same amplification class as metadata (#129) and inventories (#138, #139).

Change

  • id must be at most 128 characters and contain no whitespace or control characters (Unicode \p{Cc}).
  • address must be at most 2048 characters. It is still validated as a peer URL afterwards.
  • Violations return 400 with specific messages, and API_REFERENCE documents the limits.

Every bundled client fits comfortably: Node peers use the host name, the SDK generates IDs, and the load and capacity tools use loadtest-NNN and cap-N. Dots, colons, underscores, and hyphens remain allowed.

Tests

A new server test accepts a 128-character ID and punctuation, and rejects a 129-character ID, whitespace, NUL, and a 2 KB+ address with the expected messages. tracker: 66 pass.

A join's id and address were limited only by the 1 MB request body, and both are repeated in every peer list and in each inventory update about the peer. IDs are now at most 128 characters without whitespace or control characters, and addresses at most 2048 characters. Every bundled client uses short IDs (host names, generated browser IDs, loadtest-NNN, cap-N).
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation tests PRs that add or modify tests labels Oct 20, 2026
# Conflicts:
#	CHANGELOG.md
#	tracker/test/server.test.ts
The previous merge combined two tests appended at the end of the file into one broken block. Rebuild the file from main and append this branch's test.
@mytrashcan

Copy link
Copy Markdown
Owner Author

Self-review:

  • The bounds apply on join before address validation and storage. 128/2048 is generous for host names, generated browser IDs, and URLs.
  • \p{Cc} plus whitespace excludes log- and protocol-confusing IDs while allowing punctuation. The messages are specific.
  • The broken merge of the test file was rebuilt from main plus this test.
  • CI is green.

@mytrashcan
mytrashcan merged commit cef1c10 into main Oct 20, 2026
15 checks passed
@mytrashcan
mytrashcan deleted the fix/tracker-peer-id-limits branch October 20, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation tests PRs that add or modify tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant