-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Milestone
@nblock
Description
Is this a support request?
- This is not a support request
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Headscale crashes when a tagged node is converted to a personal node:
INF Starting node registration using key: 1L7lCnkWZ-neNM_azbeDIYWP
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x137f7d2]
goroutine 146 [running]:
github.com/juanfont/headscale/hscontrol/types.UserView.Name(...)
/home/runner/work/headscale/headscale/hscontrol/types/types_view.go:97
github.com/juanfont/headscale/hscontrol/state.(*State).HandleNodeFromAuthPath(0xc0002a0730, {0xc00042c918, 0x18}, 0x1, 0x0, {0x202f970, 0x3})
/home/runner/work/headscale/headscale/hscontrol/state/state.go:1471 +0xcf2
github.com/juanfont/headscale/hscontrol.headscaleV1APIServer.RegisterNode({{}, 0x41da00?}, {0x48?, 0xc0007624f0?}, 0xc0002a0ff0)
/home/runner/work/headscale/headscale/hscontrol/grpcv1.go:259 +0x2e9
github.com/juanfont/headscale/gen/go/headscale/v1._HeadscaleService_RegisterNode_Handler({0x1fe9bc0, 0xc000404120}, {0x23ea498, 0xc00077fa70}, 0xc0002bea00, 0x0)
/home/runner/work/headscale/headscale/gen/go/headscale/v1/headscale_grpc.pb.go:707 +0x1a9
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000390b48, {0x23ea498, 0xc00077f9e0}, 0xc000406820, 0xc0003b45a0, 0x36094c0, 0x0)
/home/runner/go/pkg/mod/google.golang.org/grpc@v1.78.0/server.go:1428 +0x1192
google.golang.org/grpc.(*Server).handleStream(0xc000390b48, {0x23eaf18, 0xc0003c1380}, 0xc000406820)
/home/runner/go/pkg/mod/google.golang.org/grpc@v1.78.0/server.go:1832 +0xdc6
google.golang.org/grpc.(*Server).serveStreams.func2.1()
/home/runner/go/pkg/mod/google.golang.org/grpc@v1.78.0/server.go:1063 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 144
/home/runner/go/pkg/mod/google.golang.org/grpc@v1.78.0/server.go:1074 +0x11d
Expected Behavior
Successful conversion.
Steps To Reproduce
- Create a tagged preauthkey:
headscale preauthkeys create --tags tag:some - Register:
tailscale up --login-server=https://headscale.example.com --auth-key hskey-auth-... - Create a headscale user:
headscale user create alice - Force reauth:
tailscale up --login-server=https://headscale.example.com --advertise-tags= --force-reauth - Crash:
headscale nodes register --user alice --key ...
Environment
- OS: Debian 13 - Headscale version: 0.28.0-beta.2 - Tailscale version: 0.92.5
Runtime environment
- Headscale is behind a (reverse) proxy
- Headscale runs in a container
Debug information
I noticed that headscale does not crash when the node was initially registered as personal node (using OIDC). Because then nodes.user_id is set and this field is not cleared when converting from personal to tagged. So converting back seems to reuse the stale nodes.user_id. It crashes reliably when the node was registered with a tagged PAK.
Shouldn't nodes.user_id always be set to NULL when converting from personal to tagged?