{"record":{"id":"9f730648fb1d7394","repo":"shadow1ng/fscan","slug":"oracle-advanced-negotiation-type-mismatch-d","errorCode":null,"errorMessage":"oracle advanced negotiation type mismatch: %d","messagePattern":"oracle advanced negotiation type mismatch: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/oracle_raw.go","lineNumber":840,"sourceCode":"\tsubPackets, err := s.getInt(2, false, true)\n\tif err != nil {\n\t\treturn 0, 0, 0, err\n\t}\n\terrCode, err := s.getInt(4, false, true)\n\treturn serviceType, subPackets, errCode, err\n}\n\nfunc (s *oracleSession) readANOPacketHeader(expectType int) (int, error) {\n\tlength, err := s.getInt(2, false, true)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\ttyp, err := s.getInt(2, false, true)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif typ != expectType {\n\t\treturn 0, fmt.Errorf(\"oracle advanced negotiation type mismatch: %d\", typ)\n\t}\n\treturn length, nil\n}\n\nfunc (s *oracleSession) readANOServiceData(serviceType, subPackets int) error {\n\tswitch serviceType {\n\tcase 1:\n\t\tif _, err := s.readANOVersion(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tstatus, err := s.readANOStatus()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif status == 0xfaff && subPackets > 2 {\n\t\t\tif _, err = s.readANOUB1(); err != nil {\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":822,"sourceCodeEnd":858,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/oracle_raw.go#L822-L858","documentation":"During Oracle Advanced Negotiation (ANO/NA), the client reads a packet header and expects a specific packet type (version, status, UB1, string, or bytes). The server returned a different type byte than expected, so the library aborts the handshake and reports the actual type value received. This indicates the server's ANO stream does not match the protocol layout the library implements.","triggerScenarios":"Any of readANOVersion/readANOStatus/readANOUB1/readANOString/readANOBytes during advancedNegotiation receives an ANO packet whose type field differs from the expected constant (e.g. a 0xDEAD-style marker byte or a service-data packet where a version packet was expected).","commonSituations":"Connecting through a proxy, load balancer, or connection pooler that mangles or partially consumes ANO packets; non-Oracle or Oracle-Cloud gateways answering the negotiation; a mid-stream desync caused by an earlier parse bug; Oracle server versions that send extra/optional ANO sub-packets in a different order.","solutions":["Bypass proxies/poolers and connect directly to the listener to see if the mismatch disappears.","Check the Oracle server/gateway version and verify the plugin supports it; upgrade the plugin if a newer server is in use.","Disable advanced negotiation/data integrity services (e.g. remove Oracle Network Encryption/Checksumming config in sqlnet) on the server so the simpler handshake is used.","Capture the traffic (tcpdump/Wireshark with TNS decoding) and compare the ANO packet types against what the library expects; file an issue with the observed type number if it looks like a real server variant."],"exampleFix":"// Workaround: force the driver to skip ANO when the server is behind a proxy\n// before\nconnStr := \"oracle://user:pass@proxy-host:1521/service\"\n// after\nconnStr := \"oracle://user:pass@db-host:1521/service\" // direct listener connection","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := db.PingContext(ctx); err != nil {\n    if strings.Contains(err.Error(), \"advanced negotiation type mismatch\") {\n        // fall back to direct connection or flag unsupported server topology\n    }\n}","preventionTips":["Connect directly to the Oracle listener, not through poolers/proxies that touch TNS payloads","Pin and test the plugin against your exact Oracle server version","Avoid server-side ANO services (encryption/checksumming) unless the library supports them"],"tags":["oracle","protocol","negotiation","handshake"],"backgroundTag":"unexpected-response-shape","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}