[management] security hardening for network map

Merged
PA
9d ago
+1486-343

Describe your changes

Login expiry and blocked users

  • Login-expired flag ignored: the network map ignored the peer LoginExpired flag set when a user is blocked or a peer is expired by inactivity or the integrated validator. It only checked time-based expiry, and only when login expiration was enabled. The flag is now loaded on all account loaders (GORM, pgx, SQLite) and always treated as expired.
  • Expired peers are no longer sent to other peers: login-expired peers (flagged or time-expired) are removed from the per-peer network map components. Server-side calculation and the components envelope computed on clients both see them as absent, so released clients that calculate locally are covered without a client update.
  • No expiry check for Networks resource-policy sources: peers that reach a Networks routing peer only through a resource policy were never checked for login expiry. They were added to the router's peers and route firewall sources. Expired sources are now excluded.

NetBird SSH

  • DROP rules enabled SSH: DROP rules with the netbird-ssh protocol (and DROP rules matching legacy SSH) enabled the SSH server on the destination and could authorize every user in the account. Only Accept rules now enable SSH or add authorized users, in the network map calculation, the components envelope, PeerSSHEnabledFromPolicies and the affected-peers resolver.
  • netbird-ssh rules without ports opened all TCP: a netbird-ssh rule without ports produced a TCP rule without ports, opening every TCP port. It now resolves to port 22 (plus 22022 for supporting agents).
  • Blocked or deleted users kept NetBird SSH access: destination peers never received an updated authorized-user list.
    • Blocking a user with peers discarded the computed affected set.
    • Deleting a user never marked allowed users as changed, and a user without peers triggered no update at all.
    • SSH destinations authorizing the user (via groups or a direct temporary-access AuthorizedUser) are now updated on block and delete.
    • Temporary-access SSH rules naming a blocked user no longer authorize them or enable SSH.

Network map updates on revocation

  • Classic-route routing peers not updated on policy changes: routing peers of classic routes with access-control groups got no network map update when a policy targeting that group was changed or deleted, or its source groups changed. Their route firewall rules stayed stale. The affected-peers resolver now links policies to routes through access-control groups.
  • UpdateGroup missed removed network resources: UpdateGroup / UpdateGroups removing a network resource from a group did not update that network's routing peer when it was the last referenced resource.
  • Network map updates could be postponed indefinitely: the update debouncer restarted its timer on every incoming update with no maximum delay. A peer calling SyncMeta about once per second could keep every peer in its network map on a stale map indefinitely, including revocations. Pending updates are now flushed once per fixed interval.

Behaviour changes

  • Login-expired peers no longer appear in OfflinePeers (they are omitted entirely).
  • Policy and posture-check changes now also load account routes to resolve affected routing peers.
  • Deleting or blocking a regular user now updates SSH destination peers that authorize that user.

Issue ticket number and link

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)

bugfixes only

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

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

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • Bug Fixes
    • Peers with expired logins are now shown as offline, even when account-level login expiration is disabled.
    • SSH access now respects accepted policies and authorized-user settings; blocked users and drop rules no longer grant access.
    • SSH rules without specified ports use the default SSH port.
    • Network updates now refresh affected routing peers when policies, users, groups, or resource references change.
    • Queued updates flush at fixed intervals instead of having their timer extended by later updates.