Commit Graph
3738 Commits
Author SHA1 Message Date
Adrien Beraud ddfbca3106 docs: describe fragment binding to the envelope state 2026-10-29 23:28:48 -04:00
Adrien Beraud 353c3d4e11 network: bind fragmented message parts to their envelope state
Value data fragments carry no node ID and were merged into a partial
message by source address and transaction ID alone, first come first
served. Transaction IDs increment from a random start and show in any
plaintext packet of a pair, such as the first-contact ping. An attacker
spoofing the sender's address could thus pre-seed forged plaintext
fragments, or a plaintext header, for an encrypted reply: the real parts
were then dropped as overlapping, forging unsigned values or losing the
message.

Parts of a message must now all be plaintext, or all come in envelopes
from the same sender key as its first part. An encrypted part replaces
plaintext state, which anyone can forge from a spoofed address; plaintext
or foreign-key parts never join an encrypted message.
2026-10-29 23:28:48 -04:00
Adrien Beraud 51324683e8 tests: cover forged parts in encrypted fragmented messages
Value data fragments carry no node ID. Parts of a message received in
envelopes must all come under the sender key of the envelopes, so that
plaintext or foreign-key parts spoofed from the sender's address, which
would otherwise be merged first, are ignored.
2026-10-29 23:28:48 -04:00
Adrien Beraud 4633483e06 docs: describe address-validated session caching 2026-10-29 23:28:48 -04:00
Adrien Beraud 6aee7ceb5c network: cache sessions only for address-validated peers
A session was cached for an address whenever we answered a peer there,
including replies to Initial and Hello envelopes, whose source address is
not verified. A spoofed Initial or Hello therefore replaced the session of
the real owner of the address, whose Data envelopes were then dropped until
a retry, and spoofed Initials from many addresses filled the cache and
evicted legitimate sessions, which were picked by address order.

Only cache a session for a peer whose ephemeral key arrived in a Session
or Data envelope, i.e. opened with our key for its address. Replies to
Initial and Hello envelopes derive their keys without caching them, so a
node that sent an Initial only confirms the session, and switches to Data
envelopes, once the peer answered a Session envelope. Evict the least
recently used session when the cache is full.
2026-10-29 23:28:48 -04:00
Adrien Beraud 32709230c6 tests: cover session cache hijacking by unvalidated senders
Replies to Initial and Hello envelopes must not cache a session at the
source address, which can be spoofed, and the cache must evict the least
recently used session rather than the lowest address. A node that started
with an Initial envelope only switches to Data envelopes once the peer
answered a Session envelope, which is when the peer caches the session.
2026-10-29 23:28:48 -04:00
Adrien Beraud 7b526410dd docs: describe Data envelopes and session confirmation 2026-10-29 23:28:48 -04:00
Adrien Beraud fbff1eced4 network: forget the peer ephemeral key on plaintext key advertisement
A peer only advertises its key in plaintext when it doesn't know ours, e.g. after a restart: it lost our session, so answer with an Initial envelope.
2026-10-29 23:28:48 -04:00
Adrien Beraud d23cb42b27 tests: cover a peer restarting with the same key
A node restarting with the same key and contacting a peer by address gets answers encrypted with the ephemeral key of its previous run.
2026-10-29 23:28:48 -04:00
Adrien Beraud e78e54b8c5 transport: send keyless Data envelopes once the session is confirmed
Sessions are keyed by peer address, so the receiver finds the keys from the source address: Data envelopes drop both keys from the header (30 bytes of overhead instead of 94) and need no key derivation to reject. A session is confirmed when the peer answers our envelope request with the session keys, or sends Data itself. Credentials only travel in key-carrying envelopes, which replaces Peer::acked. A received Initial envelope unconfirms the session, and full session caches evict instead of refusing, so a peer that derived keys keeps them.
2026-10-29 23:28:48 -04:00
Adrien Beraud 40560eec4e tests: cover keyless Data envelopes and session confirmation
Steady-state traffic uses Data envelopes, without sender keys nor credential, once the peer answered a request. Data envelopes only open from the session address, also authorize writes, and survive the receiver's epoch rotation.
2026-10-29 23:28:48 -04:00
Adrien Beraud 853bb1eeed docs: describe address-bound ephemeral keys and write authorization 2026-10-29 23:28:48 -04:00
Adrien Beraud 22d87a0f0e transport: replace write tokens with address-bound sessions
Ephemeral keys derive from a per-epoch secret and the peer address, so only that address learns them. A Session envelope then proves return routability: encrypted put, refresh and listen are accepted without token, and messages to encrypted peers no longer carry one (40 bytes saved). Initial envelopes cannot write. Tokens for plaintext peers move from Dht to NetworkEngine and derive from the same epoch secret. Session caches are keyed by address, and cached keys of both epochs are tried before any derivation.
2026-10-29 23:28:48 -04:00
Adrien Beraud dfb66c5a23 tests: cover session-based write authorization and address-bound keys
Encrypted writes must come in a Session envelope, whose ephemeral key is bound to the sender address. Plaintext writes still need a token, now issued by the network engine.
2026-10-29 23:28:48 -04:00
Adrien Beraud 56fcc5b918 docs: describe forward-secret transport keys
Ephemeral keys, Initial and Session key schedules, the unauthenticated
hello and the retry rule, with their security properties.
2026-10-29 23:28:48 -04:00
Adrien Beraud 26b30d4162 transport: add forward secrecy with rotated ephemeral keys
Each node rotates an ephemeral X25519 key every 30 minutes and keeps the
previous one for another period. Envelopes carry the sender static and
ephemeral keys. Session envelopes use keys derived from all four DH
combinations of static and ephemeral keys, erased with the epoch.
Initial envelopes, sent before the peer's ephemeral key is known, mix
the sender ephemeral and static keys with the receiver static key.

A hello is unauthenticated: it is only answered, without adding or
moving its claimed node. A peer is acknowledged only by a reply to a
request sent in an envelope, and a request retry restarts with an
Initial envelope and our credential.
2026-10-29 23:28:48 -04:00
Adrien Beraud 791a667fe2 tests: cover ephemeral key rotation, peer restart and hello
The previous ephemeral key is accepted for one more period, then erased.
A request retry restarts with an Initial envelope and our credential.
A hello is only answered and doesn't change what is known of its sender.
2026-10-29 23:28:48 -04:00
Adrien Beraud b693e3028b tests: cover forward-secret transport keys and envelope header
Session keys are directional and mix both static and ephemeral keys,
Initial keys are used before the peer's ephemeral key is known.
2026-10-29 23:28:48 -04:00
Adrien Beraud 3e975d530a docs: describe the transport encryption design 2026-10-29 23:28:48 -04:00
Adrien Beraud a32acbfa08 dht: persist the generated transport key in the node state
With persist_path, a transport key generated by the node is saved in the
state (owner-only file permissions) and restored on start, keeping the
node ID across restarts. Configured keys are never written to the state.
2026-10-29 23:28:48 -04:00
Adrien Beraud 43147b8791 tests: check generated transport key persistence 2026-10-29 23:28:48 -04:00
Adrien Beraud c1762af7e9 tools: add transport encryption and private network options
--no-encryption, --transport-key, --network-authority and
--network-credential configure the node; --gen-network-authority and
--issue-credential manage a private network.
2026-10-29 23:28:48 -04:00
Adrien Beraud 68b5996ba9 tests: cover encrypted transport and private networks 2026-10-29 23:28:48 -04:00
Adrien Beraud 7bc287fe2f network_engine: encrypt the DHT protocol
Nodes using transport encryption derive their node ID from their X25519
transport key, advertise it in plaintext messages ("k") and in node
lists ("k4"/"k6"), and encrypt all traffic with nodes whose key is
known. Keys are bound to node IDs, so they can't be forged, and
plaintext messages never move a node known to support encryption.
Legacy nodes keep talking in plaintext.

Private networks (TransportConfig::authorities) only accept nodes with
a credential issued by one of the network authorities, never send or
accept plaintext, and introduce themselves to addresses with a Hello.
2026-10-29 23:28:48 -04:00
Adrien Beraud 523dda8b3d tests: add transport primitives tests 2026-10-29 23:28:48 -04:00
Adrien Beraud 1c32dd0efb transport: add protocol encryption and credential primitives
X25519 transport keys, node ID derivation from the public key,
HKDF-SHA256 key agreement, ChaCha20-Poly1305 envelopes that legacy
msgpack parsers reject, and Ed25519 network authority credentials.
2026-10-29 23:28:48 -04:00
Adrien Beraud 1c914d8977 BUILD.md: cleanup 2026-10-29 23:28:29 -04:00
Adrien Beraud 3c87991e92 docs: make Rust README precise and factual 2026-10-29 22:46:57 -04:00
Adrien Beraud 52287bf608 ci: use npm environment for publishing v4.4.104 2026-10-29 22:27:34 -04:00
Adrien Beraud 061ce2deb4 docker: build with RelWithDebInfo 2026-10-29 22:27:04 -04:00
Adrien Beraud 64b536fb53 ci: publish Python wheels from the tag release workflow v4.4.103 2026-10-29 21:48:33 -04:00
Adrien Beraud 67c76f17de README: add Node.js bindings 2026-10-29 21:20:25 -04:00
Adrien Beraud 25fde756e8 docs: add linked package and Docker badges 2026-10-29 21:12:35 -04:00
Adrien Beraud f6b3eda280 rust: rewrite README 2026-10-29 20:55:07 -04:00
Adrien Beraud 9aee407a42 rust: avoid dual-stack conflict in startup error test v4.4.102 2026-10-29 10:35:51 -04:00
Adrien Beraud 722ef44c7d rust: move owned Value directly through callbacks and streams 2026-10-28 23:51:46 -04:00
Adrien Beraud 6ed2720bd7 rust: test single-copy async value ownership 2026-10-28 23:51:46 -04:00
Adrien Beraud 9005f73141 rust: add optional Serde typed operations 2026-10-28 23:51:46 -04:00
Adrien Beraud 9785c0a127 rust: add typed operation regression tests 2026-10-28 23:51:41 -04:00
Adrien Beraud 5662cc36d1 rust: publish crate on release with trusted publishing 2026-10-28 22:04:57 -04:00
Adrien Beraud e116cfe548 rust: add optional runtime-independent async API 2026-10-28 21:11:43 -04:00
Adrien Beraud 1c5e8378b8 rust: add async adapter regression tests 2026-10-28 21:11:42 -04:00
Adrien Beraud c630e80345 ci: use trusted publishing for Python wheels 2026-10-29 00:26:07 +00:00
cyrilleandCopilot 17f83edce4 proxy: add Huawei (HMS) push type
Route push notifications to Huawei devices, which have no Google Play
Services and therefore cannot receive FCM. gorush, already used as the
push relay, supports HMS natively as platform 3.

HMS takes its payload as a serialized JSON string in "huawei_data" and
carries its own ttl/priority fields, so it needs its own branch rather
than the generic "data" object used for FCM and APNs.

The enum value is appended last: MSGPACK_ADD_ENUM serializes it as an
integer, so reordering would break compatibility with deployed proxies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-29 00:02:02 +00:00
Adrien Beraud afab251376 nodejs: isolate native Linux dependency symbols
Use RTLD_DEEPBIND when loading the Linux addon so its llhttp calls do not resolve to Node's incompatible bundled parser. The CI image uses llhttp 9.2.1 while Node 22 exports 9.4.3, corrupting the heap when the proxy client starts. Preserve default loading on other platforms.
v4.4.101
2026-10-27 23:04:32 -04:00
Adrien Beraud 86d452fbb6 nodejs: bundle source-built llhttp license notices
The Noble dependency image builds llhttp from source, so dpkg-query cannot identify its license package. Include the pinned upstream MIT notice when bundling Linux llhttp libraries while retaining package-owner checks for other dependencies.
2026-10-27 23:04:32 -04:00
Adrien Beraud 08ff775232 ci: rely on npm trusted publishing 2026-10-27 22:48:58 -04:00
Adrien Beraud 738e0e22bf nodejs: add streaming iterators and startup proxy configuration 2026-10-27 22:46:34 -04:00
Adrien Beraud 8ec5b47c86 nodejs: test streaming iterators and proxy configuration 2026-10-27 22:09:21 -04:00
Adrien Beraud e1c31568f9 readme: cleanup 2026-10-27 22:01:05 -04:00