headscale/hscontrol/policy/v2
Kristoffer Dalby 1f32c8bf61 policy/v2: add IsTagged() guards to prevent panics on tagged nodes
Three related issues where User().ID() is called on potentially tagged
nodes without first checking IsTagged():

1. compileACLWithAutogroupSelf: the autogroup:self block at line 166
   lacks the !node.IsTagged() guard that compileSSHPolicy already has.
   If a tagged node is the compilation target, node.User().ID() may
   panic. Tagged nodes should never participate in autogroup:self.

2. compileSSHPolicy: the IsTagged() check is on the right side of &&,
   so n.User().ID() evaluates first and may panic before short-circuit
   can prevent it. Swap to !n.IsTagged() && n.User().ID() == ... to
   match the already-correct order in compileACLWithAutogroupSelf.

3. invalidateAutogroupSelfCache: calls User().ID() at ~10 sites
   without IsTagged() guards. Tagged nodes don't participate in
   autogroup:self, so they should be skipped when collecting affected
   users and during cache lookup. Tag status transitions are handled
   by using the non-tagged version's user ID.

Fixes #2990
2026-02-03 16:53:15 +01:00
..
filter.go policy/v2: add IsTagged() guards to prevent panics on tagged nodes 2026-02-03 16:53:15 +01:00
filter_test.go policy/v2: use partial IPSet on group resolution errors in autogroup:self path 2026-02-03 16:53:15 +01:00
policy.go policy/v2: add IsTagged() guards to prevent panics on tagged nodes 2026-02-03 16:53:15 +01:00
policy_test.go policy/v2: add test for issue #2990 same-user tagged device 2026-02-03 16:53:15 +01:00
types.go policy/v2: validate SSH source/destination combinations 2026-01-21 17:01:30 +00:00
types_test.go policy: update tests for SSH validation rules 2026-01-21 17:01:30 +00:00
utils.go modernize: run gopls modernize to bring up to 1.25 (#2920) 2025-12-01 19:40:25 +01:00
utils_test.go integration: replace time.Sleep with assert.EventuallyWithT (#2680) 2025-07-10 23:38:55 +02:00