Security: fix ws-upgrade crash, per-user TOFU eviction, token log leaks; rebuild sshterm

Panel (index.js, client, views):
- upgrade handler: error guard on every upgraded socket (any path) plus a 3s
  zero-byte orphan reaper; engine.io destroyUpgrade disabled — closes the
  unauthenticated ECONNRESET crash of the whole panel and stops engine.io's
  1s timer from killing slow ssh-terminal handshakes
- /api/ssh-terminal/session: per-session token reuse cache in front of the
  rate limiter — floating-terminal auto-restore no longer burns the 10/min
  mint budget (tokens are re-served only to the same panel session + IP)
- global error middleware redacts credential-bearing query params via
  utils/url-sanitize.js — ssh-terminal ?token= values no longer reach logs
- floating-terminal restore consumes the persisted live flag: after the
  frame reported the SSH session dead, restore drops the stored session id
  and starts a clean connect; script cache busters bumped

sshterm (cmd/sshterm/main.go, rebuilt and deployed):
- TOFU store eviction is per-user and offender-pays (per-user caps: 64 pins
  and 256 contributed advisory hosts; total caps remain as backstops that
  evict the largest contributor first) — one user flooding first-use pins
  to hosts they control can no longer evict another user's pinned key or
  suppress their divergence warning
- the store file is reloaded on mtime/size change: admin edits to
  data/ssh_known_hosts.json now take effect on the next connection without
  a restart; corrupt files keep the last good state, deleted files clear
  the store, other read errors fail closed
- regression tests for flood/eviction/reload/healing + negative controls
- also lands the previously uncommitted IP-binding, trusted-proxy,
  allowed-hosts and metadata-blocking hardening; binary rebuilt through
  initialize.sh --repair-sshterm and verified live at
  /usr/local/bin/adpanel-sshterm (sha256 6bc0363479b91e6c49af9b153c8e552fd4ad8f9a5f787d73bbdc238ce0f7579e)
This commit is contained in:
antonn committed 2026-09-23 17:50:40 +00:00
1 parent a022f29e34
commit 78193254ad
14 files changed
+21400 -4827

No files matched your search

+1 -1
View File
@@ -1111,7 +1111,7 @@
<% } %>
<script nonce="<%= cspNonce %>" data-cfasync="false" src="/socket.io/socket.io.min.js" defer></script>
<script nonce="<%= cspNonce %>" data-cfasync="false" src="/js/ssh-terminal-window.js?v=20260509-floating-terminal-5" defer></script>
<script nonce="<%= cspNonce %>" data-cfasync="false" src="/js/ssh-terminal-window.js?v=20260923-ssh-terminal-restore-7" defer></script>
<script nonce="<%= cspNonce %>" data-cfasync="false" src="/js/dashboard.js?v=20260512-dashboard-timeout-1" defer></script>
<script nonce="<%= cspNonce %>" data-cfasync="false" src="/js/status-monitor.js?v=<%= typeof themeVersion !== 'undefined' ? themeVersion : Date.now() %>" defer></script>