Skip to content

fix(p2p): send X-P2P-Key from every gossip sender, so enforcing it later is not an outage - #8203

Merged
Scottcjn merged 1 commit into
mainfrom
fix/p2p-gossip-sender-auth-header
Aug 11, 2026
Merged

fix(p2p): send X-P2P-Key from every gossip sender, so enforcing it later is not an outage#8203
Scottcjn merged 1 commit into
mainfrom
fix/p2p-gossip-sender-auth-header

Conversation

@Scottcjn

Copy link
Copy Markdown
Owner

Groundwork so that #8190 can land without taking the network down.

The gap

/p2p/gossip has two senders in node/rustchain_p2p_gossip.py:

  • request_full_sync() at line ~1538 sends headers={"X-P2P-Key": P2P_SECRET}
  • _send_to_peer() at line ~894, which is what broadcast() fans out through, sends no headers at all

The receiving endpoint does not require the header today, so nothing fails and the inconsistency is invisible.

It stops being invisible the moment anyone enforces on the receiver. #8190 proposes precisely that, adding _require_p2p_read_auth() to /p2p/gossip, and adds the header to zero senders. Merged as written it would 401 every broadcast message and stop inter-node gossip fleet-wide. The finding behind that PR is correct; only the sender half is missing.

This change

Send the header from _send_to_peer() too. Inert today, because nothing checks it. What it buys is that enforcement becomes a config change rather than an outage: once every node in the fleet is running a build that sends the key, the receiver can require it.

The test

CI cannot catch the original problem. It needs two live nodes talking to each other, and nothing in the suite does that. So the invariant is pinned statically instead: the test walks the AST for requests.post(...) calls whose URL contains /p2p/gossip and asserts each one passes X-P2P-Key. A sender added later without the header fails in CI rather than in production.

Reverting the source change fails the test, so it is checking the thing it claims to check.

Verification

Full CI suite: 3729 passed, 46 skipped, 2 xfailed, 0 failed.

Not included

Enforcement on the receiver. That is #8190's change to make, and it should land only after the fleet is running a build that sends the key, ideally behind a flag so the cutover is reversible without a redeploy.

/p2p/gossip has two senders. request_full_sync() sends the shared secret;
_send_to_peer(), which is the broadcast fan-out path, sent nothing. The
receiving endpoint does not require the header today, so the gap is
invisible.

It stops being invisible the moment anyone enforces on the receiver.
#8190 proposes exactly that and adds the header to no
sender, so merging it as written would 401 every broadcast message and take
inter-node gossip down fleet-wide. CI cannot catch that: it needs two live
nodes talking to each other.

Sending the header now is inert, since nothing checks it yet, and it turns
enforcement from an outage into a config change. The test pins the
invariant by walking the AST for requests.post calls targeting /p2p/gossip
and asserting each one passes X-P2P-Key, so a future sender added without
it fails in CI rather than in production.

Signed-off-by: Scott <scottbphone12@gmail.com>
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related tests Test suite changes size/M PR: 51-200 lines labels Aug 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ BCOS v2 Scan Results

Metric Value
Trust Score 49/100
Certificate ID BCOS-6f0136c5
Tier L1 (not met)

BCOS Badge

What does this mean?

The BCOS (Beacon Certified Open Source) engine scans for:

  • SPDX license header compliance
  • Known CVE vulnerabilities (OSV database)
  • Static analysis findings (Semgrep)
  • SBOM completeness
  • Dependency freshness
  • Test infrastructure evidence
  • Review attestation tier

Full report | What is BCOS?


BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs

@Scottcjn
Scottcjn merged commit 7847e73 into main Aug 11, 2026
12 checks passed
@Scottcjn
Scottcjn deleted the fix/p2p-gossip-sender-auth-header branch August 11, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants