You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/safesocket
Nick Khyl 2917ea8d0e ipn/ipnauth, safesocket: defer named pipe client's token retrieval until ipnserver needs it
An error returned by net.Listener.Accept() causes the owning http.Server to shut down.
With the deprecation of net.Error.Temporary(), there's no way for the http.Server to test
whether the returned error is temporary / retryable or not (see golang/go#66252).

Because of that, errors returned by (*safesocket.winIOPipeListener).Accept() cause the LocalAPI
server (aka ipnserver.Server) to shut down, and tailscaled process to exit.

While this might be acceptable in the case of non-recoverable errors, such as programmer errors,
we shouldn't shut down the entire tailscaled process for client- or connection-specific errors,
such as when we couldn't obtain the client's access token because the client attempts to connect
at the Anonymous impersonation level. Instead, the LocalAPI server should gracefully handle
these errors by denying access and returning a 401 Unauthorized to the client.

In tailscale/tscert#15, we fixed a known bug where Caddy and other apps using tscert would attempt
to connect at the Anonymous impersonation level and fail. However, we should also fix this on the tailscaled
side to prevent a potential DoS, where a local app could deliberately open the Tailscale LocalAPI named pipe
at the Anonymous impersonation level and cause tailscaled to exit.

In this PR, we defer token retrieval until (*WindowsClientConn).Token() is called and propagate the returned token
or error via ipnauth.GetConnIdentity() to ipnserver, which handles it the same way as other ipnauth-related errors.

Fixes #18212
Fixes tailscale/tscert#13

Signed-off-by: Nick Khyl <nickk@tailscale.com>
4 days ago
..
basic_test.go safesocket: add ConnectContext 2 years ago
pipe_windows.go ipn/ipnauth, safesocket: defer named pipe client's token retrieval until ipnserver needs it 4 days ago
pipe_windows_test.go ipn/ipnauth, safesocket: defer named pipe client's token retrieval until ipnserver needs it 4 days ago
safesocket.go feature/featuretags, all: add build features, use existing ones in more places 3 months ago
safesocket_darwin.go safesocket, version: fix safesocket_darwin behavior for cmd/tailscale (#15275) 10 months ago
safesocket_darwin_test.go safesocket, version: fix safesocket_darwin behavior for cmd/tailscale (#15275) 10 months ago
safesocket_js.go safesocket: add ConnectContext 2 years ago
safesocket_plan9.go safesocket: fix Plan 9 implementation 9 months ago
safesocket_ps.go feature/featuretags: make CLI connection error diagnostics modular 3 months ago
safesocket_test.go all: update copyright and license headers 3 years ago
unixsocket.go all: fix new lint warnings from bumping staticcheck 1 year ago
zsyscall_windows.go ipn, safesocket: use Windows token in LocalAPI 2 years ago