I recently opened a container of store-bought dried apricots and they smell vaguely of fermentation/alcohol.  I've never noticed this before.

They taste fine, but should I be concerned?  Do they need to be used soon?

Worst-case, would I end up sick, or just tipsy? 


Question: AES using derived keys / IVs. Does it introduce a weakness?
Answer: I am assuming you are using CBC mode...

I would make the argument that this is a CWE-329 violation.  The IV can be known the to attacker,  but it must be random.   A more common solution to your problem is just to store a very secure random value and use this as your "IV".

Lets say you have a table named "secret".  The attacker has a SQL Injection vulnerability and sees this table,  he can also see that the current primary key value.  By computing a simple sha256 hash he is able to predict the next IV,  or even per-compute a table of future IVs.  (Depending on your platform the SQL Injection vulnerability could be turned into a decryption oracle!  Nasty!)

If I where building this I would use a proper Key Derivation Function such as PBKDF2. These are heavier functions which make it more difficult for the attacker to ore-compute or calculate in mass.  It doesn't have to be much heavier,  but the resulting value does have to be the same size as your cipher.

Another possible solution is to have an global "IV secret".  Pass iv_secret + column_name + primary_key to your Key derivation function to produce your IV. Due to the use of a secret the IV is no longer a predictable value and this is no longer a CWE-329 violation.  Further more this value is also a nonce,  it is not likely that the same IV would be generated twice for two different values... (Unless you made an update,  which would be a violation).   To mitigate this you could add a "version number" or last-modified timestamp to the IV calculation.