[PR #6805] [MERGED] [client] Sanitize peer FQDN/hostname in generated SSH config #27126

Closed
opened 2026-08-05 07:08:14 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6805
Author: @riccardomanfrin
Created: 7/16/2026
Status: Merged
Merged: 7/17/2026
Merged by: @riccardomanfrin

Base: 0.74.7-branchHead: fix/ghsa_fix_ssh_fqdn_injection


📝 Commits (1)

  • f9e033f [client] [H28] Fix SSH config possible injection via peer FQDN / hostname

📊 Changes

2 files changed (+51 additions, -2 deletions)

View changed files

📝 client/ssh/config/manager.go (+12 -2)
📝 client/ssh/config/manager_test.go (+39 -0)

📄 Description

Describe your changes

Validate peer-supplied FQDN and hostname before they are written into the
generated NetBird SSH client config (client/ssh/config/manager.go). These
values originate from remote peers and were previously written verbatim into
the config; malformed values (e.g. containing unexpected characters) could
produce a broken or unintended config. FQDN/hostname are now checked with
domain.IsValidDomainNoWildcard, and invalid, non-empty values are dropped
with a warning. IPs are unaffected (already validated netip.Addr). Added a
test covering malformed hostnames.

Internal input-validation hardening for peer-supplied hostnames in the
generated SSH client config (client/ssh/config/manager.go).

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)

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)

Internal client SSH config generation. No public API, gRPC, CLI/service flag,
or configuration change — only input validation on peer-supplied hostnames
before they are written to the generated ssh_config.

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

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

N/A


🔄 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/6805 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 7/16/2026 **Status:** ✅ Merged **Merged:** 7/17/2026 **Merged by:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Base:** `0.74.7-branch` ← **Head:** `fix/ghsa_fix_ssh_fqdn_injection` --- ### 📝 Commits (1) - [`f9e033f`](https://github.com/netbirdio/netbird/commit/f9e033f05c0bf2411ea9bad094b3d82aa7b48824) [client] [H28] Fix SSH config possible injection via peer FQDN / hostname ### 📊 Changes **2 files changed** (+51 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `client/ssh/config/manager.go` (+12 -2) 📝 `client/ssh/config/manager_test.go` (+39 -0) </details> ### 📄 Description ## Describe your changes Validate peer-supplied FQDN and hostname before they are written into the generated NetBird SSH client config (`client/ssh/config/manager.go`). These values originate from remote peers and were previously written verbatim into the config; malformed values (e.g. containing unexpected characters) could produce a broken or unintended config. FQDN/hostname are now checked with `domain.IsValidDomainNoWildcard`, and invalid, non-empty values are dropped with a warning. IPs are unaffected (already validated `netip.Addr`). Added a test covering malformed hostnames. ## Issue ticket number and link Internal input-validation hardening for peer-supplied hostnames in the generated SSH client config (`client/ssh/config/manager.go`). ## Stack - \#6726 <!-- branch-stack --> - \#6805 :point\_left: ### 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) > 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) Internal client SSH config generation. No public API, gRPC, CLI/service flag, or configuration change — only input validation on peer-supplied hostnames before they are written to the generated ssh\_config. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from <https://github.com/netbirdio/docs> here: N/A --- <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 07:08:14 -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#27126