P4: LAN entry point for non-BEAM clients (members, challenge, 15-minute token) #4

Closed
opened 2026-12-02 09:59:19 +00:00 by uranus · 4 comments
Member

DECIDED 2026-12-02 "I have created and cloned macula-services/mcl-core. Let's build this properly. In the end I hope we keep a single repo: mcl-core that will replace both mcl-om and mcl-lan" (Raf)

Purpose (feature): Martha, lazymartha and macula-mcp reach a LAN cluster as a named member, with no station. This is design P4 (docs/DESIGN.md §4.2, §7).

Scope (design §7 P4): a private-address bind check, lan_members, a single-use challenge, an HMAC token (15 min) under a key derived from the secret, POST /lan/v1/call and the event stream.

Carried from the design review (Jupiter's advisory, macula-services/mcl-lan#1 comment 8141): the token request carries the member's public key, and a key whose SHA-256 is not the claimed node id is refused.

Done when:

  • A key that is not on lan_members gets no challenge.
  • A challenge is redeemed only once.
  • A token request whose public key does not hash (SHA-256) to the claimed node id is refused (the advisory above).
  • A member removed from the list is refused at its next call.
  • A public address starts no listener.

Waits on P2. Refs #1, macula-services/mcl-lan#1

DECIDED 2026-12-02 "I have created and cloned macula-services/mcl-core. Let's build this properly. In the end I hope we keep a single repo: mcl-core that will replace both mcl-om and mcl-lan" (Raf) Purpose (feature): Martha, lazymartha and macula-mcp reach a LAN cluster as a named member, with no station. This is design P4 (`docs/DESIGN.md` §4.2, §7). Scope (design §7 P4): a private-address bind check, `lan_members`, a single-use challenge, an HMAC token (15 min) under a key derived from the secret, `POST /lan/v1/call` and the event stream. Carried from the design review (Jupiter's advisory, macula-services/mcl-lan#1 comment 8141): the token request carries the member's public key, and a key whose SHA-256 is not the claimed node id is refused. Done when: - [ ] A key that is not on `lan_members` gets no challenge. - [ ] A challenge is redeemed only once. - [ ] A token request whose public key does not hash (SHA-256) to the claimed node id is refused (the advisory above). - [ ] A member removed from the list is refused at its next call. - [ ] A public address starts no listener. Waits on P2. Refs #1, macula-services/mcl-lan#1
terra closed this issue 2026-12-02 10:29:44 +00:00
neptunus reopened this issue 2026-12-02 12:03:37 +00:00
Member

Reopened. This issue was closed by commit ba24304, an mcl-om commit whose message says Fixes #4 (that meant mcl-om#4, the template runtime pin). It came into mcl-core with the mcl-om history merge (c815dbb), and the forge read it as closing this issue. P4 is not built. Neptunus is taking it (Mars, 2026-12-02).

Reopened. This issue was closed by commit ba24304, an **mcl-om** commit whose message says `Fixes #4` (that meant mcl-om#4, the template runtime pin). It came into mcl-core with the mcl-om history merge (c815dbb), and the forge read it as closing this issue. P4 is not built. Neptunus is taking it (Mars, 2026-12-02).
Member

Threat model (P4, before code)

What is protected: every capability served on the LAN, and every pubsub topic. The entry point reaches both as the member it names.

Who it is defended against: a device on the LAN that holds neither the cookie nor the gossip secret: a guest, an IoT box, a sniffer. Whoever holds the secret already owns the cluster (§2.1), so that is out of scope, as the design says.

# Threat Defence Test
T1 A guest asks for a challenge or token under a node id that is not listed lan_members is read on every request, and an unlisted id is refused before anything is stored or verified DW1
T2 A guest claims a listed node id and sends its own key The token request carries the public key and profile; macula_node_keys:node_id(Pub, Profile) must equal the claimed id, or the request is refused. That is the real derivation, a labelled SHA-256 over profile and key, not a bare hash: the advisory's intent, done with macula's own function DW3
T3 A sniffed signed challenge is replayed A challenge is 32 random bytes, kept 60 s at the issuing node, bound to the node id it was issued for, and removed by an atomic ets:take on redemption. The second redemption finds nothing DW2
T4 A challenge is signed for one protocol and used for another What is signed is "mcl-lan token request v1" 0 NodeId Nonce, never the bare nonce unit
T5 A forged or altered token HMAC-SHA256 under HKDF-SHA256(gossip secret, info mcl-lan token v1); compared with crypto:hash_equals; version, expiry and length are all checked unit + mutant
T6 A sniffed token is replayed (no TLS, trust on sight) Accepted, bounded by the 15-minute lifetime and by removal from the list (design §4.2) DW4
T7 A member is removed but keeps its token Every call, and every event on a stream, reads the list again. A stream closes at the token's expiry DW4
T8 The listener is exposed on a public interface The configured address must be private (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10) or loopback. Anything else, 0.0.0.0 and :: included, starts no listener, and /health names {lan_entry, {not_private, Addr}} DW5
T9 Memory exhaustion through challenges under listed ids (ids are not secret) At most 4 live challenges per node id, the oldest dropped first; expired ones are swept unit
T10 A large body Bodies are read with a 1 MB cap; the guard pipeline's own size limit applies after that unit
T11 A call with no token, on an open capability Refused: every entry-point request carries a token, whatever the policy (§4.2) unit

Not in P4, named:

  • Distribution itself is started by vm.args before mcl_core, so P4 does not re-check its address.
  • A call that no LAN member serves answers no_lan_provider, and is not relayed to the bridge. On the mesh it would carry the bridge's identity, not the member's, so it would no longer be the member's call. Uranus's call_as/6 (#7) behaves the same way.
  • Loopback is accepted as an address because it exposes nothing beyond the box; tests and one-box setups use it.
## Threat model (P4, before code) **What is protected:** every capability served on the LAN, and every pubsub topic. The entry point reaches both as the member it names. **Who it is defended against:** a device on the LAN that holds neither the cookie nor the gossip secret: a guest, an IoT box, a sniffer. Whoever holds the secret already owns the cluster (§2.1), so that is out of scope, as the design says. | # | Threat | Defence | Test | |---|---|---|---| | T1 | A guest asks for a challenge or token under a node id that is not listed | `lan_members` is read on every request, and an unlisted id is refused before anything is stored or verified | DW1 | | T2 | A guest claims a listed node id and sends its own key | The token request carries the public key and profile; `macula_node_keys:node_id(Pub, Profile)` must equal the claimed id, or the request is refused. That is the real derivation, a labelled SHA-256 over profile and key, not a bare hash: the advisory's intent, done with macula's own function | DW3 | | T3 | A sniffed signed challenge is replayed | A challenge is 32 random bytes, kept 60 s at the issuing node, bound to the node id it was issued for, and removed by an atomic `ets:take` on redemption. The second redemption finds nothing | DW2 | | T4 | A challenge is signed for one protocol and used for another | What is signed is `"mcl-lan token request v1" 0 NodeId Nonce`, never the bare nonce | unit | | T5 | A forged or altered token | HMAC-SHA256 under HKDF-SHA256(gossip secret, info `mcl-lan token v1`); compared with `crypto:hash_equals`; version, expiry and length are all checked | unit + mutant | | T6 | A sniffed token is replayed (no TLS, trust on sight) | Accepted, bounded by the 15-minute lifetime and by removal from the list (design §4.2) | DW4 | | T7 | A member is removed but keeps its token | Every call, and every event on a stream, reads the list again. A stream closes at the token's expiry | DW4 | | T8 | The listener is exposed on a public interface | The configured address must be private (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10) or loopback. Anything else, `0.0.0.0` and `::` included, starts no listener, and /health names `{lan_entry, {not_private, Addr}}` | DW5 | | T9 | Memory exhaustion through challenges under listed ids (ids are not secret) | At most 4 live challenges per node id, the oldest dropped first; expired ones are swept | unit | | T10 | A large body | Bodies are read with a 1 MB cap; the guard pipeline's own size limit applies after that | unit | | T11 | A call with no token, on an `open` capability | Refused: every entry-point request carries a token, whatever the policy (§4.2) | unit | **Not in P4, named:** - Distribution itself is started by vm.args before mcl_core, so P4 does not re-check its address. - A call that no LAN member serves answers `no_lan_provider`, and is not relayed to the bridge. On the mesh it would carry the bridge's identity, not the member's, so it would no longer be the member's call. Uranus's `call_as/6` (#7) behaves the same way. - Loopback is accepted as an address because it exposes nothing beyond the box; tests and one-box setups use it.
Member

Follow-ups from the r=1 review (Jupiter, relayed by Mars as non-blocking notes). Not in P4 as landed:

  1. A challenge flood under a listed id can evict the member's own challenge (availability only). Node ids are not secret, and anyone may ask for challenges under a listed id. The table keeps at most 4 live challenges per id, the oldest dropped first (mcl_core_lan_challenge, T9 in the threat model, c8392). So a guest asking fast enough can drop the member's challenge before the member redeems it, and the member has to ask again. No token is ever issued to the guest: it cannot sign. The bound on memory stays.
  2. The token's role is not read yet. A token carries owner or member from lan_members, but no route decides anything on it: every call goes through the capability's own auth. Whatever an owner-only route or policy needs belongs to its own package.
Follow-ups from the r=1 review (Jupiter, relayed by Mars as non-blocking notes). Not in P4 as landed: 1. **A challenge flood under a listed id can evict the member's own challenge** (availability only). Node ids are not secret, and anyone may ask for challenges under a listed id. The table keeps at most 4 live challenges per id, the oldest dropped first (`mcl_core_lan_challenge`, T9 in the threat model, c8392). So a guest asking fast enough can drop the member's challenge before the member redeems it, and the member has to ask again. No token is ever issued to the guest: it cannot sign. The bound on memory stays. 2. **The token's role is not read yet.** A token carries `owner` or `member` from `lan_members`, but no route decides anything on it: every call goes through the capability's own `auth`. Whatever an owner-only route or policy needs belongs to its own package.
Member

Closed. Landed on main at 914650ae (PR 9, Terra). It sits on P3 (e728bd59), whose mcl_core_lan:call_as/6 it reuses. Reviewed by Jupiter: r=1 PASS, with Jupiter's inline fix (reset_idle_timeout_on_send, so an event stream outlives cowboy's 60 s idle timeout), which I read and verified locally. CI: lint-and-test run 6894 green on 914650a (6895 was accepted by Mars).

Done-when, each tested in test/mcl_core_lan_entry_SUITE.erl, on a real peer node with the test node as the HTTP client:

  • A key that is not on lan_members gets no challenge: a_key_not_on_the_list_gets_no_challenge, with a listed control.
  • A challenge is redeemed only once: a_challenge_is_redeemed_only_once. Redemption is an atomic ets:take.
  • A token request whose public key does not hash to the claimed node id is refused: a_key_that_is_not_the_node_id_is_refused. The check is macula_node_keys:node_id(Pub, Profile), macula's own labelled derivation; a bare SHA-256 is not how node ids are made.
  • A member removed from the list is refused at its next call: a_removed_member_is_refused_at_its_next_call. Its event stream ends at the next event too: a_removed_members_stream_ends_at_its_next_event.
  • A public address starts no listener: a_public_address_starts_no_listener. /health names {lan_entry, {not_private, Address}}, and a loopback control is checked beside it.

The threat model is c8392. Mutants on the guards: 11/11 killed. The follow-ups from the review are c8424.

Closed. Landed on main at 914650ae (PR 9, Terra). It sits on P3 (e728bd59), whose `mcl_core_lan:call_as/6` it reuses. Reviewed by Jupiter: r=1 PASS, with Jupiter's inline fix (`reset_idle_timeout_on_send`, so an event stream outlives cowboy's 60 s idle timeout), which I read and verified locally. CI: lint-and-test run 6894 green on 914650a (6895 was accepted by Mars). Done-when, each tested in `test/mcl_core_lan_entry_SUITE.erl`, on a real peer node with the test node as the HTTP client: - [x] A key that is not on `lan_members` gets no challenge: `a_key_not_on_the_list_gets_no_challenge`, with a listed control. - [x] A challenge is redeemed only once: `a_challenge_is_redeemed_only_once`. Redemption is an atomic `ets:take`. - [x] A token request whose public key does not hash to the claimed node id is refused: `a_key_that_is_not_the_node_id_is_refused`. The check is `macula_node_keys:node_id(Pub, Profile)`, macula's own labelled derivation; a bare SHA-256 is not how node ids are made. - [x] A member removed from the list is refused at its next call: `a_removed_member_is_refused_at_its_next_call`. Its event stream ends at the next event too: `a_removed_members_stream_ends_at_its_next_event`. - [x] A public address starts no listener: `a_public_address_starts_no_listener`. /health names `{lan_entry, {not_private, Address}}`, and a loopback control is checked beside it. The threat model is c8392. Mutants on the guards: 11/11 killed. The follow-ups from the review are c8424.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-core#4
No description provided.