Repository navigation
Description
Goal
Replace the process-global, cfg(test)-switched UDP connection-cookie cipher with one cryptographically random key created at startup and injected into every cookie issuer and validator. The fixed all-zero test key must be unreachable from production builds.
Problem
BEP 15 connection IDs prevent clients from issuing announce or scrape requests for an address they do not control. The tracker protects its eight-byte cookie by encrypting it with Blowfish, so the confidentiality of that cipher key is essential.
Today, udp-core has independent static random seed and cipher values, plus an all-zero test cipher. Compile-time aliases select the zero cipher for unit tests and the random cipher for production. Startup calls check_seed() to detect an accidental production test configuration, but that function compares only the unused random seed, not the cipher that encrypts cookies. Production initialization also initializes the zero cipher.
The current production alias is correct, so no bad cookie behavior is currently observed. However, a one-line alias regression makes production encrypt with the public all-zero key while check_seed() still passes. An attacker can then forge valid cookies for a chosen fingerprint and issue time.
Reproduction
A reversible local production-mode alias mutation selected ZEROED_TEST_CIPHER_BLOWFISH. The tracker then started normally, including HTTP and management API listeners; check_seed() did not panic. An independent executable encrypted documented cookie plaintext with BlowfishLE::new_from_slice(&[0_u8; 32]), constructed a protocol connection ID, and production check accepted it:
forged cookie accepted for issue time 1728000000
The full commands, toolchain, tracker startup logs, and restoration details are in the issue-local manual-verification-evidence.md artifact that will accompany the specification.
Scope
- Introduce a cookie-cipher key type with a cryptographically secure production constructor, an explicit test-only fixed-key constructor, and redacted
Debug. - Pass that key explicitly to cookie
makeandcheck, and throughudp-core,udp-server, and all remaining production callers. - Construct exactly one shared key at the composition root; no consumer may construct an independent key.
- Exclude the key from tracing spans.
- Remove the global key facades,
cfgaliases, zero and random statics, startup seed check, and stale documentation unless a surviving consumer is justified. - Add an ADR documenting the dependency-injection decision and its alternatives.
The cookie format, Blowfish algorithm, fingerprint/time arithmetic, inter-process key sharing, rotation, and key zeroization are out of scope.
Acceptance Criteria
- No production path can use a key other than the one cryptographically generated at startup; the test key cannot be referenced in a production build.
- All cookie issuers and validators use one shared key instance.
- Key material is absent from
Debugoutput and tracing spans. - Existing cookie behavior and encoding remain unchanged for an explicit fixed test key.
- Focused regression, collaboration, documentation, lint, and manual verification evidence pass.
Verification
The regression suite will prove the production constructor differs from the fixed key, a production build cannot access the test constructor, components in one container share a key, and debug output is redacted. Existing cookie round-trip and pinned-encoding tests will run with an explicit fixed key. The initial reproduction will be repeated after the change to show that all-zero-key production wiring is no longer expressible or accepted.
Activity
docs(issues): record torrust#2458 spec branch name
docs(issues): add specification for torrust#2458
docs(issues): record torrust#2458 spec branch name
docs(issues): add specification for torrust#2458
docs(issues): record torrust#2458 spec branch name
docs(issues): correct torrust#2458 cookie-cipher history
docs(issues): record torrust#2458 reproducer source verbatim
docs(issues): split torrust#2458 forged-cookie scenario into before a…
docs(issues): tidy torrust#2458 verification evidence
docs(issues): mark torrust#2458 reproduction step as completed
docs(issues): plan a pre-fix red regression test for torrust#2458
docs(issues): record the torrust#2458 disposable reproducer in the spec
docs(issues): assign planned evidence sections to torrust#2458 scenarios
docs(issues): link the secrecy ADR from torrust#2458
128 remaining items
docs(adrs): [torrust#2458] state that the compiler keeps the cookie k…
docs(issues): [torrust#2458] record the PR torrust#2470 review fixes
docs(pr-reviews): [torrust#2458] record the PR torrust#2470 review audit
docs(issues): [torrust#2458] cite the torrust#2411 cookie-key creatio…
docs(pr-reviews): [torrust#2458] record the PR torrust#2470 round-3 f…
Merge torrust#2470: fix(udp-core): [torrust#2458] inject the UDP conn…
chore(issues): archive closed issue torrust#2458 spec to docs/issues/…
Merge #2478: chore(issues): archive closed issue #2458 spec to docs/i…
Merge #2480: docs(issues): [#2479] add the HTTP announce benchmark bu…
test(udp-core): [torrust#2479] guard the connect_once benchmark again…
Merge #2509: fix(http-core): [#2479] make the HTTP announce benchmark…
docs(issues): pause udp core tests for torrust#2458 cookie key injection
docs(issues): re-plan udp core ledger after torrust#2458
Merge #2538: test(udp-core): [#1348] add tests to the udp-core package