CBC Encryption with Fixed IV in Encrypt Function #1049

Open
opened 2025-11-20 05:23:04 -05:00 by saavagebueno · 0 comments
Owner

Originally created by @nyxfqq on GitHub (Jul 8, 2024).

Originally assigned to: @lixmal on GitHub.

Describe the problem

I've discovered that the CBC encryption mode implemented in the Encrypt function located in the crypt.go file (part of the github.com/netbirdio/netbird/management/server/activity/sqlite package) utilizes a static initialization vector (IV). This practice is known to compromise the security of the encrypted data, as using a predictable IV can lead to pattern leaks and potentially allow attackers to infer information about the plaintext.

Expected behavior

For security purposes, each encryption operation should utilize a unique and unpredictable IV, maybe it can derived from the key.

NetBird version

<=0.28.4

Screenshots

      var iv = []byte{10, 22, 13, 79, 05, 8, 52, 91, 87, 98, 88, 98, 35, 25, 13, 05}
      func (ec *FieldEncrypt) Encrypt(payload string) string {
          plainText := pkcs5Padding([]byte(payload))
          cipherText := make([]byte, len(plainText))
          cbc := cipher.NewCBCEncrypter(ec.block, iv)
          cbc.CryptBlocks(cipherText, plainText)
          return base64.StdEncoding.EncodeToString(cipherText)
      }
Originally created by @nyxfqq on GitHub (Jul 8, 2024). Originally assigned to: @lixmal on GitHub. **Describe the problem** I've discovered that the CBC encryption mode implemented in the `Encrypt` function located in the `crypt.go` file (part of the `github.com/netbirdio/netbird/management/server/activity/sqlite` package) utilizes a static initialization vector (IV). This practice is known to compromise the security of the encrypted data, as using a predictable IV can lead to pattern leaks and potentially allow attackers to infer information about the plaintext. **Expected behavior** For security purposes, each encryption operation should utilize a unique and unpredictable IV, maybe it can derived from the key. **NetBird version** <=0.28.4 **Screenshots** var iv = []byte{10, 22, 13, 79, 05, 8, 52, 91, 87, 98, 88, 98, 35, 25, 13, 05} func (ec *FieldEncrypt) Encrypt(payload string) string { plainText := pkcs5Padding([]byte(payload)) cipherText := make([]byte, len(plainText)) cbc := cipher.NewCBCEncrypter(ec.block, iv) cbc.CryptBlocks(cipherText, plainText) return base64.StdEncoding.EncodeToString(cipherText) }
saavagebueno added the management-servicesecurity labels 2025-11-20 05:23:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#1049