Skip to content

security: pass 2 batch 1 - dashboard XSS, readonly writes, rate limiting, fetch queue exposure, OSM tile policy - #10

Merged
MatMatt merged 2 commits into
masterfrom
security/pass2-quickwins
Sep 21, 2026
Merged

MatMatt merged 2 commits into
masterfrom
security/pass2-quickwins

Conversation

@MatMatt

@MatMatt MatMatt commented Sep 21, 2026

Copy link
Copy Markdown
Owner

What this fixes

Pass 2, batch 1 of the security review (earthgrid-security-report.md): the small, independently shippable findings. One commit per topic.

ecde913 - security batch 1

Finding Change
H1 Collection names in the beacon node cards are escaped, and sensorLabel() escapes its result so the coverage keys that reach the tooltip, the detail panel and both coverage tables through another node's coverage data cannot inject markup either.
M1 The admin console escapes the STAC-derived strings (item.id, item.tile, item.datetime, the tile list, the date range) and every remote error/message at the call site, so the deliberately bold log lines still render.
M2 A readonly session no longer satisfies AccessLevel::Write, and /api/admin/activity requires the admin role with its limit capped at 500.
M3 The rate limiter is attached to the router (300/min, 60 per 2 s). X-Forwarded-For is no longer read at all - the first value is client-settable and made the limiter bypassable with one header - and X-Real-IP is honoured only when the peer is the local ingress (loopback or the bridge address). /health, /api/health, /, /assets/* are exempt, as are /api/chunks/* requests presenting the grid key, so inter-node transfers are not throttled.
M4 / L6 GET /api/fetch/queue and /{id} require write access (the console's session cookie and the grid key both still work; anonymous callers now get 401). The remote queue client encodes its status filter and reports a refused or malformed response instead of treating it as an empty list.

89da263 - OpenStreetMap tile usage policy

Both embedded maps requested https://{s}.tile.openstreetmap.org/..., which is the rotation the policy forbids, and sent no Referer because the vhost inherits Referrer-Policy: same-origin from ssl.conf. Since the vhost header is shared by every service it is not touched here: the layer now uses the exact policy URL, sets referrerPolicy: 'strict-origin-when-cross-origin' (Leaflet sets the attribute on each tile image, which overrides the document policy) and shows the required attribution - the coverage map had attributionControl: false, so the credit goes into its legend. The CARTO dark/light layers are untouched and still serve their keyless watermark; replacing them is a separate decision.

Verification

  • cargo build --release clean, zero warnings; cargo test 187 passed, 0 failed, 1 ignored, plus 2 ignored doc-tests.
  • node --check on every <script> block of ui.html and beacon.html.
  • Three independent read-only adversarial passes (round 1 PARTIAL on all five findings, round 2 VERIFIED on both XSS items and PARTIAL on the auth/limiter items, round 3 VERIFIED on the queue handling). The rounds are what produced the call-site escaping, the positive role list in the console and the path-scoped key exemption.
  • Live on the running node: anonymous GET /api/fetch/queue 401, the same request with the grid key 200 listing 99 jobs, /dashboard 200, node still present in /api/beacon/nodes, one queued fetch completed 1/1 with no error, and a real OpenStreetMap tile now returns ~53 KB of imagery instead of the 6.9 KB block notice.

Known residuals (not addressed here)

  • Replication's own chunk requests do not carry the grid key, so the /api/chunks/* exemption does not cover them. LAN peers stay exempt via the LAN rule; public peers would be throttled. This belongs with the replication work (report H4 / Cluster 1).
  • The console guard for the queue uses the cached role, so a role change mid-session can suppress or (for a stale admin) still attempt the request. The 5 s refresh and the refresh button both re-check.
  • The showAlert() sinks and the coverage plugin paths are unchanged.

…-limit the API, gate the fetch queue

H1: escape collection names in the beacon node cards and the coverage labels
that reach the dashboard through another nodes registration and coverage data.
M1: escape the STAC-derived strings and error text the admin console renders,
at the call sites, keeping the deliberate bold log lines intact.
M2: a readonly session no longer satisfies AccessLevel::Write, and
/api/admin/activity requires the admin role with a capped limit.
M3: attach the rate limiter to the router; stop trusting X-Forwarded-For and
accept X-Real-IP only from the local ingress; exempt static assets, /api/health
and key-authenticated /api/chunks requests.
M4/L6: /api/fetch/queue and /{id} require write access; remote queue calls
encode the status filter and no longer read a refusal as an empty list.
… maps

Use the exact bare-host tile URL instead of the forbidden s subdomain
rotation, set referrerPolicy so the Referer is sent (the vhost inherits a
same-origin policy from ssl.conf, and Leaflet sets the attribute on each tile
image), and show the required OpenStreetMap attribution - the coverage map had
attributionControl disabled, so the credit goes into its legend.
@MatMatt
MatMatt merged commit b0ca845 into master Sep 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant