Skip to content

tailcat: don't crash the server when a client resets before it's served - #188

Merged
bradfitz merged 1 commit into
mainfrom
bradfitz/pr167
Nov 18, 2026
Merged

bradfitz merged 1 commit into
mainfrom
bradfitz/pr167

Conversation

@bradfitz

@bradfitz bradfitz commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

[Moved from #167 by @bra1nDump]

gonet's LocalAddr and RemoteAddr return nil once the connection is no
longer connected. If the client resets a connection right after the
handshake, before netstack calls the OnTCP handler, ExecConnHandler
passed those nil addresses to PeerEnv, whose remote.String() panicked
and took the whole server down with every other connection on it:

panic: runtime error: invalid memory address or nil pointer dereference
tailcat.(*Server).PeerEnv            tailcat_exec.go:49
tailcat.(*Server).ExecConnHandler.func1  tailcat_exec.go:29
netstack.(*Impl).acceptTCP

ExecConnHandler now closes such a connection without running the
command, and PeerEnv leaves out an address it doesn't have (an SSH
session's connection can be reset at any time too).

gonet's LocalAddr and RemoteAddr return nil once the connection is no
longer connected. If the client resets a connection right after the
handshake, before netstack calls the OnTCP handler, ExecConnHandler
passed those nil addresses to PeerEnv, whose remote.String() panicked
and took the whole server down with every other connection on it:

    panic: runtime error: invalid memory address or nil pointer dereference
    tailcat.(*Server).PeerEnv            tailcat_exec.go:49
    tailcat.(*Server).ExecConnHandler.func1  tailcat_exec.go:29
    netstack.(*Impl).acceptTCP

ExecConnHandler now closes such a connection without running the
command, and PeerEnv leaves out an address it doesn't have (an SSH
session's connection can be reset at any time too).

Signed-off-by: Kirill <kirill2003de@gmail.com>
@bradfitz
bradfitz merged commit 913b282 into main Nov 18, 2026
9 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.

2 participants