Skip to content

feat(scallion): circuit handshake, relay table with limits, threat model (refs #386) - #494

Merged
ralyodio merged 2 commits into
masterfrom
feat/386-scallion-handshake
Nov 25, 2026
Merged

ralyodio merged 2 commits into
masterfrom
feat/386-scallion-handshake

Conversation

@ralyodio

@ralyodio ralyodio commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #386 (does not close it).

What this is

The next slice of the Scallion transport, in the order the issue lists: the threat model, signed peer capabilities, and an authenticated three-hop circuit handshake with forward secrecy.

Still not a working VPN. scallion_handshake is a pure state machine: it opens no socket, is not wired into the node, carries no user traffic and has had no independent review. c0mpute scallion doctor keeps reporting both modes as not ready, and nothing here changes that.

What it adds

  • Signed relay descriptors. A relay's Noise key, roles, exit ports and expiry, signed by its libp2p identity. A circuit can only be built from a VerifiedRelay, and only SignedRelayDescriptor::verify produces one. This closes the "unauthenticated relay key" gap scallion-frames.md calls out.
  • Per-hop Noise_NK_25519_ChaChaPoly_SHA256 through snow, the Noise implementation libp2p already uses (same version as the lockfile already held, so the lock gains one dependency line and no new crate). The relay is authenticated, the client stays anonymous to it, and traffic keys come from an ephemeral-ephemeral exchange, so a relay key stolen later does not open recorded traffic. No hand-rolled key agreement.
  • Telescoped build. Guard, then extend to the middle through the guard, then to the exit. Each link has its own random circuit id. Each hop learns its previous and next peer only.
  • Replay and ordering. Explicit sequence numbers and a 64-wide sliding window; a cell that fails authentication does not advance it.
  • Path rules. Guard, middle and exit roles enforced by position; no repeated peer or key; exactly three hops. A relay refuses a second extend, an extend to itself or back to its previous hop, and next-hop messages from the wrong peer.
  • Teardown from either end, extend failure and retry.

Docs

  • docs/protocol/scallion-threat-model.md (draft v0.1): goals, non-goals, adversaries with the state of each answer, and the weaknesses of this design that we already know (cell size reveals hop position, no padding, no rekeying, no streams, unauthenticated link-level destroy, no descriptor distribution or revocation).
  • docs/protocol/scallion-handshake.md: wire formats, acceptance rules, limits, and what it does not do.
  • scallion-frames.md points at the successor; README index; the /scallion page gains a row and two spec links, worded as built and tested but not wired or reviewed.

Relay table (second commit)

scallion_relay::RelayTable holds every circuit one relay carries: per-peer and total circuit caps, a Create rate limit per peer, an idle timeout and a shorter extend timeout, link ids unique per peer in both directions, no idle refresh from cells that fail authentication, and teardown of every circuit through a peer that disconnected. Same shape as the handshake: a state machine that takes the peer id and the time as parameters. 10 tests.

Tests

cargo test -p c0mpute-net scallion_handshake --locked: 46 passed on vienna across all scallion_ modules (18 handshake, 10 relay table). A simulated three-relay network covers a full build and data both ways, that the guard never sees the exit's id or the payload and the exit never sees the guard's, distinct link ids, descriptor tampering/expiry/wrong signer/bad content, a relay holding the wrong key, a handshake aimed at another peer id, replayed/tampered/reordered cells, path rules, extend refusals, extend failure and retry, teardown both ways, key separation between circuits, and malformed link messages.

Still open on #386

Carrying link messages over real libp2p streams with limits and timeouts; a stream layer and an exit enforcing ExitPolicy; the loopback SOCKS5 client; live path measurement; scallion start/status/stop; multi-node and leak tests; independent review.

🤖 Generated with Claude Code

…at model (#386)

Next slice of the Scallion transport. Still an in-process state machine:
no socket, not wired into the node, not reviewed, not a working VPN. Both
client modes keep reporting "not ready".

- scallion_handshake: relay descriptors signed by the relay's libp2p
  identity (Noise key, roles, exit ports, expiry). Circuits can only be
  built from a VerifiedRelay, which only verify() produces.
- Per-hop Noise_NK_25519_ChaChaPoly_SHA256 via snow (already in the
  lockfile through libp2p-noise): relay authenticated, client anonymous to
  it, ephemeral-ephemeral keys for forward secrecy. Prologue binds the
  relay peer id and the link id.
- Telescoped three-hop build with a separate random circuit id per link:
  each hop learns its previous and next peer only.
- Explicit sequence numbers with a 64-wide sliding replay window; a cell
  that fails authentication does not advance it. Teardown from either end,
  extend failure and retry.
- 18 unit tests on a simulated three-relay network.
- docs: scallion-threat-model.md (draft v0.1), scallion-handshake.md (wire
  formats, rules, limits, what it does not do); frames doc points at the
  successor; README index; /scallion page row and spec links.

Refs #386.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

26 finding(s)

HIGH/CRITICAL: 2 | MEDIUM: 20 | LOW: 4

Severity Rule Location
HIGH js-ssrf-outbound-request apps/web/public/sw.js:24
HIGH sh-remote-script-execution scripts/install.sh:618
MEDIUM gha-ssh-key-secret .github/workflows/deploy-dev2.yml:180
MEDIUM js-unescaped-html-sink apps/web/src/app/blog/[slug]/page.tsx:53
MEDIUM js-unescaped-html-sink apps/web/src/app/layout.tsx:111
MEDIUM js-open-redirect apps/web/src/components/sign-in-options.tsx:16
MEDIUM sql-template-interpolation apps/web/src/lib/accounts/alerts.ts:458
MEDIUM sql-template-interpolation apps/web/src/lib/accounts/fleet.ts:386
MEDIUM sql-template-interpolation apps/web/src/lib/chat/convo-store.ts:116
MEDIUM sql-template-interpolation apps/web/src/lib/chat/convo-store.ts:117
MEDIUM sql-template-interpolation apps/web/src/lib/chat/push.ts:489
MEDIUM sql-template-interpolation apps/web/src/lib/chat/share-store.ts:171
MEDIUM sql-template-interpolation apps/web/src/lib/disk/apps.ts:194
MEDIUM sql-template-interpolation apps/web/src/lib/disk/store.ts:237
MEDIUM sql-template-interpolation apps/web/src/lib/earnings/store.ts:216
MEDIUM sql-template-interpolation apps/web/src/lib/earnings/store.ts:319
MEDIUM sql-template-interpolation apps/web/src/lib/gallery/store.ts:284
MEDIUM js-dynamic-code-execution apps/web/src/lib/router/verify.ts:91
MEDIUM py-stack-trace-returned docker/worker/status_ui.py:35
MEDIUM sh-remote-script-execution scripts/dev-setup.sh:25
MEDIUM sh-eval-expansion scripts/dev-setup.sh:35
MEDIUM redos-nested-quantifier scripts/dev2-dns-recovery.py:31
LOW py-ssrf-outbound-request examples/business-strategist-agent/chat.py:37
LOW py-ssrf-outbound-request examples/business-strategist-agent/train.py:54
LOW secret-generic-credential node/crates/c0mpute-core/src/webhook.rs:1171
LOW py-path-traversal node/crates/c0mpute-core/tests/fixtures/fake-infernet-text:29

Snippets are redacted; ThreatCrush never prints matched credential material.

#386)

Holds every circuit one relay carries and enforces what a relay needs
before it can face the network. Still a pure state machine: no socket, no
clock, not wired into the node, not reviewed, not a working VPN.

- per-peer and total circuit caps; Create rate limit per peer (a refused
  Create costs no handshake)
- idle timeout (destroy toward both sides) and a shorter extend timeout
  (client gets ExtendFailed, the circuit survives and can retry)
- link ids unique per peer in both directions; an Extend that would reuse
  one fails
- a cell that fails authentication does not refresh the idle timer
- peer_disconnected tears down every circuit through that peer
- 10 unit tests on a three-table network; docs: "Relay limits" section,
  threat model row updated

Refs #386.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@ralyodio ralyodio changed the title feat(scallion): authenticated forward-secret circuit handshake + threat model (refs #386) feat(scallion): circuit handshake, relay table with limits, threat model (refs #386) Nov 25, 2026
@ralyodio
ralyodio merged commit 48123bc into master Nov 25, 2026
@ralyodio
ralyodio deleted the feat/386-scallion-handshake branch November 25, 2026 07:30
ralyodio added a commit that referenced this pull request Nov 25, 2026
…ke and relay table (#494), stale app error fix

scripts/bump-version.sh 0.3.113, plus the workspace crate versions in
Cargo.lock.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
ralyodio added a commit that referenced this pull request Nov 25, 2026
…again; bump v0.3.113 (#498)

* fix(apps): clear the "stopped for disk" error once the app runs again (#394)

stop_for_disk records why a node stopped an app in Local.error, which is
persisted and returned by /apps/v1/apps. Nothing ever cleared it, so after
the disk recovered and the app restarted the status API kept saying
"stopped at ...: this node's docker disk is down to 18 GiB free" next to
healthy: true. Seen live on gateway.c0mpute.com on 2026-11-25: four apps
up and answering 200, all four still carrying the error from the previous
evening.

Clear it when the container starts successfully as primary.

Refs #394 (product surface must reflect verified live state).

Co-Authored-By: Claude Fable 5.2 <[email protected]>

* bump v0.3.113: apps owned by the account key (#495), Scallion handshake and relay table (#494), stale app error fix

scripts/bump-version.sh 0.3.113, plus the workspace crate versions in
Cargo.lock.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

---------

Co-authored-by: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant