Skip to content

security: time out stalled SSH handshakes after 15s - #8335

Merged
unknwon merged 3 commits into
mainfrom
GHSA-xp79-5mx3-jx52
Jun 7, 2026
Merged

unknwon merged 3 commits into
mainfrom
GHSA-xp79-5mx3-jx52

Conversation

@unknwon

@unknwon unknwon commented Jun 7, 2026

Copy link
Copy Markdown
Member

Describe the pull request

The built-in SSH server accepted TCP connections and handed them to ssh.NewServerConn without setting a read deadline on the underlying socket. A client that connected but never sent the SSH banner held a file descriptor and goroutine open for the lifetime of the process. The deadline is now set to 15 seconds for the handshake and cleared once the session is established.

This bounds per-connection FD lifetime and lets the server recover automatically after a flood stops. It does not by itself prevent a sustained flood from saturating the FD budget while the attack is running.

Refs GHSA-xp79-5mx3-jx52.

Checklist

Test plan

  1. Configure Gogs with the built-in SSH server enabled ([server] START_SSH_SERVER = true).
  2. Open a TCP connection to the SSH port and do not send any data (for example nc <host> 2222 < /dev/null while suspending output).
  3. Before this change: the connection stays open indefinitely and the corresponding goroutine and FD remain held until the process exits.
  4. After this change: the server closes the connection after 15 seconds with a handshake EOF and releases the FD/goroutine.
  5. Confirm a legitimate git clone ssh://... still completes normally well under 15 seconds.

@unknwon unknwon added this to the 0.14.3 milestone Jun 7, 2026
@unknwon
unknwon merged commit 7da9cda into main Jun 7, 2026
8 checks passed
@unknwon
unknwon deleted the GHSA-xp79-5mx3-jx52 branch June 7, 2026 03:27
unknwon added a commit that referenced this pull request Jun 7, 2026
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

⌂ 换网址