client raising a "failed marshalling message string field contains invalid UTF-8" when trying to register the peer due to invalid SerialNumber #1058

Closed
opened 2025-11-20 05:23:15 -05:00 by saavagebueno · 1 comment
Owner

Originally created by @EdouardVanbelle on GitHub (Jul 11, 2024).

Hello I am getting an error: encryption/message.go:14: failed marshalling message string field contains invalid UTF-8
during a netbird up --key XXX --management-url YYY

NetBird version

0.28.4

More details on the reason

I have rebuilt netbird to have a better understanding of the isssue,
here is the reason: my board do not have any serialnumber !

For better understanding:

$ git diff
diff --git a/encryption/message.go b/encryption/message.go
index a646fa67..8fe76f7a 100644
--- a/encryption/message.go
+++ b/encryption/message.go
@@ -9,6 +9,7 @@ import (
 // EncryptMessage encrypts a body of the given protobuf Message
 func EncryptMessage(remotePubKey wgtypes.Key, ourPrivateKey wgtypes.Key, message pb.Message) ([]byte, error) {
        byteResp, err := pb.Marshal(message)
+       log.Debugf("DEBUG marshalling message %v", message)
        if err != nil {
                log.Errorf("failed marshalling message %v", err)
                return nil, err

which raises me:

/home/ed/netbird/client/client up --log-level debug -F --log-file console --management-url https://MYSERVER:443 --setup-key MYKEY

2024-07-11T18:35:09+02:00 DEBG client/internal/login.go:93: connecting to the Management service https://MYSERVER:443
2024-07-11T18:35:09+02:00 DEBG client/internal/login.go:63: connected to the Management service https://MYSERVER:443
2024-07-11T18:35:10+02:00 ERRO encryption/message.go:12: DEBUG marshalling message meta:{hostname:"my-pretty-nuc"  goOS:"linux"  kernel:"Linux"  core:"12"  platform:"unknown"  OS:"Debian GNU/Linux"  wiretrusteeVersion:"development"  kernelVersion:"6.1.0-22-amd64"  OSVersion:"12"  networkAddresses:{netIP:"OBFUSCATED"  mac:"OBFUSCATED"}  networkAddresses:{netIP:"OBFUSCATED"  mac:"OBFUSCATED"}  networkAddresses:{netIP:"OBFUSCATED"  mac:"OBFUSCATED"}  sysSerialNumber:"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"  sysProductName:"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"  sysManufacturer:"OVH"  environment:{}}  peerKeys:{sshPubKey:"OBFUSCATED"}
2024-07-11T18:35:10+02:00 ERRO encryption/message.go:14: failed marshalling message string field contains invalid UTF-8
2024-07-11T18:35:10+02:00 ERRO management/client/grpc.go:331: failed to encrypt message: string field contains invalid UTF-8

My device has no serial number which generated a failure on marshalling phase

and I confirm it via a dmidecode:

# dmidecode -t system

# dmidecode 3.4
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: OVH
        Product Name: .................................
        Version: .................................
        Serial Number: .................................
        UUID: OBFUSCATED
        Wake-up Type: Power Switch
        SKU Number: .................................
        Family: .................................

do you have any suggestion to prevent this ?
We could eventually use the UUID if serial number is not present ?

Kindest regards
note: I love your project !

Originally created by @EdouardVanbelle on GitHub (Jul 11, 2024). Hello I am getting an error: `encryption/message.go:14: failed marshalling message string field contains invalid UTF-8` during a `netbird up --key XXX --management-url YYY` **NetBird version** 0.28.4 **More details on the reason** I have rebuilt netbird to have a better understanding of the isssue, here is the reason: my board do not have any serialnumber ! For better understanding: ```diff $ git diff diff --git a/encryption/message.go b/encryption/message.go index a646fa67..8fe76f7a 100644 --- a/encryption/message.go +++ b/encryption/message.go @@ -9,6 +9,7 @@ import ( // EncryptMessage encrypts a body of the given protobuf Message func EncryptMessage(remotePubKey wgtypes.Key, ourPrivateKey wgtypes.Key, message pb.Message) ([]byte, error) { byteResp, err := pb.Marshal(message) + log.Debugf("DEBUG marshalling message %v", message) if err != nil { log.Errorf("failed marshalling message %v", err) return nil, err ``` which raises me: ``` /home/ed/netbird/client/client up --log-level debug -F --log-file console --management-url https://MYSERVER:443 --setup-key MYKEY 2024-07-11T18:35:09+02:00 DEBG client/internal/login.go:93: connecting to the Management service https://MYSERVER:443 2024-07-11T18:35:09+02:00 DEBG client/internal/login.go:63: connected to the Management service https://MYSERVER:443 2024-07-11T18:35:10+02:00 ERRO encryption/message.go:12: DEBUG marshalling message meta:{hostname:"my-pretty-nuc" goOS:"linux" kernel:"Linux" core:"12" platform:"unknown" OS:"Debian GNU/Linux" wiretrusteeVersion:"development" kernelVersion:"6.1.0-22-amd64" OSVersion:"12" networkAddresses:{netIP:"OBFUSCATED" mac:"OBFUSCATED"} networkAddresses:{netIP:"OBFUSCATED" mac:"OBFUSCATED"} networkAddresses:{netIP:"OBFUSCATED" mac:"OBFUSCATED"} sysSerialNumber:"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" sysProductName:"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" sysManufacturer:"OVH" environment:{}} peerKeys:{sshPubKey:"OBFUSCATED"} 2024-07-11T18:35:10+02:00 ERRO encryption/message.go:14: failed marshalling message string field contains invalid UTF-8 2024-07-11T18:35:10+02:00 ERRO management/client/grpc.go:331: failed to encrypt message: string field contains invalid UTF-8 ``` My device has no serial number which generated a failure on marshalling phase and I confirm it via a dmidecode: ``` # dmidecode -t system # dmidecode 3.4 Getting SMBIOS data from sysfs. SMBIOS 2.8 present. Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: OVH Product Name: ................................. Version: ................................. Serial Number: ................................. UUID: OBFUSCATED Wake-up Type: Power Switch SKU Number: ................................. Family: ................................. ``` do you have any suggestion to prevent this ? We could eventually use the UUID if serial number is not present ? Kindest regards note: I love your project !
saavagebueno added the triage-needed label 2025-11-20 05:23:15 -05:00
Author
Owner

@EdouardVanbelle commented on GitHub (Jul 11, 2024):

I bypassed this issue doing a fallback to the board

diff --git a/client/system/info_linux.go b/client/system/info_linux.go
index d85a6fae..564195a4 100644
--- a/client/system/info_linux.go
+++ b/client/system/info_linux.go
@@ -11,6 +11,7 @@ import (
        "runtime"
        "strings"
        "time"
+       "regexp"

        log "github.com/sirupsen/logrus"
        "github.com/zcalusic/sysinfo"
@@ -89,9 +90,17 @@ func _getInfo() string {
 func sysInfo() (serialNumber string, productName string, manufacturer string) {
        var si sysinfo.SysInfo
        si.GetSysInfo()
+       isascii, _ := regexp.Compile("^[[:ascii:]]+$")
        serial := si.Chassis.Serial
        if (serial == "Default string" || serial == "") && si.Product.Serial != "" {
                serial = si.Product.Serial
        }
-       return serial, si.Product.Name, si.Product.Vendor
+       if (!isascii.MatchString(serial)) && si.Board.Serial != "" {
+               serial = si.Board.Serial
+       }
+       name := si.Product.Name
+       if (!isascii.MatchString(name)) && si.Board.Name != "" {
+               name = si.Board.Name
+       }
+       return serial, name, si.Product.Vendor
 }

let me know if you want a merge request

@EdouardVanbelle commented on GitHub (Jul 11, 2024): I bypassed this issue doing a fallback to the board ```diff diff --git a/client/system/info_linux.go b/client/system/info_linux.go index d85a6fae..564195a4 100644 --- a/client/system/info_linux.go +++ b/client/system/info_linux.go @@ -11,6 +11,7 @@ import ( "runtime" "strings" "time" + "regexp" log "github.com/sirupsen/logrus" "github.com/zcalusic/sysinfo" @@ -89,9 +90,17 @@ func _getInfo() string { func sysInfo() (serialNumber string, productName string, manufacturer string) { var si sysinfo.SysInfo si.GetSysInfo() + isascii, _ := regexp.Compile("^[[:ascii:]]+$") serial := si.Chassis.Serial if (serial == "Default string" || serial == "") && si.Product.Serial != "" { serial = si.Product.Serial } - return serial, si.Product.Name, si.Product.Vendor + if (!isascii.MatchString(serial)) && si.Board.Serial != "" { + serial = si.Board.Serial + } + name := si.Product.Name + if (!isascii.MatchString(name)) && si.Board.Name != "" { + name = si.Board.Name + } + return serial, name, si.Product.Vendor } ``` let me know if you want a merge request
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1058