fix: realign native network encryption keystream on in-band break#4
Merged
Conversation
A server-side error sent via an in-band break (markers) reset the connection but left the crypto-checksum keystream advanced, so the post-break error packet failed its integrity check and the connection crashed instead of surfacing the error. - Re-initialize the data-integrity keystream (both directions) on the reset marker, mirroring the reference thin drivers, and drop any partial packet. - Write the statement state back in errorHappened so a pipeline error no longer trips the readyForStatement precondition. - Throw, never trap, on a malformed/short native-encryption packet.
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.
Problem
Under Oracle native network encryption, any server-side error crashed the connection instead of surfacing.
When a query hits a server error and out-of-band breaks are disabled (common behind firewalls and proxies, and the default on some servers), the server signals the error with an in-band break: marker packets, then the error in a data packet. The crypto-checksum keystream resets on a break, but that was never implemented, so the post-break error packet failed its integrity check and threw. The thrown error then tripped a
preconditionFailureinreadyForStatementReceivedbecauseerrorHappeneddid not write the statement's.errorstate back.Reproduced live against Oracle 23ai with
SQLNET.ENCRYPTION_SERVER=REQUIRED+SQLNET.CRYPTO_CHECKSUM_SERVER=REQUIREDandDISABLE_OOB=ON: every error query (missing table, syntax error, divide by zero, no-privilege view) crashed the process.Fix
HashAlgo.Initon reset).OracleNetworkAESHash/OracleNetworkRC4Hashkeep their key generator and exposereinitialize(); the first derivation is unchanged, so existing behaviour and tests are unaffected.errorHappenedso a pipeline error fails the statement and returns the connection to ready, instead of crashing. Matches the existingbackendErrorReceivedpath.Verification
ORA-00942 / 00936 / 01476 / 00904, 110k-row queries work before and after errors, 0 crashes. Same on the SHA1 (RC4) checksum path.