[GH-ISSUE #6637] Bug: Groups can be deleted while referenced in service access_groups #12228

Open
opened 2026-08-05 01:32:41 -04:00 by saavagebueno · 2 comments
Owner

Originally created by @bcross on GitHub (Jul 1, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/6637

Description

Groups can be deleted even if they are referenced in a service's access_groups field, which should prevent deletion.

Current Behavior

The validateDeleteGroup function in management/server/group.go performs validation checks to prevent deletion of groups that are linked to various entities such as:

  • Routes (including AccessControlGroups)
  • Policies
  • Setup keys
  • Users
  • DNS name server groups
  • Network routers
  • Settings (flow groups, disabled DNS management groups)

However, services with access_groups are not checked, allowing a group to be deleted even if it's actively referenced by a private service.

Expected Behavior

Group deletion should fail with an appropriate error message when the group is referenced in any service's access_groups field, consistent with other linkage checks.

Impact

  • Groups referenced by private services can be orphaned
  • Service access control configuration becomes compromised
  • Undefined behavior may occur when the service attempts to reference the deleted group

Steps to Reproduce

  1. Create a private service with at least one access group
  2. Attempt to delete the group referenced in the service's access_groups field
  3. Current result: Deletion succeeds (bug)
  4. Expected result: Deletion should fail with error message indicating group is linked to a service

Code Location

The missing validation should be added to the validateDeleteGroup function at:

  • File: management/server/group.go (lines 689-738)
  • Similar to the existing route check (lines 713-715)

Suggested Fix

Add a check similar to the existing route validation:

if isLinked, linkedService := isGroupLinkedToService(ctx, transaction, group.AccountID, group.ID); isLinked {
    return &GroupLinkError{"service", linkedService.ID}
}

This check should verify if the group is referenced in any service's AccessGroups field before allowing deletion.

References

  • Services with private access are validated to require AccessGroups in management/internals/modules/reverseproxy/service/service.go
  • Similar checks already exist for routes, policies, and other entities in management/server/group.go
Originally created by @bcross on GitHub (Jul 1, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/6637 ## Description Groups can be deleted even if they are referenced in a service's `access_groups` field, which should prevent deletion. ## Current Behavior The `validateDeleteGroup` function in `management/server/group.go` performs validation checks to prevent deletion of groups that are linked to various entities such as: - Routes (including `AccessControlGroups`) - Policies - Setup keys - Users - DNS name server groups - Network routers - Settings (flow groups, disabled DNS management groups) However, **services with `access_groups` are not checked**, allowing a group to be deleted even if it's actively referenced by a private service. ## Expected Behavior Group deletion should fail with an appropriate error message when the group is referenced in any service's `access_groups` field, consistent with other linkage checks. ## Impact - Groups referenced by private services can be orphaned - Service access control configuration becomes compromised - Undefined behavior may occur when the service attempts to reference the deleted group ## Steps to Reproduce 1. Create a private service with at least one access group 2. Attempt to delete the group referenced in the service's `access_groups` field 3. **Current result**: Deletion succeeds (bug) 4. **Expected result**: Deletion should fail with error message indicating group is linked to a service ## Code Location The missing validation should be added to the `validateDeleteGroup` function at: - File: `management/server/group.go` (lines 689-738) - Similar to the existing route check (lines 713-715) ## Suggested Fix Add a check similar to the existing route validation: ```go if isLinked, linkedService := isGroupLinkedToService(ctx, transaction, group.AccountID, group.ID); isLinked { return &GroupLinkError{"service", linkedService.ID} } ``` This check should verify if the group is referenced in any service's `AccessGroups` field before allowing deletion. ## References - Services with private access are validated to require `AccessGroups` in `management/internals/modules/reverseproxy/service/service.go` - Similar checks already exist for routes, policies, and other entities in `management/server/group.go`
Author
Owner

@linear-code[bot] commented on GitHub (Jul 1, 2026):

NET-1343

<!-- gh-comment-id:4861077078 --> @linear-code[bot] commented on GitHub (Jul 1, 2026): <!-- linear-linkback --> <p><a href="https://linear.app/netbird/issue/NET-1343">NET-1343</a></p>
Author
Owner

@CrazyHenk44 commented on GitHub (Aug 4, 2026):

I encountered this issue on a self-hosted combined NetBird management server running version 0.74.3.

Deleting a group referenced by seven private Reverse Proxy services left its ID in services.access_groups. This did not merely
result in an orphaned configuration: every subsequent peer synchronization crashed the complete management server.

The container entered a crash loop and restarted 23 times with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48]

github.com/netbirdio/netbird/management/server/types.filterGroupPeers(...)
management/server/types/account_components.go:491

github.com/netbirdio/netbird/management/server/types.(*Account).GetPeerNetworkMapComponents(...)
management/server/types/account_components.go:231

github.com/netbirdio/netbird/management/server.(*DefaultAccountManager).SyncPeer(...)
management/server/peer.go:1058

Recovery required stopping the management server and manually removing the deleted group ID from the affected
services.access_groups JSON arrays in SQLite. After that, peer synchronization resumed normally.

There is also a UI/UX aspect: under Access Control → Groups, there is no column or dependency indicator showing that a group is
used by Reverse Proxy services. The deletion confirmation did not list these dependencies either. I therefore assumed that the group
was unused and safe to delete.

It would be helpful if the Groups page or deletion dialog also showed Reverse Proxy service usage, in addition to fixing the server-
side deletion validation and nil handling.

<!-- gh-comment-id:5177360947 --> @CrazyHenk44 commented on GitHub (Aug 4, 2026): I encountered this issue on a self-hosted combined NetBird management server running version `0.74.3`. Deleting a group referenced by seven private Reverse Proxy services left its ID in `services.access_groups`. This did not merely result in an orphaned configuration: every subsequent peer synchronization crashed the complete management server. The container entered a crash loop and restarted 23 times with: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x48] github.com/netbirdio/netbird/management/server/types.filterGroupPeers(...) management/server/types/account_components.go:491 github.com/netbirdio/netbird/management/server/types.(*Account).GetPeerNetworkMapComponents(...) management/server/types/account_components.go:231 github.com/netbirdio/netbird/management/server.(*DefaultAccountManager).SyncPeer(...) management/server/peer.go:1058 Recovery required stopping the management server and manually removing the deleted group ID from the affected `services.access_groups` JSON arrays in SQLite. After that, peer synchronization resumed normally. There is also a UI/UX aspect: under **Access Control → Groups**, there is no column or dependency indicator showing that a group is used by Reverse Proxy services. The deletion confirmation did not list these dependencies either. I therefore assumed that the group was unused and safe to delete. It would be helpful if the Groups page or deletion dialog also showed Reverse Proxy service usage, in addition to fixing the server- side deletion validation and nil handling.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#12228