Skip to content

Harden auth and client security boundaries#15

Merged
thegoodduck merged 1 commit into
masterfrom
thegoodduck/security-audit
May 25, 2026
Merged

Harden auth and client security boundaries#15
thegoodduck merged 1 commit into
masterfrom
thegoodduck/security-audit

Conversation

@thegoodduck

Copy link
Copy Markdown
Collaborator

This hardens several high-risk trust boundaries found in the security audit: session token exposure in cookies, mutable auth endpoint routing, private key persistence in localStorage, and unescaped untrusted text in settings alerts.

What changed

  • Marked the relay jwt cookie as HttpOnly both when setting and clearing it in relay-server/relay-server-enhanced.js.
  • Added a trusted auth origin in src/config.ts (config.auth.api) and updated AuditService auth/session calls (/api/me, vote authorize/confirm, poll-policy, OAuth start) to use it instead of mutable relay overrides.
  • Hardened DM key storage in src/services/chatService.ts:
    • keypairs now persist in IndexedDB metadata via StorageService
    • newly generated private keys are non-extractable
    • legacy localStorage keypairs are migrated once and removed
  • Escaped user-controlled relay/bootstrap labels before injecting them into alertController content in src/views/SettingsPage.vue.
  • Added rel="noopener noreferrer" to the external Tor Browser link in src/views/ResiliencePage.vue.
  • Updated src/services/copilot-services.md to reflect chat key storage hardening.
  • package-lock.json updated from dependency install during verification.

Notes for reviewers

  • Auth/session requests are intentionally pinned to the trusted backend origin and no longer follow runtime relay API overrides.
  • The chat key migration path preserves existing users by importing old localStorage keypairs on first run, then deleting the legacy entry.

- Mark JWT cookie HttpOnly on set and clear in relay server\n- Pin auth/session endpoints to trusted backend origin in config/audit service\n- Move chat keypair storage out of localStorage and migrate legacy keys\n- Escape untrusted relay/bootstrap labels in settings alerts\n- Add noopener noreferrer to external Tor guide link\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 24, 2026 23:58
@thegoodduck thegoodduck merged commit 5373f84 into master May 25, 2026
1 check failed
@thegoodduck thegoodduck removed the request for review from Copilot May 25, 2026 00:20
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