Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.25.3, 3.7.2
-
None
-
Patch Available
-
Unknown
Description
If you use stream caching with file encryption in a camel route where you have a multicast with several branches, then it the following errors can happen in the message processing of the branch.
- When the message is processed in a branch you can get the following exception:aused by: java.lang.ArrayIndexOutOfBoundsException: while trying to load from index 16 of a byte (or boolean) array with length 16, loaded from field com.sun.crypto.provider.CounterMode.encryptedCounter of an object loaded from local variable 'this'aused by: java.lang.ArrayIndexOutOfBoundsException: while trying to load from index 16 of a byte (or boolean) array with length 16, loaded from field com.sun.crypto.provider.CounterMode.encryptedCounter of an object loaded from local variable 'this' at com.sun.crypto.provider.CounterMode.implCrypt(CounterMode.java:190) at com.sun.crypto.provider.CounterMode.crypt(CounterMode.java:178) at com.sun.crypto.provider.CounterMode.decrypt(CounterMode.java:153) at com.sun.crypto.provider.CipherCore.update(CipherCore.java:782) at com.sun.crypto.provider.CipherCore.update(CipherCore.java:667) at com.sun.crypto.provider.AESCipher.engineUpdate(AESCipher.java:380) at javax.crypto.Cipher.update(Cipher.java:1835) at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:139) at javax.crypto.CipherInputStream.read(CipherInputStream.java:199) at org.apache.camel.converter.stream.FileInputStreamCache.read(FileInputStreamCache.java:139)
- or you get a damaged payload in the branch which is not correctly decrypted
The root cause of the problem is that the decryptor is not thread safe: If two different FileInputStreamCache instances use the same decryptor in two different threads at the same time, the above problems occur.
I will provide a patch for this problem.