[PR #7062] [MERGED] [management] Prevent deleting groups referenced by reverse proxy services #30127

Closed
opened 2026-08-05 08:10:15 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/7062
Author: @mlsmaycon
Created: 8/4/2026
Status: Merged
Merged: 8/4/2026
Merged by: @mlsmaycon

Base: mainHead: fix/group-delete-reverse-proxy-link


📝 Commits (1)

  • a63bcfe [management] Prevent deleting groups referenced by reverse proxy services

📊 Changes

2 files changed (+165 additions, -0 deletions)

View changed files

📝 management/server/group.go (+25 -0)
📝 management/server/group_test.go (+140 -0)

📄 Description

Describe your changes

A group could be deleted while a reverse proxy service still referenced it, silently breaking the service's access control: private services list groups in access_groups as the peer allowlist, and SSO bearer auth distributes tokens to distribution_groups.

Group deletion now runs through the same linkage validation as routes, policies, and agent network policies: deleting a group that backs a private service allowlist or an enabled bearer-auth distribution list fails with a GroupLinkError naming the service domain. Disabled bearer configs and stale access_groups on non-private services are inert and do not block deletion.

Tests cover both linked cases in single and bulk deletion, and pin the non-blocking cases. The test account seeds decoy services ahead of the linked ones so the check is proven to scan the full service list.

NET-1343: Bug: Groups can be deleted while referenced in service access_groups

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • I ran and tested this change locally — I did not rely on CI to find out whether it works
  • This PR has a single purpose (not a fix + refactor + feature in one)
  • This change is a trivial fix, OR it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Validation-only change: group deletion behaves like the existing linkage checks for routes and policies, no new API surface or configuration.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

Summary by CodeRabbit

  • Bug Fixes
    • Prevented deletion of groups linked to private reverse proxy services.
    • Prevented deletion of groups used by enabled bearer-authentication distribution settings.
    • Deletion remains available when references are inactive or unrelated to private service access.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/7062 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 8/4/2026 **Status:** ✅ Merged **Merged:** 8/4/2026 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `fix/group-delete-reverse-proxy-link` --- ### 📝 Commits (1) - [`a63bcfe`](https://github.com/netbirdio/netbird/commit/a63bcfe10b36d13e7244d6835fd6c527f231059d) [management] Prevent deleting groups referenced by reverse proxy services ### 📊 Changes **2 files changed** (+165 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `management/server/group.go` (+25 -0) 📝 `management/server/group_test.go` (+140 -0) </details> ### 📄 Description ## Describe your changes A group could be deleted while a reverse proxy service still referenced it, silently breaking the service's access control: private services list groups in `access_groups` as the peer allowlist, and SSO bearer auth distributes tokens to `distribution_groups`. Group deletion now runs through the same linkage validation as routes, policies, and agent network policies: deleting a group that backs a private service allowlist or an enabled bearer-auth distribution list fails with a `GroupLinkError` naming the service domain. Disabled bearer configs and stale `access_groups` on non-private services are inert and do not block deletion. Tests cover both linked cases in single and bulk deletion, and pin the non-blocking cases. The test account seeds decoy services ahead of the linked ones so the check is proven to scan the full service list. ## Issue ticket number and link [NET-1343: Bug: Groups can be deleted while referenced in service access_groups](https://linear.app/netbird/issue/NET-1343/bug-groups-can-be-deleted-while-referenced-in-service-access-groups) ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] I ran and tested this change locally — I did not rely on CI to find out whether it works - [x] This PR has a single purpose (not a fix + refactor + feature in one) - [x] This change is a trivial fix, **OR** it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#ticket-first-pr-second). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Validation-only change: group deletion behaves like the existing linkage checks for routes and policies, no new API surface or configuration. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented deletion of groups linked to private reverse proxy services. * Prevented deletion of groups used by enabled bearer-authentication distribution settings. * Deletion remains available when references are inactive or unrelated to private service access. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:10:15 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30127