Skip to content

feat(server): optional location privacy — serve approximate positions - #2458

Open
zfouts wants to merge 17 commits into
Kpa-clawbot:masterfrom
zfouts:feat/location-privacy
Open

zfouts wants to merge 17 commits into
Kpa-clawbot:masterfrom
zfouts:feat/location-privacy

Conversation

@zfouts

@zfouts zfouts commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in location privacy setting for operators who don't want their CoreScope instance to be the easy way to look up where a repeater owner or companion user lives. When it is on, the web UI and API never serve an exact position, only an approximate point within a configured radius (for example 1 km). The setting is off by default, and with it off, behaviour is unchanged.

"locationPrivacy": { "enabled": true, "radiusM": 1000 }

The secret comes from CORESCOPE_LOCATION_SECRET (or "secret"), at least 32 bytes. Full operator guide: docs/location-privacy.md.

Scope, stated plainly: this only protects against users of this instance. Adverts are broadcast in clear over the air and published to MQTT, the database stays exact, and admin-only routes stay exact.

How it works

Node positions

  • Every read of nodes / inactive_nodes coordinates now lives in cmd/server/node_coords.go and is fuzzed as it is loaded.
  • An invariant test fails on any other coordinate read in cmd/server.
  • Fuzz: each node is placed on its own metre-based grid, whose origin derives from the secret and the node's public key. The served point is its cell centre plus an offset from HMAC(secret, key, cell), inside a disk sized so that |served − exact| ≤ radiusM everywhere, including the poles and the antimeridian. The HMAC inputs are fixed-width and versioned (csloc/v2).
    • Deterministic, so repeated requests can't be averaged.
    • Keyed per node, so a probe node placed next to a target never gets the target's point, and one node's point says nothing about another's grid. The cost is that nodes known to be at one site can be averaged; the docs give the numbers.
    • Estimates on a grid of their own. A node's /api/nodes/reported estimate comes from unsigned companion reports, so it gets a separate grid and cannot be used to probe the node's.
    • Keys must be 64 hex digits. Any other key, and non-finite input, gets no position.
    • Per-node hysteresis stops a node jittering across a cell edge from flipping between points.
  • All computation uses served positions: distances, the neighbour graph, reach, path inspect, the planner, route LOS and the ducting overlay's forecast cells.
  • The geo_filter, area membership and the admin geo-prune still classify by exact position.

Companion GPS (client_receptions, client_rf_samples)

  • Each fix is replaced by the centre of its cell before any filter, binning or distance. Cells are at least 2R × 2R, with a secret origin.
  • Bisecting a bbox therefore only finds a cell. Display hexes are capped at a circumradius of at least R.
  • The /api/nodes/reported estimate is fuzzed, and its radius_m grows by R.
  • Per-companion views (?rx=<pubkey>) are served only to that companion's linked owner or an admin. Anyone else sees a notice on the map saying so, not a blank map.

Located adverts

  • Served with raw_hex: null and a decoded_json without lat, lon, signature or raw. The signature alone would let anyone brute-force the position from the approximate one.
  • They also carry location_hidden: true, plus frame_bytes and frame_head (header and path only), so sizes and hash-size badges keep working.
  • Redaction runs once, where a packet enters server memory (load, chunked load, poll, rewrite feed), and in every DB fallback. Truncated frames fail closed.
  • Analytics (hash sizes, packet sizes, relay airtime) give identical numbers with the setting on and off.

Startup fails closed

  • The server refuses to start in these cases:
    • the secret is missing or too short;
    • the radius is out of range;
    • the env secret is set but the block doesn't say "enabled": false;
    • config.json can't be parsed and a locationPrivacy block in it doesn't say "enabled": false. Each block is decoded on its own, as a clean load would read it: a quoted "true", duplicate or escaped keys and braces inside strings are all read correctly. A broken string that hides a block from that walk refuses too, and so does any other mention of the name that isn't plain text in a string value (a key that lost its colon or closing quote, a misspelt key, a block closed too early, even one that says "enabled": false before the brace with its other members after it), counted after unescaping. A _comment… key with a string value is a comment. A file with a raw NUL (UTF-16) refuses.
  • A disabled install still starts as before, including Docker's copied config.example.json with a typo in it. A copy of the stock file with the block enabled loads and turns the feature on (areas._comment no longer fails the parse; see Notes).
  • /api/config/client omits the key when the feature is off.

UI

  • "Approximate location (within 1 km)" and an uncertainty circle on node detail.
  • The same circle on the main and live maps, around the pin under the pointer and the selected pin (open popup or live detail panel). One circle per map is moved, not one per marker.
  • A note in the map attribution.
  • Notices on the planner, route LOS, distance, reach and coverage views.
  • A "raw bytes hidden" message in packet detail.

Security review

A threat model was done before implementation, and independent security and code reviews after it. Everything those reviews raised is addressed in this PR, including:

  • the signature-oracle and bbox-bisection attacks;
  • substring retention of the exact frame;
  • truncated frames failing open;
  • averaging co-located nodes;
  • the per-companion attribution of edge flips;
  • the fail-closed gaps.

Residual risks are documented in docs/location-privacy.md:

  • Injected adverts: an attacker who can inject adverts can learn the grid origin.
  • Restarts and replicas: each replica keeps its own hysteresis state, so a restart or a second replica can show a node sitting on a cell edge at a second point. Both points are within the radius.
  • Secret rotation: rotating the secret lets old and new positions be compared, so rotate only if it leaked.

Screenshots

Privacy on (radiusM 1000), on the e2e fixture, at commit 2b682cc3; the last row (map circles) at affd8877, zoomed to one node, with no basemap tiles loaded. Headless Chromium at 1280×800 (one at 390×844), on the keyless OSM Gray basemap. Click a thumbnail for the full size. The images are on a separate assets branch, so they are not in this diff.

Node detail, light: the uncertainty circle (radius 1 km) around the approximate point, and "Approximate location (within 1 km)" under the coordinates
Node detail, light: the uncertainty circle (radius 1 km) around the approximate point, and "Approximate location (within 1 km)" under the coordinates
Node detail, dark
Node detail, dark
Node detail at 390 px
Node detail at 390 px
Main map: pins sit at the approximate points, and the attribution says "Positions approximate (within 1 km)"
Main map: pins sit at the approximate points, and the attribution says "Positions approximate (within 1 km)"
Packet detail of a located advert: raw bytes hidden, and no lat, lon or signature among the decoded fields
Packet detail of a located advert: raw bytes hidden, and no lat, lon or signature among the decoded fields
Repeater planner: the notice that distances, line of sight and results are indicative
Repeater planner: the notice that distances, line of sight and results are indicative
RX coverage, dark: one companion's view refused to an anonymous viewer shows a notice, not a blank map
RX coverage, dark: one companion's view refused to an anonymous viewer shows a notice, not a blank map
Main map, light: the 1 km circle around the selected pin, under its popup
Main map, light: the 1 km circle around the selected pin, under its popup
Main map, dark
Main map, dark
Live map, dark: the selected node keeps its circle while the detail panel is open
Live map, dark: the selected node keeps its circle while the detail panel is open

Tests

  • Leak test (location_privacy_leak_test.go): walks every GET route from the router (a new route without test parameters fails), the live feed builders, and bbox and route-LOS oracles. It fails on any exact coordinate in text, int×1e6 or distance form, on any advert raw hex, and on any signature. The fixture includes a truncated advert, and runs ducting over a fake Open-Meteo so /api/ducting answers with cells. Its allowlist is empty.
  • Fuzzer properties: at least 100k points across the globe for the distance bound, plus determinism, hysteresis, the anchor cap, -race, and secret never serialised.
  • Probe resistance: 10,000 probe keys around a target never share its point; row and column edges are uniform across keys; node and estimate grids are independent; averaging bounds pinned; a known-answer vector fixes the HMAC layout.
  • Analytics parity, on vs off, including transport and direct routes. Store-entry redaction, the frame fields and memory retention.
  • Fail-closed tables (60 cases), including the stock config.example.json with a syntax error, a quoted "true", duplicate, escaped and case-varied keys, braces in strings, stray or unterminated quotes, broken keys (missing colon or closing quote, =, ,, ;), the same with the name escaped, a block closed too early (including one whose "enabled": true lands outside it, the same in an enabled copy of the stock block, and a block that says "enabled": false closed before its other members), null or a block without enabled, _comment… keys, and a UTF-16 file.
  • Stock config: config.example.json parses as shipped (LoadConfig returns its values), and with the block enabled and a secret it loads, turns the feature on and passes the startup checks.
  • Companion-view authorisation (owner, admin, anonymous, other user) and the coordinate-read invariants.
  • Frontend unit tests (test-location-privacy.js, test-packet-filter.js) and an E2E against a privacy-on server, which CI now starts on :13583 (shard 1) with clientRxCoverage on. It includes a refused ?rx= coverage link, and the map circles: on hover, kept while a popup or the live detail panel is open, and gone once it closes.

Local runs:

  • full cmd/server suite, plus -race on the privacy tests and the leak test 10× in a row
  • test-all.sh
  • the privacy E2E and the axe suite against a privacy-on server: 0 violations

On a live dev instance (PostgreSQL, 5 server replicas, real mesh traffic) with it on: 873 nodes checked against their exact positions are displaced 24–792 m, none exact and none beyond 1 km; all 5 replicas serve identical points for all 1,346 positioned nodes; 110 of 110 adverts on the live feed over 2 minutes arrived redacted.

Performance

Path Cost
Fuzzing, 10,000 nodes per node-cache refresh about 1.6 ms warm
Packet redaction, non-adverts about 3 ns, 0 allocs
Packet redaction, located adverts about 4.4 µs
Packet redaction, mixed, 30K packets with 10% adverts about 410 ns/packet

Nothing expensive runs under the store lock on the poll and rewrite paths.

Notes for reviewers

  • Per-node grids (2b682cc3): the shared grid let anyone with signed adverts of their own probe a target's 0.4 x radiusM cell with about 6 nodes. Validated by an independent security review before building, and code-reviewed after; see the PR comment.

  • Review round 1 (efiten, on abc6696e): fixes in 03d7809b (fail closed), ead854a3 (docs on what one known position gives away) and c660e7ef (refused per-companion view); see the reply comment. Master is merged in (8d4814b0), and Optional mobile push for watched-node alerts through a push relay #2447's two push-relay routes are classified in the leak test (1a073b6e).

  • Review round 3 (efiten, on affd8877): master merged again (eda3d883); the ducting overlay's node read uses served positions (9ce6273a); the fail-closed walk accounts for every mention (13ef883f, also checked by a separate security review); the circle list is pruned (538b5e15). See the reply comment.

  • Review round 4 (efiten, on 538b5e15): a broken config starts only when every block says "enabled": false explicitly, _comment… keys no longer refuse, and the leak test serves /api/ducting with data (fc06dee2). See the reply comment. Master merged again (1ae8f25b): both sides' eslint globals and E2E suite lines kept, and feat(analytics): rank nodes by neighbour count (#2100) #2457's /api/nodes/neighbor-rank added to the leak test.

  • Review round 5 (efiten, on 1ae8f25b): master merged again (5891ffea). In store.go, the per-transmission redaction is kept next to Count only received adverts when assigning node regions #2497's per-observation observedFrameEvidence, and master's nodeZeroHopRegionCounts is taken. Its legacy-singleton fallback now reads the route evidence that hiddenFrame keeps, so hiding an advert changes no zero-hop vote. Compare observers against a pinned reference #2492's /api/analytics/observer-comparison (observer IDs, names, counts, no position) is classified in the leak test. The stock config can now be enabled: Config.Areas skips _-prefixed non-object keys (6b4aa59d). A disabled block closed before its other members refuses (2671bc4a). See the reply comment.

  • map[string]interface{} in cmd/server production code: two fewer here than on master. The unused GetNodeLocations is removed, and observer locations are now typed.

  • Found while testing, and fixed here (6b4aa59d): the stock config.example.json didn't unmarshal into Config (areas._comment is a string where an object is expected), so LoadConfig treated every Docker install that copies it as a parse failure. Pre-existing and not changed: ENABLE_PPROF listens on all interfaces.

  • Interaction with feat(db): PostgreSQL as an alternative database backend #2396 (Postgres): verified on an integration branch with both. See the PR comment for the port notes.

  • Merging with the other overnight PR: whichever lands second needs a one-line rebase in .github/workflows/deploy.yml (both add a suite line next to test-node-reach-e2e.js).

🤖 Generated with Claude Code

@zfouts

zfouts commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Location privacy × PostgreSQL (#2396): port notes

I verified both together on an integration branch: master + #2396 + this PR, plus the map-tile, ducting and grid-history branches. The full cmd/server suite passes on SQLite and on Postgres, including 38 Postgres tests, none skipped. Whichever of the two PRs merges second needs these changes:

  1. exactNodePositions (node_coords.go) uses SQLite's json_each(?). On Postgres it needs db.sqlFor(...) with jsonb_array_elements_text(CAST(? AS jsonb)).
  2. Carry feat(db): PostgreSQL as an alternative database backend #2396's explicit orderings into the functions this PR moved to node_coords.go:
    • bulkHealthNodes: ORDER BY last_seen DESC NULLS LAST, public_key ASC
    • GetNodePubkeysInArea: ORDER BY public_key
    • GetNodesForGeoPrune: ORDER BY name NULLS FIRST, public_key
  3. pg_db_queries_test.go must stop calling the removed GetNodeLocations and use map[string]nodeLocation.
  4. Add the parity test pg_node_coords_test.go: every node-coordinate reader serves the same fuzzed positions on both backends.

scanNodeRow, nodeSelectCols, getAllNodes and GetNodeLocationsByKeys needed no Postgres-side changes.

@zfouts
zfouts force-pushed the feat/location-privacy branch from d6e1680 to 4da569b Compare November 23, 2026 15:27
… (fuzzy location)

New opt-in setting `locationPrivacy` {enabled, radiusM, secret} (secret also
via CORESCOPE_LOCATION_SECRET). When on, this instance never serves an exact
position:

- Node positions: every read of nodes/inactive_nodes coordinates goes through
  node_coords.go and is fuzzed on load: a metre grid with a secret origin, the
  served point offset inside a disk derived from HMAC(secret, cell), so
  |served - exact| <= radiusM, it is stable (no averaging across requests),
  co-located nodes share one point, and per-node hysteresis stops flipping at
  cell edges. Distances, neighbours, reach, path inspect, planner and route
  LOS all compute from served positions. The geo_filter, area membership and
  the admin geo-prune are the only exact consumers. An invariant test fails on
  any other coordinate read.
- Companion GPS (client_receptions, client_rf_samples): every fix becomes the
  centre of its cell (>= 2R x 2R, secret origin) before filtering, so bbox
  bisection can't localise a fix; display hexes are capped at circumradius >=
  R; the /api/nodes/reported estimate is fuzzed. Per-companion views (?rx=)
  are served only to the companion's linked owner or an admin.
- Located adverts: raw_hex null, decoded_json without lat/lon/signature (the
  signature would let anyone brute-force the position) and "raw", plus
  location_hidden, frame_bytes and frame_head so sizes and hash sizes still
  work. Redaction runs once where a packet enters server memory (load,
  chunked load, poll, rewrite feed) and in every DB fallback; truncated
  frames fail closed. Analytics give identical numbers on and off.
- Startup fails closed: bad secret or radius; the env secret set without the
  block saying "enabled": false; an unparseable config.json that enables the
  feature. Disabled installs (including Docker's copied config.example.json)
  start exactly as before, and /api/config/client omits the key when off.
- UI: "Approximate location (within 1 km)" and an uncertainty circle on node
  detail, a map attribution note, notices on planner/LOS/distance/reach and
  coverage, and a hidden-bytes message in packet detail.
- Tests: a leak test walks every GET route, the live feed and bbox/LOS
  oracles and fails on any exact coordinate, advert hex or signature;
  property tests for the fuzzer bound across the globe; analytics parity on
  and off; a CI job runs the privacy E2E against a privacy-on server.
- Docs: docs/location-privacy.md (what it protects and what it does not).

Off by default; with it off, behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts
zfouts force-pushed the feat/location-privacy branch from 4da569b to abc6696 Compare November 23, 2026 15:46
@zfouts
zfouts marked this pull request as ready for review November 23, 2026 17:17
@efiten

efiten commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

A remark from me : I think this is a bit a strange request?
Meshcore is public by default; all repeaters send their location over the Meshcore protocol, so everyone with a companion receives the exact location of each node. Why would you try to avoid this in Corescope ?

@efiten

efiten commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Review of abc6696e. I looked for any endpoint, WebSocket feed, export or derived field (distances, bearings, hexes, neighbour distances, planner, coverage) that still serves exact coordinates with the option on, and found none. The full cmd/server suite passes locally, the leak tests fail when the fuzzer is mutated out, and with the option off nothing changes.

Three points before merge:

  1. Startup does not fail closed for "enabled": "true" (cmd/server/location_privacy.go:389, :400-413). A quoted boolean makes UnmarshalJSON fail, the file counts as a parse failure, and locEnabledTrueRe only matches an unquoted true. A probe with {"locationPrivacy":{"enabled":"true","secret":"..."}} started with the fuzzer off and one log warning. A } inside the block before "enabled" (a _comment such as "see {docs}") defeats [^}]* the same way when the file has a syntax error elsewhere. Could the check refuse to start whenever a parse failure leaves a locationPrivacy key in the raw file, unless it says an unquoted "enabled": false? Both cases would fit in the fail-closed test table.

  2. The docs promise more uncertainty than a single known position leaves (cmd/server/location_privacy.go:148, docs/location-privacy.md:119, :129-133). The served point depends on the cell only, and cells are 0.4 R wide. At 51 N with radiusM: 1000 the served point changes every 400 m, and two pubkeys 300 m apart serve the identical point. Anyone who knows one position in a cell (their own node, a public mast) can place every node that shares its served point inside that 400 m square. No code change needed if that trade-off is intended, but "What it protects", the radiusM row and the FAQ should say it, since operators pick radiusM from that page.

  3. The per-companion coverage view goes blank without a message (public/rx-coverage.js:452, :469-483, :289-295; cmd/server/rx_dashboard.go:241). With privacy on, ?rx= returns 403 to anyone but the owner or an admin. Leaderboard rows stay clickable, and a click ends in an empty map with only a console.warn. Shared #/rx-coverage?rx=... links behave the same. Showing a notice on 403 (as mine-refused does), or not making the rows selectable for non-owners, would fix it; an E2E step would pin it.

Smaller notes, none blocking:

  • location_privacy.go:480: above 85° relative offsets stay exact within a cell.
  • reported_nodes.go:155, :287: the /api/nodes/reported estimate is built from exact companion fixes and fuzzed afterwards, the one exception to "replaced before any filter, binning or distance".
  • tx_rewrite_feed.go:55 reads raw_hex per row also with the feature off.
  • config.example.json:428 and docs/location-privacy.md:131 still say "per-node offset"; location_privacy.go:25 has a leftover process comment.
  • window.__meshcorePacketsInternals (public/packets.js:4501) is a production global for a unit test.

Not checked: browser and E2E runs, -race, and the five-replica numbers in the description.

@zfouts

zfouts commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

That's a fair question, and you're right about the radio side: every advert carries the position as the operator set it, and anyone with a companion in range receives it. This doesn't change that, and the docs say so up front ("It does not make positions secret: adverts are public radio traffic").

The gap it's aimed at is who can look at the map. A public CoreScope instance isn't limited to people on the mesh: anyone with the link can open it, whether or not they run MeshCore. Hearing an advert takes a radio within range, at the moment it's sent. A public instance serves every position to anyone on the internet, all at once, searchable, with history behind it. Some operators are comfortable with that, and some would rather their site wasn't the place that collects those positions and hands them out. For example, a repeater may sit on someone's house, or the coverage pages may show where people actually drive and stop.

So it's for those operators. It's off by default, and with it off nothing changes, which your review confirmed. When it's on, it only limits what that instance's own map and API show. That seemed worth offering as an option, even though the over-the-air data stays as it is.

I'll work through the three points from your review next.

zfouts and others added 5 commits November 26, 2026 09:29
Conflict in public/nodes.js: master (Kpa-clawbot#2482) replaced the Avg Hops row
with renderNodePathLength; this branch added the approximate-location
marker to the Location row. Both kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot#2447)

TestLocationLeakRoutes requires every GET route to be requested or listed
as admin-only. GET /api/admin/notifications/push-relay is behind withAdmin;
GET /api/push-relay/enrollment-proof answers only a signature over the
challenge, and 404 while no enrollment runs. Push payloads carry no
coordinates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k reads as off

Review of Kpa-clawbot#2458: the fail-closed check after a parse failure matched only
an unquoted "enabled": true in the first brace-free span of the block, so
"enabled": "true", or a brace inside a string before "enabled", started
the server serving exact positions.

rawLocationPrivacyMayEnable now walks the raw file's string tokens
(escapes included) and decodes each locationPrivacy block on its own
through LocationPrivacyConfig.UnmarshalJSON, matching keys as
encoding/json does. Duplicate keys, escaped keys and quoted values read
exactly as a clean load reads them; a block that does not decode refuses.
Every raw "locationprivacy" must lie inside a token the walk read, so a
stray or unterminated quote that hides a block refuses too. The stock
disabled block with a typo elsewhere still starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of Kpa-clawbot#2458: the served point depends on the cell only, and cells are
0.4 x radiusM on a side (0.6 x radiusM near an edge, with the hysteresis).
Anyone who knows one position in a cell can place every node served the
same point inside that square, and nodes sharing a point are close
together. "What it protects", the radiusM row, the FAQ and the
config.example.json comment now say so, with how to pick radiusM for the
cell size. The stale "per-node offset" wording and the leftover process
markers in location_privacy.go are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of Kpa-clawbot#2458: with location privacy on, ?rx=<companion> on RX
coverage and RF noise answers 403 to anyone but the owner or an admin,
and the page ended on an empty map with only a console warning (a
leaderboard click, or a shared #/rx-coverage?rx= link).

coverageReply returns 'rx-refused' for a 403 to a single-companion
view; fetchLayer then clears the hexes and shows a notice over the map
("Only this companion's owner or an admin can see its coverage. Choose
All to see everyone's."), styled as the other privacy notices and
announced (role=status). Any later drawn view hides it.

Tests: coverageReply cases (unit); an E2E step on the privacy-on CI
server, which now enables clientRxCoverage, opens a refused ?rx= link,
expects the notice and no hexes, then expects it gone without ?rx=. It
fails on the old code. Checked by eye in light, dark and at 375 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Review feedback addressed (commits 03d7809b, ead854a3, c660e7ef), plus a master merge (8d4814b0, 1a073b6e).

  1. Fail closed on a broken config (03d7809b). I replaced the regex with rawLocationPrivacyMayEnable (cmd/server/location_privacy.go:422), as you suggested: after a parse failure, any locationPrivacy block that does not read as off refuses the start. It walks the raw file's string tokens, escapes included, so braces and quotes inside strings no longer throw it off. Each locationPrivacy key, matched case-insensitively as encoding/json matches keys, has its value decoded on its own through LocationPrivacyConfig.UnmarshalJSON. So "enabled": "true", {"enabled": false, "enabled": true}, a second block and escaped keys ("enabled") all read exactly as a clean load would read them, and a block that doesn't decode refuses. One case a block-level check can't see: an unescaped quote earlier in the file pairs the following strings up wrongly and hides the block. So every raw locationprivacy must lie inside a string token the walk read, or the start is refused. I didn't require an explicit "enabled": false: once the block is decoded on its own, a block without enabled reads as off exactly as it would on a clean load, and the stock example with a typo elsewhere keeps starting. The table in TestLocationPrivacyFailClosed has 10 new cases (cmd/server/location_privacy_test.go:723 and around). Your two cases and the escaped-key case fail on abc6696e.
  2. What one known position gives away (ead854a3). "What it protects" (docs/location-privacy.md:84) now says it outright. The served point depends only on the cell, which is 0.4 x radiusM on a side, or up to 0.6 x near an edge because of the hysteresis. Anyone who knows one position in a cell can place every node served the same point inside that square, and nodes that share a point are close together. The section ends with how to choose radiusM for the cell size (:96). The radiusM row, the FAQ and the config.example.json comment say the same, and the stale "per-node offset" wording and the leftover process comment in location_privacy.go are gone.
  3. Refused per-companion view (c660e7ef). coverageReply returns 'rx-refused' for a 403 to a single-companion view (public/rx-coverage.js:69). fetchLayer then clears the hexes and shows a notice over the map (public/rx-coverage.js:217), "Only this companion's owner or an admin can see its coverage. Choose All to see everyone's." It uses the privacy notices' style, has role="status", and any later drawn view hides it. That covers leaderboard clicks and shared #/rx-coverage?rx= links alike. I left the rows selectable, since that needs no ownership data in the client. A new E2E step on the privacy-on CI server opens a refused ?rx= link, expects the notice and no hexes, then expects it gone without ?rx=. It fails on the old code. The CI privacy server now enables clientRxCoverage so the endpoint reaches the companion gate. Checked in light, dark and at 375 px.

Merge. Master's #2447 added two GET routes, which TestLocationLeakRoutes refused until they were classified. GET /api/admin/notifications/push-relay is behind withAdmin. GET /api/push-relay/enrollment-proof answers only a signature over the challenge (404 while no enrollment runs). Push payloads carry no coordinates. In public/nodes.js, master's path-length row and this PR's approximate-location marker are both kept.

Re-tested: the full cmd/server suite with vet and gofmt, test-all.sh, eslint (0 errors), the CSS variable check, test-location-privacy-e2e.js against a privacy-on server, and the four RX coverage E2E suites against a stock server.

Of the smaller notes, I fixed the "per-node offset" wording and the leftover comment. These are not done: the relative offsets above 85°, the /api/nodes/reported estimate being built from exact fixes, the per-row raw_hex read with the feature off, and the window.__meshcorePacketsInternals global. I'd rather do them in a follow-up than grow this PR further, unless you'd like any of them here.

With one grid for all nodes and an offset per cell, every node in a cell
was served the identical point. Anyone who can get signed adverts heard
(their own keys, chosen positions) could place about 6 probe nodes around
a target's served point and read off its 0.4 x radiusM cell from the one
that matched, and map the shared grid with about 25 adverts.

The grid origin and the offsets now come from
HMAC(secret, label ‖ purpose ‖ pk32 [‖ row ‖ col]), fixed-width and
versioned (csloc/v2). A probe's point says nothing about any other node.
A node's computed estimate (/api/nodes/reported, built from unsigned
companion reports) gets a grid of its own (purpose byte), so a report
submitted for a key cannot probe that node's grid. Keys must be exactly
64 hex digits; anything else, and non-finite input, serves no position.
Hysteresis anchors move to the LRU, keyed by (purpose, key). Geometry and
the |served - exact| <= radiusM bound are unchanged.

Trade-off, documented with numbers: nodes known to be at one site can be
averaged (median error 404 m alone, 184 m for 4, at radiusM 1000).

Tests: distinct points for co-located keys; 10,000 probes never share a
target's point; row and column edges uniform across keys; node and
estimate grids independent; bound over random keys; key forms; malformed
keys and non-finite input fail closed; interleaved determinism; averaging
bounds; LRU eviction; a known-answer vector. The two shared-point tests
are removed. The leak-test fixture starts its secret search at 8502: two
earlier suitable secrets trip a two-decimal coincidence between a fuzzed
distance and an unrelated exact one, which a real leak would not do.

Bench: warm 10k-node pass 1.6 -> 2.0 ms, cold 15 -> 23 ms (two HMACs per
node).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
zfouts added a commit to zfouts/CoreScope that referenced this pull request Nov 26, 2026
@zfouts

zfouts commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

One more change, to the fuzzing itself (2b682cc3): each node now gets its own grid and offsets, keyed by its public key.

Why. With one grid for every node and an offset per cell, all nodes in a cell were served the identical point. That made the cell easy to find for anyone who can get adverts heard. They can't post a position under someone else's key (the ingestor checks signatures), but they can make as many keys of their own as they like. About 6 probe nodes placed around a target's served point are enough: the one that comes back with the identical point gives away the target's cell, 400 m across at the default radiusM, not the 1 km the setting promises. About 25 adverts map the shared grid itself. Knowing one real position in a cell did the same without any probes. That was the "0.4 x radiusM cell" I documented last round; this closes it instead of documenting it.

What changed.

  • Grid origin and offsets come from HMAC(secret, label ‖ purpose ‖ key ‖ row ‖ col), fixed-width and versioned (csloc/v2) (cmd/server/location_privacy.go:345, cmd/server/location_privacy.go:361). A probe's point says nothing about any other node.
  • A node's /api/nodes/reported estimate is built from companion reports, which aren't signed, so it gets a grid of its own (cmd/server/location_privacy.go:595). A report submitted for a key can't be used to probe that node's grid.
  • Keys must be exactly 64 hex digits (cmd/server/location_privacy.go:217). Any other key, or a non-finite coordinate, gets no position at all, never a shared-grid fallback.
  • Hysteresis moved to the existing LRU, keyed by (purpose, key), so a node's position and its estimate no longer evict each other.
  • Geometry is unchanged, so |served − exact| ≤ radiusM still holds everywhere.

The cost. Nodes at one site are now drawn at separate points. Someone who knows that N nodes really share a site can average their points. At radiusM 1000 the median error goes from 404 m for one node to 184 m for four and 114 m for ten. The docs give the table (docs/location-privacy.md:88) and suggest raising radiusM for a site with many nodes. They also say to keep signature validation on, and not to re-key a node in place (docs/location-privacy.md:129). I think it's the right trade: probes are free and work on every node, while averaging needs the victim's own co-located nodes and knowledge that they're together.

How it was checked.

  • Before building: an independent security review compared four designs: shared grid, per-node keying, a hybrid, and per-node rotation over time. The hybrid keeps the probe signal unless its per-node part is so large it's per-node keying anyway. Rotation over time gives an averageable sample every period, so it's worse.
  • After building: a code review. Its findings are all in this commit: estimates on their own grid, non-finite input fails closed, tighter test bounds, and a known-answer vector.
  • Tests that fail on the shared-grid code:
    • 10,000 probe keys around a target never share its point (cmd/server/location_privacy_test.go:401);
    • node and estimate grids are independent (cmd/server/location_privacy_test.go:495);
    • the averaging error is pinned to its expected range (cmd/server/location_privacy_test.go:760);
    • a fixed input gives a hard-coded point (cmd/server/location_privacy_test.go:530).
  • Full cmd/server suite and -race on the privacy and leak tests pass. So does the privacy E2E against a privacy-on server.
  • On the e2e fixture, 186 nodes compared with their exact positions: displacement 19–734 m, median 387 m; none exact, none over 1 km, and no two nodes share a point. The one pair at an identical spot is now drawn at two points.
  • Screenshots in the description are retaken at this commit.

Changes that need your attention:

  • Every approximate point moved. Not an issue before release, but don't run the old and new builds side by side on one instance.
  • Bench, per 10,000 nodes: a warm pass goes from 1.6 to 2.0 ms, a cold one from 15 to 23 ms (two HMACs per node instead of one).
  • Leak-test fixture. It now starts its secret search at 8502 (cmd/server/location_privacy_fixture_test.go:228). Of the first five secrets that suit the fixture, two trip a two-decimal coincidence between a fuzzed distance and an unrelated exact one. A real leak would show under every secret, and three pass in full. The distance rule is brittle, though: 5 secrets in 20,000 suit the fixture. I'd tighten it in a follow-up rather than here.

With location privacy on, the main map shows the radiusM circle around
the pin under the pointer and keeps it while that pin's popup is open.
The live map does the same for hover and keeps it while the node detail
panel is open. One circle per map is moved, not one per marker.

Circles are drawn by an SVG renderer in their own pane (z-index 390, no
pointer events), so they look the same on the canvas live map and never
cover a canvas path's clicks. Listeners are shared functions that do
nothing while the feature is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

The uncertainty circle is now on the main and live maps too (affd8877), not only on node detail. With location privacy on:

  • Main map: hovering a pin draws the radiusM circle around its served point (public/map.js:2202). Opening its popup keeps the circle there while you hover other pins, and closing the popup removes it.
  • Live map: hover works the same way, and the selected node keeps its circle while the detail panel is open (public/live.js:2555).
  • One circle per map, moved from pin to pin, not one per marker (public/location-privacy.js:224). The listeners are shared functions that do nothing while the feature is off.
  • Its own SVG pane, under the overlay pane with no pointer events (public/location-privacy.js:178). The live map renders on canvas, so in the default pane the circle would have been canvas-drawn; in its own pane it looks the same as on the other maps and never covers a canvas path's clicks.
  • At the default overview zoom a 1 km circle is a few pixels wide and hides under the pin. It becomes useful once you zoom in, which is when people are judging a node's position anyway.

Tests:

  • 4 new unit tests in tests/unit/test-location-privacy.js: hover, popup pin, explicit pin and clear, the pane and renderer.
  • 4 new steps in the privacy E2E, run against a privacy-on server: hover shows the circle, mouseout hides it, it stays while the popup is open, and it goes when the popup closes. 2 more cover the live map: the circle stays while the detail panel is open and goes when it closes.
  • test-all.sh and eslint pass. With the feature off, test-e2e-playwright.js, the map teardown and race-stress suites, the estimated-positions E2E and the live map animation E2E pass on a stock server.
  • docs/location-privacy.md describes the circles, and that the real position is anywhere inside them, not at the centre.

Screenshots are in the description's last row.

zfouts added a commit to zfouts/CoreScope that referenced this pull request Nov 27, 2026
…k reads as off

Review of Kpa-clawbot#2458: the fail-closed check after a parse failure matched only
an unquoted "enabled": true in the first brace-free span of the block, so
"enabled": "true", or a brace inside a string before "enabled", started
the server serving exact positions.

rawLocationPrivacyMayEnable now walks the raw file's string tokens
(escapes included) and decodes each locationPrivacy block on its own
through LocationPrivacyConfig.UnmarshalJSON, matching keys as
encoding/json does. Duplicate keys, escaped keys and quoted values read
exactly as a clean load reads them; a block that does not decode refuses.
Every raw "locationprivacy" must lie inside a token the walk read, so a
stray or unterminated quote that hides a block refuses too. The stock
disabled block with a typo elsewhere still starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 03d7809)
zfouts added a commit to zfouts/CoreScope that referenced this pull request Nov 27, 2026
Review of Kpa-clawbot#2458: the served point depends on the cell only, and cells are
0.4 x radiusM on a side (0.6 x radiusM near an edge, with the hysteresis).
Anyone who knows one position in a cell can place every node served the
same point inside that square, and nodes sharing a point are close
together. "What it protects", the radiusM row, the FAQ and the
config.example.json comment now say so, with how to pick radiusM for the
cell size. The stale "per-node offset" wording and the leftover process
markers in location_privacy.go are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ead854a)
zfouts added a commit to zfouts/CoreScope that referenced this pull request Nov 27, 2026
Review of Kpa-clawbot#2458: with location privacy on, ?rx=<companion> on RX
coverage and RF noise answers 403 to anyone but the owner or an admin,
and the page ended on an empty map with only a console warning (a
leaderboard click, or a shared #/rx-coverage?rx= link).

coverageReply returns 'rx-refused' for a 403 to a single-companion
view; fetchLayer then clears the hexes and shows a notice over the map
("Only this companion's owner or an admin can see its coverage. Choose
All to see everyone's."), styled as the other privacy notices and
announced (role=status). Any later drawn view hides it.

Tests: coverageReply cases (unit); an E2E step on the privacy-on CI
server, which now enables clientRxCoverage, opens a refused ?rx= link,
expects the notice and no hexes, then expects it gone without ?rx=. It
fails on the old code. Checked by eye in light, dark and at 375 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c660e7e)
@efiten

efiten commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the per-node keying; that closes the probe attack. I found no path (API, WebSocket, exports, /api/nodes/reported, node detail, coverage, packet fields, logs) that serves an exact or shared-grid point, and the averaging table in docs/location-privacy.md reproduces (394/261/185/115 m).

Two things before merge:

  1. The fail-closed walk can still be bypassed (cmd/server/location_privacy.go:513-516, :524). A token that contains the name counts as seen whether or not it is a key, and the block is only decoded when the next byte is :. These files fail to parse, are not refused, and the server starts with exact positions (secret in config.json, env secret unset):

    • "locationPrivacy" {"enabled":true,...} (colon missing)
    • "locationPrivacy: {"enabled":true,...} (closing quote missing)
    • "locationPrivacy" = {, "locationPrivacy", {, "locationPrivacy"; {

    Suggested fix: let a token containing the name pass only when it is a key followed by : whose value decodes as off, or a string in value position. Anything else may enable. Please add these cases to TestLocationPrivacyFailClosed.

  2. Master moved again. The branch conflicts in cmd/server/routes.go, cmd/server/types.go and .github/workflows/deploy.yml. GET /api/ducting (feat(map): tropospheric ducting overlay (Open-Meteo, worldwide, off by default) #2436) is not yet classified in location_privacy_leak_test.go, so TestLocationLeakRoutes will fail after the merge. It serves a weather grid, not node positions.

Minor: circles in public/location-privacy.js:214 is only pruned on a theme change, so every node detail opened with privacy on keeps its removed map reachable.

zfouts and others added 4 commits November 27, 2026 20:39
Conflicts: routes.go and types.go keep both LocationPrivacy and
Ducting in the client config; deploy.yml stops both the
location-privacy and the ducting E2E servers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… positions

The merge of master brought the ducting overlay (Kpa-clawbot#2436), whose node read
ductingNodeCoords selected nodes.lat/lon in ducting_service.go. With
location privacy on, the overlay's forecast cells followed exact
positions; it serves them in /api/ducting and names them to the weather
API. The read now lives in node_coords.go and returns servedNodePos; the
visibility rule still classifies by the stored position. Rows without
lat or lon, or with no servable position (malformed key), are skipped.

TestDuctingNodeCoordsFuzzed covers privacy on and off, NULL rows and a
malformed key. /api/ducting gets its leak-route entry (ducting is off in
the fixture, so it is the 404).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… mention

A config.json that failed to parse started with exact positions when the
locationPrivacy key itself was broken: a token holding the name counted
as seen whether or not it was a key, and the block was decoded only when
':' followed. "locationPrivacy" {…}, "locationPrivacy: {…}, and the key
followed by '=', ',' or ';' all started on defaults.

rawLocationPrivacyMayEnable now accounts for every mention or refuses:
- a key that decodes to locationPrivacy must have a value that decodes
  as off and is well-formed where it sits (followed by ',' or '}'), so
  {"locationPrivacy": {} "enabled": true} refuses;
- any other key holding the name (misspelt block) refuses;
- elsewhere the name may only appear in a string value (':' or '['
  before it; ',', '}' or ']' after it).
Mentions are counted on JSON-unescaped text, so an escaped name with a
broken separator refuses too, and a raw NUL (a UTF-16 file) refuses.

TestLocationPrivacyFailClosed: 47 cases (25 new), including the
review's five bypasses and the same with the name escaped.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…w one

The circle list was only pruned on a theme change, so every node detail
opened with privacy on kept its removed map reachable. makeCircle now
prunes before adding, which bounds the list to circles on live maps.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zfouts

zfouts commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Review feedback addressed (commits eda3d883, 9ce6273a, 13ef883f, 538b5e15). Thanks, each point reproduced as described.

  1. Fail-closed walk (13ef883f). rawLocationPrivacyMayEnable (cmd/server/location_privacy.go:517) now takes your suggested rule and refuses unless it can account for every mention of the name:

    • A key that decodes to locationPrivacy must have a value that decodes as off. That value must also be well-formed where it sits, followed by , or } (cmd/server/location_privacy.go:544), so {"locationPrivacy": {} "enabled": true} refuses.
    • Any other key holding the name refuses. That covers a misspelt block ("locationPrivacyX":).
    • Anywhere else, the name may appear only inside a string value: : or [ before it, and ,, } or ] after it. All five of your cases refuse.

    A separate security review of the first version found three more ways to start with exact positions, now closed:

    • The name escaped with a broken separator ("locationPrivacy" {). Mentions are now counted on JSON-unescaped text (cmd/server/location_privacy.go:571).
    • A block closed too early, as above.
    • A UTF-16 file, which is PowerShell 5.1's default for >. Any raw NUL refuses (cmd/server/location_privacy.go:519).

    TestLocationPrivacyFailClosed now has 47 cases, 25 of them new. They include your five bypasses, the same five with the name escaped, string values that should still start (a _comment, an array of notes), and the stock example with a typo. The docs section "Unparseable config" says which mentions refuse.

  2. Master merged (eda3d883). The conflicts were in routes.go and types.go (the client config keeps both LocationPrivacy and Ducting) and in deploy.yml (cleanup stops both E2E servers). /api/ducting is now classified (cmd/server/location_privacy_leak_test.go:876). Ducting is off in the fixture, so the check sees the 404.

    Classifying it turned up one real gap (9ce6273a). The overlay places its forecast cells around node positions, serves them in /api/ducting and sends them to the weather API, but ductingNodeCoords read exact nodes.lat/lon in ducting_service.go. The read now lives in node_coords.go (cmd/server/node_coords.go:225) and returns servedNodePos. Visibility still classifies by the stored position. TestDuctingNodeCoordsFuzzed (cmd/server/node_coords_test.go:381) covers privacy on and off, NULL coordinates and a malformed key.

  3. circles (538b5e15). makeCircle calls pruneCircles (public/location-privacy.js:135) before adding a circle, so the list only holds circles on live maps. A new unit test opens node detail three times and checks that one circle stays reachable.

Verified locally: the full cmd/server suite, all frontend unit suites, and eslint. The location-privacy E2E passed twice against a privacy-on server, and the ducting E2E passed (36 checks).

@efiten

efiten commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks, the new walk holds up well. BOMs, UTF-16 LE/BE, comments, single-quoted and unquoted keys, escapes, duplicate and nested blocks, and quote mis-pairing all refuse. I checked 62 hand-written cases and about 4.1M generated mutants of the stock config, and the stock example still starts. The ducting fix is right: its test fails when the fix is reverted. No other code merged into master since your base (#2436, #2486, #2491, #2493, #2446) reads node lat/lon, and the circle pruning and the master merge look right.

One bypass is left (cmd/server/location_privacy.go:541, :545): a block that is closed too early still starts with exact positions when the stray } is followed by , or }. One added character in a stock-shaped block is enough:

"locationPrivacy": {"_comment": "..."}, "enabled": true, "secret": "..."},

The block decodes as {"_comment": ...}, which reads as off, and "enabled": true lands as a top-level key. The same happens with {}, "enabled": true and null, {...}, and with a misspelt "enable": true combined with a syntax error elsewhere in the file. Of 4,679 single-byte mutants of the stock block that keep the name intact, this is the only one that starts.

Suggested fix: at :541, pass only a block that is explicitly off (c.explicitlyDisabled()), not one that merely does not enable. With that change the single-mutation bypasses go from 1 to 0, two-byte mutations from 33,830 to 18, and the stock example still starts. The "block without enabled" case in TestLocationPrivacyFailClosed would then expect a refusal.

Minor, optional: a _comment_locationPrivacy key refuses every start of a stock-derived config. Also, the leak test only sees /api/ducting as a 404, because ducting is off in the fixture.

With config.json unparseable, the fail-closed walk passed any
locationPrivacy block that did not enable. A block closed too early
({"_comment": "..."}, "enabled": true, ...; {}, "enabled": true; null,
{...}) or one with a misspelt "enable" decodes as not saying enabled,
so the server fell back to exact positions. Only a block that says
"enabled": false explicitly passes now.

A "_comment..." key naming the block, with a whole string value, is a
comment and no longer refuses every start of a stock-derived config.

The leak test fixture now runs ducting over a fake Open-Meteo, so
/api/ducting answers 200 with cells instead of the 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Review feedback addressed (commit fc06dee2). Thanks. The early-close bypass reproduced as you described.

  1. Early-close bypass (cmd/server/location_privacy.go:544). As you suggested, a block now passes only when it says "enabled": false explicitly (c.explicitlyDisabled()). These cases now refuse:

    • {"_comment": "..."}, "enabled": true, ...
    • {}, "enabled": true
    • null, {...}
    • a misspelt "enable": true
    • a block without enabled

    TestLocationPrivacyFailClosed has a case for each, and its "block without enabled" case now expects a refusal. TestLocationPrivacyStockExampleWithSyntaxErrorStarts also takes an enabled copy of the stock block, adds your one stray } after its _comment, and expects a refusal. With the fix reverted, all six cases fail. The stock example with a syntax error still starts. I did not rerun your mutation counts.

  2. _comment_locationPrivacy: a key starting with _comment that names the block is now treated as a comment. Its value must be a whole string value, followed by , or }. With an object value, or with something other than , or } after the string, it still refuses. Four new table cases cover this, and the stock-example test checks that a broken stock copy carrying such a key still starts.

  3. /api/ducting in the leak test: the fixture now runs ducting over the fake Open-Meteo, with cells laid out by the server's own node source (srv.ductingNodes). The route now answers 200 with cells instead of the 404. The cells sit on a whole-step grid, so the response body can't show which positions laid them out. Feeding ducting exact positions still passes the leak test, so TestDuctingNodeCoordsFuzzed stays the guard for that node read, and it does fail under that mutation.

Docs (docs/location-privacy.md) and the stock comment in config.example.json now say "a block that says enabled: false" instead of "reads as off".

Local runs: full cmd/server suite, go vet, gofmt, and -race -count=2 on the privacy, leak and ducting tests.

Brings in Kpa-clawbot#2457, Kpa-clawbot#2490, Kpa-clawbot#2488, Kpa-clawbot#2500 and Kpa-clawbot#2455. Conflicts were two
added lines on each side: the eslint globals (frameHex/frameSize and
NeighborRank) and the deploy.yml E2E suite list (the privacy-on suite
and test-neighbor-rank-e2e.js); both kept. The leak test now requests
Kpa-clawbot#2457's /api/nodes/neighbor-rank, which serves no positions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Merged current master (1ae8f25b) to clear the conflicts. It brings in #2457, #2490, #2488, #2500 and #2455.

  1. .eslintrc.json and .github/workflows/deploy.yml: each side had added lines in the same spot (the eslint globals, and the E2E suite list). Both sides kept.
  2. The leak test now requests feat(analytics): rank nodes by neighbour count (#2100) #2457's /api/nodes/neighbor-rank, which serves no positions. It has to, because the test fails on any GET route it doesn't request.

Full cmd/server suite, go vet, eslint (0 errors) and test-all.sh pass on the merge.

@efiten efiten left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 1ae8f25b. Thanks, the early-close fix holds up.

Earlier points

  • Early-close bypass: fixed (location_privacy.go:544). All four of my cases now refuse, and I found no variant: comment markers, */ inside a key, braces in strings, a second block after a close, CRLF, trailing garbage, BOM and NBSP all refuse or start as intended. Single-byte mutants of the stock config with the block enabled (271,680 broken files) and two-byte mutants of a small enabled config (7,987,264) gave no bypass with the key name intact. Mutants that break the name itself ("location"Privacy") start, which is inherent to detecting it by name.
  • _comment_locationPrivacy and the /api/ducting leak test: fixed.
  • The master merge 1ae8f25b is clean: it only keeps both sides in .eslintrc.json and deploy.yml and adds the neighbor-rank leak-test entry.

Blocking

  1. Conflicts with current master (00f0b41f) in cmd/server/store.go: the redactLocatedAdvert block against observedFrameEvidence from #2497, and nodeZeroHopRegionCounts. After resolving, GET /api/analytics/observer-comparison from #2492 also needs a class in location_privacy_leak_test.go, or TestLocationLeakRoutes fails.
  2. A config copied from config.example.json cannot be turned on. areas._comment is a string and does not decode into AreaEntry (config.go:156, Areas map[string]AreaEntry), so the stock file always reads as a parse failure. With locationPrivacy.enabled: true the server then exits with "config.json could not be parsed and location privacy appears configured ... cannot unmarshal string into Go struct field Config.areas". The Docker entrypoint starts from that file, so the Quick start in docs/location-privacy.md fails for anyone who keeps the areas example. It fails closed, so nothing leaks, but the feature cannot be used that way. TestLocationPrivacyStockExampleWithSyntaxErrorStarts only covers the disabled block. Either let _comment keys be skipped when decoding areas, or check that only locationPrivacy needs to parse, and add a test with the stock file and the block enabled.

Non-blocking

  • A block that says "enabled": false and then closes early, with "enabled": true outside it, starts. It takes two edits to get there.
  • An unreadable config.json without the environment secret starts on defaults. That is documented (docs/location-privacy.md:160).

zfouts and others added 3 commits December 1, 2026 16:38
Conflict resolutions:
- cmd/server/store.go ingestNewFromDB: keep both. Each transmission is
  still redacted once (redactLocatedAdvert); master's per-observation
  observedFrameEvidence (Kpa-clawbot#2497) runs on the observation's own frame
  before it is dropped, so it reads exact bytes but keeps only the hop
  width and reception kind.
- cmd/server/store.go nodeZeroHopRegionCounts: take master's version,
  which moved the frame checks into StoreObs.receivedDirectAdvert. Its
  legacy-singleton fallback read packetpath.AdvertRouteEvidence(tx.RawHex),
  which is empty for a located advert under privacy, and the evidence
  needs the payload length, so frameHead cannot supply it. hiddenFrame now
  keeps routeEvidence (computed from the whole frame at redaction) and
  receivedDirectAdvert reads tx.frameRouteEvidence(). Test:
  TestRedactZeroHopLegacySingletonParity.

Follow-ups for master's changes:
- TestLocationLeakRoutes: classify GET /api/analytics/observer-comparison
  (Kpa-clawbot#2492). It returns observer IDs, names, reception counts and SNR
  deltas, no position.
- packet_redact_frames_test.go: ingestNewFromDB takes a clientCount (Kpa-clawbot#2511).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
config.example.json documents areas with a "_comment" string, and
Config.Areas was map[string]AreaEntry, so json.Unmarshal of the stock
file always failed: LoadConfig reported it as a parse failure (on master
it silently moved on), and with locationPrivacy enabled the fail-closed
guard refused to start. The Quick start in docs/location-privacy.md could
not be followed with a config copied from the example (Kpa-clawbot#2458 review).

Config.Areas is now AreaMap, whose UnmarshalJSON skips a "_"-prefixed key
whose value is not an object (a comment) and decodes every other key as
an AreaEntry. A "_comment": {} object is still an area, as
TestConfigAreasDocumentedResponses expects. The ingestor has no areas
field and already loads the example (observation_hops_backfill_test).

Tests: TestConfigExampleParses (the stock file loads with its values),
TestAreaMapSkipsCommentKeys, and TestLocationPrivacyStockExampleEnabledStarts
(the stock file with the block enabled and a secret loads, turns privacy
on and passes the startup checks); all three fail before the change.
TestLocationPrivacyStockExampleWithSyntaxErrorStarts now requires the
stock file to parse, and edits only the locationPrivacy block (other
blocks say "enabled": false too).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kpa-clawbot#2458 review (non-blocking): a broken config whose locationPrivacy block
says "enabled": false and is closed early, with "enabled": true among the
members after the brace, started: the raw fallback read the block as an
explicit false, and the decoder ignores the stray top-level "enabled".

rawLocationPrivacyMayEnable now also reports true when a key of the block
(enabled, radiusM, secret; escapes decoded, case folded as encoding/json
does) is among the scalar members right after the block. A block's members
are all scalars, so an early close leaves every one of them in that run;
the walk stops at the first object or array value, so another setting's
"enabled" is not read as the block's. The stock example's block is followed
by a _comment string and then an object, so it still starts.

This path is reached only when the file fails to parse elsewhere (here the
extra brace). docs/location-privacy.md lists the case and says the example
already carries the block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Review feedback addressed (commits 5891ffea, 6b4aa59d, 2671bc4a)

  1. Conflicts with master (5891ffea, merge of 144937cd).

    • ingestNewFromDB: kept both sides. Each transmission is still redacted once by redactLocatedAdvert, and Count only received adverts when assigning node regions #2497's observedFrameEvidence runs on each observation's own frame before it is dropped. It keeps only the hop width and the reception kind, never a payload byte.
    • nodeZeroHopRegionCounts: took master's version, which moved the frame checks into StoreObs.receivedDirectAdvert. Its legacy-singleton fallback reads packetpath.AdvertRouteEvidence(tx.RawHex), which is empty for a located advert with privacy on. That evidence needs the payload length, so frameHead cannot supply it. hiddenFrame now keeps routeEvidence, computed from the whole frame at redaction, and the fallback reads tx.frameRouteEvidence(). TestRedactZeroHopLegacySingletonParity checks that hiding the advert changes no zero-hop vote. hiddenFrameBaseBytes is now 32+16.
    • GET /api/analytics/observer-comparison (Compare observers against a pinned reference #2492) is classified in TestLocationLeakRoutes with the observer routes. It returns observer IDs, names, reception counts and SNR deltas, with no position. It is requested with and without region. It was the only route added since the last merge.
    • ingestNewFromDB now takes a clientCount (Skip live packet formatting when the WebSocket hub is empty #2511). The one test call passes nil.
  2. The stock config could not be enabled (6b4aa59d). Fixed at the root: Config.Areas is now AreaMap. Its UnmarshalJSON skips a _-prefixed key whose value is not an object, as a comment, and decodes every other key as an AreaEntry. A "_comment": {} object is still an area, as TestConfigAreasDocumentedResponses expects. The ingestor has no areas field and already loads the example, so nothing changes there. New tests, all red before the change:

    • TestConfigExampleParses: the stock file parses and LoadConfig returns its values.
    • TestAreaMapSkipsCommentKeys.
    • TestLocationPrivacyStockExampleEnabledStarts: the stock file, with the block enabled and a secret, loads, turns privacy on and passes the startup checks.

    TestLocationPrivacyStockExampleWithSyntaxErrorStarts now requires the stock file to parse. It also edits only the locationPrivacy block, because other blocks in the example say "enabled": false too.

  3. Non-blocking: a disabled block closed early, with "enabled": true after it (2671bc4a). This case still reaches the raw fallback after point 2: the extra brace is a parse error. The fallback now also refuses when a key of the block (enabled, radiusM, secret, matched with escapes and case folding as encoding/json does) is among the scalar members right after the block. The block's members are all scalars, so an early close leaves every one of them in that run. The walk stops at the first object or array value, so another setting's enabled is not read as the block's. Tests:

    • Five new TestLocationPrivacyFailClosed cases: comment in between, ENABLED, escaped key, secret only, and another block's enabled (starts).
    • Your two-edit case applied to the stock file.

    One case still starts: valid JSON whose block says "enabled": false and that also has a top-level "enabled": true. That takes a third edit to rebalance the braces, and the decoder ignores the unknown key. I left it.

  4. Non-blocking: an unreadable config without the env secret starts on defaults. No change. It is documented.

  5. Docs. The Quick start was right once point 2 was fixed. It now says that a copy of config.example.json already has the block, so you only set enabled to true. The "Unparseable config" item now covers a block that says "enabled": false and is closed early.

Tests:

  • cmd/server passes in full at 2671bc4a.
  • cmd/ingestor passes in full at the merge commit; it is unchanged after that.
  • sh test-all.sh passes.
  • ESLint on public/*.js: 0 errors.

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.

2 participants