Repository navigation
fix(plugin-oracle): bound the login handshake and read the accept connect flags correctly - #2935
Conversation
…nect flags correctly
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Second commit: the five collateral findingsThe investigation for this issue produced a register of five verified defects in the same subsystem. All five are now fixed here rather than left for later. Driver revision re-pinned 1. An 11.x server's negotiated SDU was ignored. Below protocol 315 the session data unit lives only in the 16-bit pair at packet bytes 12 and 14, and the driver kept its own proposal of 8192, so it sent packets larger than the server agreed to whenever a DBA had tuned it down. The new test caught a bug in the first version of this fix. NIO's 2. 3. A silent redial was discarding session state. The load-bearing part was that Fixed in MySQL's shape rather than inventing a local answer: a new 4. A shipped build could not produce a packet capture. This is not an env-var flip: a TNS login capture is an offline password oracle, and a token login is a live bearer token in the clear. The tracer is now always in the pipeline with 5. A listener redirect was never followed. Three things the obvious version gets wrong, all avoided: the follow-up connect sends the descriptor the listener handed back rather than one rebuilt from the configuration, because python-oracledb does and rebuilding it makes shared server a coin flip; a Verification
The exhaustive switch over What is still not provenNothing here was run against a real Oracle server. The redirect mechanics, the SDU clamp and the footprint are all covered offline, but the redirect chain in particular is only as safe as sending the server's own connect string makes it, and a real shared-server dispatcher has not accepted one of these follow-ups. One question this opened and did not close: oracle-nio's |
Fixes #2919.
Oracle 11.2.0.4 reached over a corporate VPN. TablePro reports Login Handshake Timed Out; DBeaver with Oracle JDBC thin 23.2 connects in 1000 ms over the same VPN, same host, same credentials.
Two defects, both measured. The VPN is shared context, not the differentiator.
1. The driver could not hear a server declining native network encryption
Accept.decoderead the accept packet's connect flags atreaderIndex + 18/+19. The decoder hands it the whole packet with the reader moved past the 8-byte header, so after the version and options the reader sits at 12 and that read landed on packet bytes 30/31, the reconnect-address length, instead of 22/23 where ACFL0 and ACFL1 live.Confirmed against two independent implementations:
v2/network/accept_packet.go:ACFL0 = packetData[22],ACFL1 = packetData[23], and its own writer puts them there. Its gate atv2/connection.go:505isACFL0&1 != 0 && ACFL0&4 == 0 && ACFL1&8 == 0.Measured against a hand-rolled TNS listener speaking protocol version 314, driving the real driver: an accept carrying
0x04(DISABLE_NA) at byte 22 still got the 156-byte0xDEADBEEFnegotiation packet; the same byte moved to 30 made the driver skip it. So the negotiation was decided by an unrelated length field.The fork also dropped go-ora's first condition,
ACFL0 & 0x01, with a comment that some servers do not echo the support bit. That observation was an artifact of the offset: with the wrong bytes every server reads0x00. Restoring the condition turns two tests green that are red at the pinned revision today (authHappyPathandfastAuthHappyPathboth trapped withInvalid state: advancedNegotiationSent).The accept flags are now read at their own absolute offsets, an accept shorter than the 32 bytes every server sends is rejected instead of walking the reader off the end, and the gate matches go-ora.
2. Nothing bounded the login, so a stalled handshake ran until the server gave up
OracleCoreConnectionwrapped connect inwithOracleTimeoutwith noonTimeout. The task group cancels the child and then awaits it, and the child is parked inEventLoopFuture.get(), which ignores cancellation. oracle-nio had no handshake timer of its own;connectTimeoutbounds the TCP connect only.Measured: a 2 s deadline over a 6 s uncancellable call surfaced at 6.40 s, and an accept-then-silence hung 20 s and unblocked only when the listener closed. The dialog therefore appeared whenever the server gave up, not at 30 s, and never if it did not.
This is the
Cancelling a connect does not stop the driverinvariant in CLAUDE.md, unenforced.OracleConnection.startno longer chainschannel.closeFuturebehind a startup error, which held the caller until the server hung up. Measured: an advanced-negotiation error now throws in 0.009 s where it took 20.009 s.Also in scope, same phase, all measured
preconditionFailure. A release build against a fake listener exited 133. The plugin is loaded in-process, so that was a pre-auth remote kill of the app, the same class as 连接Oracle闪退 #1746.moveReaderIndex(forwardBy: 20), live in-O.Native network encryption negotiatedand then sent the rest of the login in clear text. A real server cannot produce that, since the key exchange is the only key source, but a silent downgrade to plaintext is the wrong failure, so it now fails the connect.Network Encryption on the connection form
New dropdown mapping 1:1 to
SQLNET.ENCRYPTION_CLIENT: Rejected, Accepted (default, what Oracle's own clients send), Requested, Required. Nothing setConfiguration.nativeNetworkEncryptionbefore this, so the diagnosis had no lever on the one server that matters; now a reporter can isolate the negotiation.New error codes are wired through
OracleConnectErrorClassifierso they reach a named dialog instead of falling to the genericdefault:arm.Not done, on evidence
maxSize = 10spins at 99.7% CPU and 5.66 GB RSS and never returns,maxSize = 0trips a precondition,maxSize = 8force-unwraps nil. Reported separately.[0,1,3,4,5,6]is byte-identical to go-ora's, so "we offer SHA-2 checksum IDs an 11.2 server cannot do" is not a divergence from the reference client.Shipping
Oracle is registry-only. The fix rides the next app release and the next
plugin-oracle-v*build; it is not being back-published to 0.74.0.Driver change: TableProApp/oracle-nio
fix/2919-bound-login-handshake, commit42f8518. Re-pinned in all six tracked places (licenses.ymlcarries the revision twice).From the Codex review
Seven findings, all addressed. Four existed only because of the new field, which turned out to carry more weight than it looked:
Requiredwas a guarantee in name only: it changed the offered algorithm list and nothing else. The driver now refuses a server that will not negotiate, and refuses a negotiation that comes back having selected no cipher.readyToLogOff, so the close waited on a logoff reply the failing server never sends. A failure before authentication now hard-closes through a newcloseImmediatelycleanup action, since there is no session to log off from.advancedNegotiationRequiredhit the generic encryption predicate first and surfaced the wrong remediation. It is routed to its own error now.CRYPTO_CHECKSUM_CLIENT, because the driver negotiates both in one exchange. Said so in the option, the settings table and the docs rather than implying otherwise.Verification
TableProOracleCoreTests: 80 tests, no failures, including new coverage for the option, its wire strings, the level mapping and the phase naming.verify.sh build OracleDriver: PASS against the new pin.verify.sh lintover every changed Swift file: 0 violations.verify.sh generate: PASS, and the re-pin survives regeneration.One gap worth stating:
Packages/TableProOracledoes not build on Xcode 27 beta at either pin, old or new, because oracle-nio's@TaskLocalmacro emitsusableFromInlinenonisolatedunder Swift 6.4. That is pre-existing and unrelated to this change; the runs above used a locally patched build checkout, and CI builds on its own toolchain.Two notes for review that look alarming and are not.
Capabilities.encode/init(from:)also serialize the accept flags, but only into a client-internal REF CURSOR blob that never reaches the server. And the pre-fix behaviour on modern servers was not "the negotiation always ran": bytes 30/31 are a length field, so it was already being skipped whenever that length had0x08set.