Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Bound what an unauthenticated SSH client can spend

78cd3437a597b0155682d2e8d5129bf7cdeac85d · Keenan Nemetz · 13d ago · parent b1499c72

Bound what an unauthenticated SSH client can spend

The SSH listener accepted every connection, gave each one a goroutine, and
started a process per session channel. A client that opened a socket and
never finished the handshake held all three for as long as it liked, and a
client that opened channels held a goroutine each. The host key was
hardened by `vole serve` on the way in, but the SSH package on its own
would happily load a key the whole machine could read.

Four bounds, all enforced before the expensive thing happens:

  - A handshake deadline, cleared once the handshake completes so a clone
    or a push is not cut. `ssh_handshake_timeout_seconds`, default 20.
  - `ssh_max_connections` (default 64) tokens, one per open connection. Past
    the cap the connection is closed before the handshake, the goroutine or
    the process, and the accept loop keeps running so the listener cannot be
    wedged. The "listener is full" warning is throttled to once per 10s so a
    flood cannot become a disk problem instead.
  - Eight session channels per connection, rejected at the channel layer
    rather than by spawning a goroutine per request.
  - `ssh_max_git_processes` (default 16) across every connection, covering
    upload-pack, receive-pack and vole-change-merge. A command waits up to
    30s for a slot and is then told to retry, rather than parked forever.

Payloads are bounded too: an exec line over 4 KiB is refused before it is
parsed, and a vole-runner request line over 1 MiB ends the session with an
error. The runner bound is a per-line reader, so json.Decoder's buffering
cannot hide an oversized request and a long-lived runner is not limited in
total.

Loading an existing host key now tightens it to 0600 and warns, and a mode
that cannot be tightened fails startup, so the package is safe on its own
rather than only behind `vole serve`.

Tests hold a connection without handshaking (it is dropped and its slot
returns), flood one connection with channels (the ninth is rejected and
closing one releases a slot), send an oversized exec line and an oversized
runner request (both refused), saturate the process pool (a bounded wait,
then a refusal), and load a 0644 host key (tightened).

forge/config/validate.go +9

@@ -142,6 +142,15 @@ func (c *Config) Validate() error {
142 142 if c.PagesProcs < 0 || c.PagesProcs > 64 {
143 143 add("pages_procs must be between 0 and 64, got %d", c.PagesProcs)
144 144 }
145 if c.SSHMaxConnections < 0 {
146 add("ssh_max_connections must not be negative, got %d", c.SSHMaxConnections)
147 }
148 if c.SSHMaxGitProcesses < 0 {
149 add("ssh_max_git_processes must not be negative, got %d", c.SSHMaxGitProcesses)
150 }
151 if c.SSHHandshakeTimeoutSeconds < 0 || c.SSHHandshakeTimeoutSeconds > 300 {
152 add("ssh_handshake_timeout_seconds must be between 0 and 300, got %d", c.SSHHandshakeTimeoutSeconds)
153 }
145 154 if c.GitHTTPMaxConcurrent < 0 {
146 155 add("git_http_max_concurrent must not be negative, got %d", c.GitHTTPMaxConcurrent)
147 156 }