{"record":{"id":"518050a34dabba91","repo":"shadow1ng/fscan","slug":"cassandra-error-s","errorCode":null,"errorMessage":"cassandra error: %s","messagePattern":"cassandra error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/cassandra.go","lineNumber":120,"sourceCode":"\t// Step 1: STARTUP (CQL_VERSION=3.0.0)\n\tstartupBody := cqlStringMap(map[string]string{\"CQL_VERSION\": \"3.0.0\"})\n\tif err := cqlSend(conn, cqlOpStartup, startupBody); err != nil {\n\t\tstate.IncrementTCPFailedPacketCount()\n\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeNetwork, Error: err}\n\t}\n\n\t// Step 2: 读取响应\n\topcode, body, err := cqlRecv(conn)\n\tif err != nil {\n\t\tstate.IncrementTCPFailedPacketCount()\n\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeNetwork, Error: err}\n\t}\n\n\t// READY → 已就绪，发送测试查询\n\t// AUTHENTICATE → 需要认证\n\t// ERROR → 错误\n\tif opcode == cqlOpError {\n\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeAuth, Error: fmt.Errorf(\"cassandra error: %s\", string(body))}\n\t}\n\n\t// Step 3: 如果需要认证\n\tif opcode == cqlOpAuthChl {\n\t\tif cred.Username == \"\" && cred.Password == \"\" {\n\t\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeAuth, Error: fmt.Errorf(\"authentication required\")}\n\t\t}\n\t\t// SASL PLAIN: \\x00username\\x00password\n\t\tsaslToken := []byte(\"\\x00\" + cred.Username + \"\\x00\" + cred.Password)\n\t\tif err := cqlSend(conn, cqlOpAuthRsp, saslToken); err != nil {\n\t\t\tstate.IncrementTCPFailedPacketCount()\n\t\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeNetwork, Error: err}\n\t\t}\n\t\topcode, body, err = cqlRecv(conn)\n\t\tif err != nil {\n\t\t\tstate.IncrementTCPFailedPacketCount()\n\t\t\treturn &AuthResult{Success: false, ErrorType: ErrorTypeNetwork, Error: err}\n\t\t}","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/cassandra.go#L102-L138","documentation":"During the Cassandra native-protocol handshake, the server replied with an ERROR frame (opcode cqlOpError) in response to the OPTIONS/STARTUP exchange. The raw server error message is wrapped as 'cassandra error: %s' and returned as an auth failure (ErrorTypeAuth).","triggerScenarios":"doCassandraAuth sends the protocol STARTUP/OPTIONS frame and reads the reply; if the response opcode is cqlOpError, the server-side error body is surfaced via this error.","commonSituations":"Protocol version unsupported by the server; server rejecting the STARTUP options; node overloaded or bootstrapping; connecting to something that speaks CQL binary protocol but refuses the handshake.","solutions":["Read the embedded server message from the error to identify the server-side cause (e.g. unsupported protocol version).","Adjust the CQL protocol version used by the plugin to one supported by the target Cassandra release.","Retry later or against another node if the server reports overload/unavailable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"res := doCassandraAuth(conn, cred, state)\nif !res.Success && res.ErrorType == ErrorTypeAuth {\n    var srvMsg string\n    fmt.Sscanf(res.Error.Error(), \"cassandra error: %s\", &srvMsg)\n    log.Printf(\"server rejected handshake: %s\", srvMsg)\n}","preventionTips":["Use a CQL protocol version supported by the target server version.","Check server logs alongside client errors to correlate server-side rejections.","Avoid scanning nodes that are bootstrapping or decommissioned."],"tags":["cassandra","cql","protocol","auth"],"backgroundTag":"api-error-response","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}