Skip to content

Release: S-33…S-37 security fixes (R-53…R-56) to master - #36

Merged
TurkerMertkan merged 5 commits into
masterfrom
develop
Nov 23, 2026
Merged

TurkerMertkan merged 5 commits into
masterfrom
develop

Conversation

@TurkerMertkan

Copy link
Copy Markdown
Collaborator

Summary

Brings S-33…S-37 from develop to master (5 commits): the remaining auth and transport gaps found in the S-31 review, plus the editor dev script.

Steps

  • S-33 (R-55): SOX tree reads (/api/sox/tree|comp|palette|names) and GET /file/* behind the editor gate (bearer or session cookie + Origin).
  • S-34: tools/editor-dev.sh runs the Vue editor dev server against a device (address kept out of git).
  • S-35 (R-53): tags, alerts, roxWarp/cluster and simulator routers are now inside the global layers (request counter, rate limit, 1 MiB body limit, CORS).
  • S-36 (R-54): roxWarp cluster is fail-closed: mTLS, or plain WS only with the new --cluster-insecure; a broken mTLS setup keeps the cluster network off. /roxwarp on the REST port only in plain mode.
  • S-37 (R-56): PUT /file/* accepts the session cookie with a required allowed Origin, so editor kit uploads work with auth on.

Behavior impact on the field device (auth off, --cluster without certificates, no peers)

  • Port 7443 stops listening; log says no mTLS configured, cluster listener disabled.
  • Tags/alerts/cluster endpoints share the 100 req/s rate limit and the 1 MiB body limit.
  • With auth off, the new gates pass every request: no other change in behavior.
  • No wire format change. No .deb unit or conffile change.

Tests

Each step was merged with gates and CI Test green. On develop 8df1b97, 2910 tests pass and 0 fail; push CI (incl. Build ARM) green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC

TurkerMertkan and others added 5 commits November 21, 2026 15:16
… S-33)

GET /api/sox/tree, /api/sox/comp/{id}, /api/sox/palette, /api/sox/names
and GET /file/* now sit behind check_upgrade_auth (bearer header or
sandstar_session cookie, plus Origin check), the same gate as
/live/sedonaState, which carries the same component tree.

Routes and auth layer:
- inside check_upgrade_auth: the four SOX tree reads and GET /file/*;
- PUT /file/* stays behind require_auth (bearer only);
- /library/ and GET /tags stay outside on purpose (read-only stubs, no
  device data; comment in rest/mod.rs).

Behavior: with no auth configured (field default) every request passes,
unchanged. With auth on, the browser editor keeps working: it fetches
/file/* same-origin with the session cookie after SCRAM login (S-32b).

Tests: auth_layer.rs covers 401 without/with bad credential (GET and
HEAD), exact status with cookie or bearer, same-host Origin accepted,
foreign Origin 403 with bearer or cookie, PUT /file with cookie only
401, library stubs open, auth off open. The main test fails on the old
code. Gates: 2890 passed, 0 failed. Local E2E with auth on and the
trkrDevelop editor: /file and /api/sox/tree 200 after login, 401
without.

docs: HARDCODED_LIMITS.md not needed, only tests changed there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
… (S-34)

tools/editor-dev.sh starts the sedonaWebEditor dev server on
localhost:8091 with SOX_PROXY_URL pointing at a device's 8085 port.

- Device address comes from the argument, SANDSTAR_DEVICE or the
  git-ignored tools/editor-dev.env; no host or IP is kept in the repo.
- Before starting it checks the device (/api/about version, and whether
  /live/sedonaState asks for a login) and refuses a second server on
  the same port.
- HowToUses/03_WEB_EDITOR.md: usage, empty peer, and the
  --ws-allowed-origins note for auth-on devices.

No behavior change in the server. Gates: 2890 passed, 0 failed.
Run against device 1-6: version and auth state printed, editor served
and proxied to the device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
main.rs merged the tags, alerts, roxWarp/cluster and simulator routers
after router_with_auth had applied the request counter, rate limit,
1 MiB body limit and CORS. axum layers only wrap routes added before
them, so those routes had no rate limit (unlimited bearer guesses once
auth is on), axum's 2 MiB Json default instead of 1 MiB, no CORS
preflight answer, and were not counted in /api/metrics.

Split router_with_auth into api_routes (core routes with their auth
layers, no global layers) and with_global_layers (same layers, same
order). router_with_auth keeps its signature and composes the two.
main.rs now merges every router first and applies with_global_layers
last; TLS and plain HTTP serve that same app.

Routes/auth: no auth decision changed. Every router keeps its own
require_auth / require_upgrade_auth or documented open routes. The
global layers now also wrap /api/tags*, /api/alerts/*, /roxwarp,
/api/cluster/* and the simulator routes. The 7443 cluster listener is
unchanged (R-54).

Behavior change: those routes share the global --rate-limit counter
(429 when exceeded), reject bodies over 1 MiB with 413, and answer
CORS preflight like the core routes.

Tests: new tests/global_layers.rs (429 on late GETs and before auth on
a late PUT, 413 on a 1.5 MiB PUT, CORS header and preflight); all 5
failed with the old order. auth_layer.rs builds the app in the new
order. gates: 2895 passed / 0 failed; simulator-hal check OK. Local
E2E with --rate-limit 2: 429, 413 and CORS headers on late routes.

Docs: OVERVIEW security notes, HARDCODED_LIMITS (body limit scope,
CORS line), routes-auth rule example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
With --cluster, the cluster port (default 7443) served plain WebSocket
with no peer auth when no certificates were given, and also when the
mTLS config failed to build (only an error line). Outbound peers fell
back to ws:// the same way, and /roxwarp on the REST port was always
mounted without auth, so even with mTLS a peer could bypass it there.

New roxwarp::transport decides per side (listener, outbound):
- cert, key and CA set and the rustls config builds: mTLS;
- no mTLS path and --cluster-insecure: plain WS (warn: no peer auth);
- no mTLS path and no flag: off (warn naming the flags to pass);
- broken or incomplete mTLS config: off (error), never plain WS.
main.rs builds the listener from it; ClusterManager::run builds the
outbound side from it and, when off, starts no peer connections and no
mDNS and registers no peers (the local feed still runs). /roxwarp on
the REST port is mounted only in plain mode (plain_ws_allowed, same
rule). ClusterConfig.allow_plain is serde(skip): only the CLI flag sets
it, the cluster JSON file cannot.

Routes/auth: /roxwarp on the REST port stays outside the auth layer but
exists only with --cluster-insecure. /api/cluster/status (public) and
/api/cluster/query (bearer) are unchanged.

Wire protocol: unchanged. Affected clients: roxWarp peers. A peer that
used plain WS without --cluster-insecure can no longer connect.

Behavior change: the packaged unit runs --cluster with no certificates
and an empty peer list, so after deploy port 7443 is no longer
listening (log: "no mTLS configured, cluster listener disabled"). Also:
the plain-mode serve error is now logged; the startup field "mtls" is
renamed "mtls_paths" (it reports configured paths, not a working TLS).

Tests: transport decision (no certs, flag, broken and missing files,
partial config, plain_ws_allowed matches the plain arm); /roxwarp on
the REST port mounted only in plain mode (failed on the old code);
run() registers no peers when off; config file cannot set allow_plain;
CLI flag parse. gates: 2908 passed / 0 failed; simulator-hal check OK.
Local E2E with the real binary in the three modes: port, /roxwarp and
log lines as above. Not covered: the mTLS success path with real
certificates (needs rcgen or test certificates).

Docs: OVERVIEW, HARDCODED_LIMITS, DEPLOYMENT_CHECKLIST (verify step),
research/16 status, HowToUses/06, README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
…gin (R-56, S-37)

The editor uploads kit manifests and .kit files with a same-origin
fetch PUT to /file/sedona/..., carrying only its sandstar_session
cookie. PUT /file/* sat behind check_auth (bearer only), so with auth
on every kit upload got 401. Reads already accept the cookie (S-33).

New check_write_auth / require_write_auth, used only by PUT /file/*:
- auth not configured: every request passes (field default);
- valid bearer: passes, Origin not checked (as before);
- valid session cookie: passes only with an Origin header that matches
  the Host or --ws-allowed-origins; missing or foreign Origin gets 403.
  Browsers always send Origin on PUT, so this backs up the cookie's
  SameSite=Strict against cross-site request forgery;
- otherwise 401.

Routes/auth: PUT /file/* moves from require_auth to require_write_auth
(still inside an auth layer). Every other write route stays
bearer-only; a test checks they reject the cookie. GET /file/* and
path handling (safe_join) are unchanged. Editor: no change needed.

Tests: cookie/Origin matrix on PUT /file/* (none, forged cookie,
same-host, allowlisted, missing, foreign, null, other port, subdomain,
ftp scheme, case, duplicate cookie, second Cookie header, bearer with
and without Origin); it failed on the old gate. Other write routes
reject the cookie; open when auth is off. gates: 2910 passed / 0
failed. Local E2E with the real binary (--auth-token, temp
SANDSTAR_FILE_ROOT): 401 / 200 / 200 / 403 / 403 / 401 / 200, file
written and read back with the cookie. Largest kit in the repo is
189 KB, under the 1 MiB body limit. Not tried: a real kit upload from
the editor.

Docs: OVERVIEW §3 PUT /file row, HowToUses/03_WEB_EDITOR.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
@TurkerMertkan
TurkerMertkan merged commit 3ed9600 into master Nov 23, 2026
4 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