Skip to content

[fix] Enforce relay authentication and local filesystem authorization boundaries - #351

Draft
paul-fresquet wants to merge 8 commits into
masterfrom
fix/security-boundaries
Draft

paul-fresquet wants to merge 8 commits into
masterfrom
fix/security-boundaries

Conversation

@paul-fresquet

@paul-fresquet paul-fresquet commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Relay authentication must prove possession of the client's durable key, and synchronization must only access filesystem locations explicitly authorized on the local machine. This PR enforces both boundaries across login, session operations, transfers, replicated inventories, and synchronization execution.

  • Add expiring RSA-PSS authentication challenges, canonical key fingerprints, authentication epoch 1 and protocol V3. Keep the existing readable ClientId separate from cryptographic Identity; bind both to the signed challenge. Use verified identity and epoch for JWTs, refresh tokens, SignalR subscriptions and authorization.
  • Authenticate trust-completion notifications with the sender's verified fingerprint and instance. Match the expected peer instance, identity and exchange salt on the recipient; consume each response once and keep colliding readable aliases independent.
  • Keep explicit key renewal coherent across stored RSA keys, readable ClientId, fingerprint and runtime instance. Drain old refresh work, stop the old hub, clear its tokens/endpoint and start a fresh login. Refuse renewal during sessions or pending authentication attempts; ordinary reconnections retain the same identity.
  • Enforce session membership, resource ownership, route/body consistency and single-use join proofs. Resend the same unexpired join proof after a lost SignalR notification without extending its expiry or allowing a second finalization. Scope storage URLs to authorized transfer parts and operations.
  • Persist exact local source permissions independently of replicated data. Resolve synchronization paths through local grants and source-relative paths, validate complete plans before execution, and use native filesystem operations that refuse links and substituted paths.
  • Consume challenges atomically with one Redis 6.0-compatible Lua GET/DEL script. Add an offline regression guard for Redis API overloads, Lua commands and audited dependency versions.
  • Stop automatic reconnection after HTTP 404 on auth/challenge, without attempting legacy login. Display an actionable English/French relay compatibility error while preserving retries for transient failures.

Compatibility and rollout

This is a breaking protocol change: relay and session peers must use matching V3 builds, including the revised canonical login message and identity-bound trust confirmations in this unreleased PR. Existing ClientId codes retain their stored ABCD-EFG-HIJ format across the client, public-key information, login, server records, endpoints and JWT ClientId claim. Startup and login do not reset ClientId, regenerate RSA keys or clear trusted peers. The existing explicit manual-renewal action still regenerates keys/readable code and clears trust after confirmation; it now synchronizes the runtime identity and connection too.

Identity is the full RSA fingerprint, and ClientInstanceId remains <Identity>_<GUID>. Readable aliases never grant authority: collisions cannot merge identities or adopt legacy records, and existing peer trust still requires the previously accepted key. Dormant profile/lobby ownership checks use an explicit slot identity without adding profile migration. Legacy tokens, sessions and remote relationships are not silently promoted. Restored profiles require prior local enrollment of their exact sources.

Filesystem access deliberately rejects symlinks, reparse points, hard-linked file content, UNC/device sources and unsafe relative paths. Directory deletion remains nonrecursive.

Deployment requires a coordinated client/relay cutover. No Azure configuration, deployment, or Functions build-SDK migration is included.

Validation

The solution, including the migrated Functions integration/E2E fixtures, builds with zero errors. Existing warnings remain. git diff --check passes.

Suite Passed Failed Local validation date
Server unit tests, excluding service-dependent repository/integration suites 431 0 November 22, 2026
Functions unit tests 66 0 November 22, 2026
Common unit tests 54 0 November 22, 2026
Client unit tests 1,317 0 November 22, 2026

The latest client suite passes 1,317 tests with zero failures, including 18 additional cases for coherent manual key renewal, real RSA-PSS login after renewal, token clearing, refusal/failure paths, refresh draining, automatic restart and UI availability. Pending relay reconnection does not block displaying the renewed identity. The 431 server, 66 Functions and 54 Common results above are from the preceding P1 validation; backend production code is unchanged and these suites were not rerun for the client-only P2 correction.

P2 coverage reaches 88 of 93 changed executable/instrumented lines (94.6%), including the XAML tooltip sequence point. P1 covered 56 of 57 changed executable production lines (98.2%), with 100% coverage of the trust-confirmation handler. These change-specific metrics do not establish the PR-wide Sonar gate.

Trust-confirmation regressions cover authenticated issuer metadata, same-alias peers and distinct instances of one key, incorrect identity/instance/session, recipient key binding, expired join attempts, old exchanges and duplicate confirmations. Other existing regressions cover preserved readable IDs and saved keys/trust at startup/login, signed authentication and refresh replay, join-proof retry/finalization, storage scope, Redis 6.0 compatibility and local filesystem authorization.

Dependencies were restored from the local NuGet cache. No Azure services or Docker were used. P1 and P2 from the review are both addressed.

Functions integration and E2E fixtures now request and sign challenges, use current identity/epoch refresh records and server storage object IDs, and authenticate join validation as the validator. They compile but were not executed because Azure access and Docker startup are prohibited for this task. The correction commit uses [skip ci] to avoid automatically invoking the existing Azure/container workflows after the requested push.

Twelve POSIX-only client cases did not execute on Windows. Earlier local filesystem integration validation passed 40 tests, with six OS/ACL cases not executed.

Remaining validation

  • Four explicit real Redis 6.0 integration cases remain unexecuted after Docker failed. Docker was not restarted and the tests were not run against hosted caches.
  • Native Linux/macOS filesystem behavior, supported architecture coverage, and multi-machine synchronization require validation.
  • Windows line coverage for LocalPathSafety was 63%, below the 85% target; no exclusions hide the unexecuted POSIX paths. The PR-wide 80% Sonar gate has not yet been demonstrated.

See the implementation, validation and rollout report for detailed evidence and limitations.

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