Conversation
GuardedString and GuardedByteArray protected their contents with the same AES/CBC code as the legacy wire format: a random key, but the framework's fixed IV, so equal secrets encrypted to equal bytes and a modified ciphertext decrypted without complaint. Those secrets never leave the process, so nothing depends on their format: newRandomEncryptor() now returns an AES-256/GCM encryptor with a random IV for every encryption. EncryptorImpl keeps only the legacy wire format, which must stay byte-compatible with the .NET connector server; a test pins its output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the high-severity CodeQL alerts on
EncryptorImpl(java/weak-cryptographic-algorithm#1 #2,java/static-initialization-vector#11 #12).Problem
EncryptorImplserved two purposes with one piece of code. WithdefaultKey=trueit is the wire format of the legacy connector server protocol (AES/CBC, key and IV built into the framework). WithdefaultKey=false— whatEncryptorFactory.newRandomEncryptor()returned, i.e. whatGuardedStringandGuardedByteArrayuse for the secrets they hold in memory — it generated a random key but kept the framework's fixed IV. So two equal secrets encrypted to identical bytes (spot the reused password in a heap dump), and a modified ciphertext decrypted to garbage without complaint.Change
AesGcmEncryptor(new): AES-256/GCM, key per instance, random 12-byte IV for every encryption written in front of the ciphertext, 128-bit tag.newRandomEncryptor()returns it. These secrets never leave the process, so nothing depends on their format.EncryptorImplkeeps only the legacy wire format, with a javadoc saying why it is what it is: it must stay byte-for-byte compatible with the .NET connector server, and it is obfuscation rather than protection — the transport is what protects it (Verify the connector server certificate against the host over the legacy SSL connection #122). Thebooleanconstructor goes (its only caller was the factory).Tests
EncryptorImplTests:defaultEncryptorKeepsLegacyWireFormatpinsencrypt("secret")to66df076267e3a421575ce6fa2ec1d5c7, computed independently withopenssl enc -aes-128-cbcand the framework's key/IV — the .NET compatibility guard;connector-framework-internalsuite: 474 tests, green (serializer round trips ofGuardedString/GuardedByteArray, remote tests).Alerts
The four
EncryptorImplalerts remain on the legacy path by design and are being dismissed as "won't fix" with this PR as the reason. Already dismissed with recorded reasons: DESede inPasswordDecryptor(#5 #6, DSEE retro-changelog format), LDAP{SHA}/{MD5}schemes (#27 #28, the directory's format), SHA-1 connector key hash (#25 #26, storedconnectorserver.keyformat; SHA-256 needs dual support — separate task).