Ticket #119 (new defect)

Opened 2 years ago

Last modified 2 years ago

[patch] Encryption scheme doesn't use proper random seed to encrypt

Reported by: guest Owned by:
Priority: blocker Milestone:
Component: extensions Version:
Keywords: security encryption migration Cc:


Red Hat security team discovered a vulnerability in Elixir caused by improper use of Blowfish encryption. Encryption is done roughly with following code:

def encrypt_value(value, secret):
    return Blowfish.new(secret, Blowfish.MODE_CFB) \

This code doesn't create proper random seed (IV argument for Blowfish) and therefore attacker with access to both database and able to add new data into database will be able to decrypt contents even without knowing the password.

Unfortunately to properly fix this issue a change of database is required as well and this change is backward incompatible since we need to store seed (IV) in the database.

I am attaching a proposed patch that should fix the issue. It adds new encryption mechanism that is enabled when acts_as_encrypted is used with "with_aes=True" parameter. It also prints out warning to stderr about insecure Blowfish method when it's used.

Apart from that I attach tarball with example migration that could help with migration of current databases. Users should be able to modify this example to properly migrate their databases. It is possible with minimal changes to the current code, provided database schema used fields that are big enough to contain IV seed together with encrypted data.

Change History

Changed 2 years ago by guest

Note that we have chosen AES instead of Blowfish since a database migration would be needed one way or the other and AES seemed like a more forward-looking migration.

Trac doesn't allow me to attach files for some reason so I am linking them here: proposed patch - http://sochotni.fedorapeople.org/python-elixir-aes-encryption-addition.patch

migration example - http://sochotni.fedorapeople.org/migration_test.tar.xz

Note: See TracTickets for help on using tickets.