Repository navigation
Harden third-party dependency boundaries - #71
Merged
Merged
Conversation
- Go toolchain & build hygiene:
- Update go/go.mod to go 1.27.3 to match .goversion and export GOTOOLCHAIN in go/build.sh.
- Exclude stale xterm.js from sshterm-server's embedded docroot.
- Centralized third-party dependency workarounds (go/internal/depfix):
- Add feature-flagged workarounds and depfix.WithDisabled helper so each vulnerability and its remediation can be verified in dual-mode tests and cleanly removed once fixed upstream.
- github.com/pkg/sftp (EnableSFTPPacketGuard, EnableSFTPPathAndRemoveGuard, EnableSFTPResourceGuard):
- Interpose sftpSafeConn via sftp.NewClientPipe to bounds-check incoming SFTP packets (SSH_FXP_VERSION, SSH_FXP_STATUS, SSH_FXP_HANDLE, SSH_FXP_DATA, SSH_FXP_NAME, SSH_FXP_ATTRS) before pkg/sftp unmarshals them with unchecked slice bounds.
- Reject 0-byte SSH_FXP_DATA responses that trigger an infinite read loop in File.readChunkAt, cap cumulative SSH_FXP_READDIR entries, and reject READDIR filenames containing '/' or resolving to '.' / '..'.
- Provide Lstat-based depfix.RemoveAll so recursive removal does not follow directory symlinks, and wrap JS callback boundaries in jsutil.TryCatch.
- golang.org/x/crypto/ssh & ssh/agent (EnableSSHAgentGuard, EnableRSASHA2, EnableSSHSessionExitGuard, EnableCertSignatureGuard):
- Bound concurrent forwarded agent channels, cap incoming agent request frames to 256 KiB before agent.ServeAgent pre-allocates up to 16 MiB, and reject non-list/sign agent message types before ServeAgent parses attacker-supplied keys.
- Implement ssh.MultiAlgorithmSigner on dynSigner and agent.ExtendedAgent on keyRing and forwardedAgent so RSA keys and certificates use rsa-sha2-256 / rsa-sha2-512 instead of falling back to SHA-1 (ssh-rsa).
- Wrap SSH session channels so malformed exit-status or exit-signal requests close the channel and drain remaining requests instead of deadlocking (*ssh.Session).Wait and mux.loop.
- Reject deprecated SHA-1 (ssh-rsa) and DSA (ssh-dss) CA signatures in certificate verification and support no-touch-required (Flags=0) sk-* CA signatures.
- golang.org/x/term (EnableTermEscapeGuard):
- Terminate runaway (>64-byte) unterminated escape sequences in WrapTermReadWriter before Terminal.inBuf ([256]byte) fills up and spins in a synchronous 0-byte Read loop.
- Document the removal procedure and residual risks in go/internal/depfix/README.md.
- Frontend @xterm/xterm workarounds & terminal hardening (docroot/ssh.mjs, go/internal/terminal):
- Add window.sshApp.workarounds (csiRepGuard, csiLoopGuard, oscQueryAndLinkGuard) and applyXtermWorkarounds to clamp CSI Ps b (preventing RangeError in repeatPrecedingCharacter from wedging WriteBuffer) and CSI I/Z/L/M/S/T loop counts, and to rate-limit chained OSC 4 color queries and OSC 8 hyperlink markers.
- Sanitize and cap OSC 0 / OSC 2 window titles and reuse a single toast element in TabManager._showMessage.
- Reset terminal session modes and drain pending onData responses between SSH/SFTP sessions via Terminal.ResetSessionState.
- Local fixes:
- Fix duplicate trailing backslash append to bufRaw in go/internal/shellwords.Parse that could cause an out-of-bounds slice panic during tab completion.
- Set HandshakeTimeout on the WebSocket upgrader and per-write deadlines on upstream TCP connections in sshterm-server.
- Update CHANGELOG.md.
rthellend
marked this pull request as ready for review
October 25, 2026 15:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades
github.com/pkg/sftptov1.13.12, adds RSA SHA-2 signing support for user certificates and forwarded agents, rejects deprecated SHA-1/DSA CA signatures, and hardenssshtermandsshterm-serveragainst terminal, auto-completion, and proxy edge cases.Changes
1. SFTP Client (
github.com/pkg/sftpv1.13.12)github.com/pkg/sftptov1.13.12: Fixes upstream slice bounds panics on truncated/malformed server packets andClient.RemoveAlldirectory symlink traversal.2. SSH Client, Certificates, & Forwarded Agent (
golang.org/x/crypto/ssh)rsa-sha2-256/rsa-sha2-512) Support:ssh.MultiAlgorithmSignerondynSignerso RSA keys and RSA-backed user certificates advertise and sign withrsa-sha2-512andrsa-sha2-256.agent.ExtendedAgent(SignWithFlags) onkeyRingandforwardedAgentso remote hosts requesting SHA-2 signatures viaSSH_AGENTC_SIGN_REQUESTflags receiversa-sha2-256/rsa-sha2-512instead of falling back to SHA-1 (ssh-rsa).ssh-rsa(SHA-1) andssh-dss(DSA) CA signatures incheckCertificate.3. Tab Auto-Completion & Standalone Server (
internal/shellwords,sshterm-server,go/build.sh)shellwords.Parseso a trailing unquoted\keepsrawandargsaligned instead of panicking with an out-of-bounds slice during tab auto-completion.go/go.mod(go 1.27.3) andgo/build.sh(GOTOOLCHAIN) with.goversionso local builds do not fall back to an older host toolchain, and strips staledocroot/xterm.jsfrom the embedded server docroot.HandshakeTimeout: 10 * time.Secondonwebsocket.Upgraderand applies a write deadline (tcpDeadlineWriter) on upstream TCP writes inproxyConn.4. Frontend Terminal Hardening (
@xterm/xtermindocroot/ssh.mjs)csiRepGuard: InterceptsCSI Ps b(REP) and clampsPstoterm.cols, preventingString.prototype.repeat(2147483647)from throwing an uncaughtRangeErrorthat wedgesWriteBufferand deadlocks WASMTerminal.Write.csiLoopGuard: Clamps parameters onCSI I(CHT),CSI Z(CBT),CSI L(IL),CSI M(DL),CSI S(SU), andCSI T(SD) to terminal dimensions to prevent2^31 - 1synchronous main-thread loops.OSC 0/OSC 2titles to 128 characters while reusing a single.sshterm-toastDOM node per screen, and resets terminal modes and pending input buffers (ResetSessionState) when an SSH or SFTP session ends.Verification
go/internal/shellwords/...,go/internal/app/..., andgo/sshterm-server/...go/internal/tests/remediations_test.go