Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBC Encryption with Fixed IV in Encrypt Function #2246

Open
nyxfqq opened this issue Jul 8, 2024 · 1 comment
Open

CBC Encryption with Fixed IV in Encrypt Function #2246

nyxfqq opened this issue Jul 8, 2024 · 1 comment
Assignees

Comments

@nyxfqq
Copy link

nyxfqq commented Jul 8, 2024

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)
      }
@lixmal
Copy link
Contributor

lixmal commented Jul 9, 2024

Hi @nyxfqq,

thanks for reporting this. We work on a migration to some authenticated encryption cipher with proper iv usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants