{"record":{"id":"8c7d582a766ce15f","repo":"apache/cassandra","slug":"provided-frame-does-not-appear-to-be-snappy-compre","errorCode":null,"errorMessage":"Provided frame does not appear to be Snappy compressed","messagePattern":"Provided frame does not appear to be Snappy compressed","errorType":"exception","errorClass":"org.apache.cassandra.transport.ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/Compressor.java","lineNumber":116,"sourceCode":"                output.release();\n                throw e;\n            }\n            finally\n            {\n                uncompressed.release();\n            }\n\n            return uncompressed.with(output);\n        }\n\n        public Envelope decompress(Envelope compressed) throws IOException\n        {\n            try\n            {\n                byte[] input = CBUtil.readRawBytes(compressed.body);\n\n                if (!Snappy.isValidCompressedBuffer(input, 0, input.length))\n                    throw new ProtocolException(\"Provided frame does not appear to be Snappy compressed\");\n\n                int uncompressedLength = Snappy.uncompressedLength(input);\n                validateUncompressedLength(uncompressedLength);\n                ByteBuf output = CBUtil.allocator.heapBuffer(uncompressedLength);\n\n                try\n                {\n                    int size = Snappy.uncompress(input, 0, input.length, output.array(), output.arrayOffset());\n                    output.writerIndex(size);\n                }\n                catch (final Throwable e)\n                {\n                    output.release();\n                    throw e;\n                }\n\n                return compressed.with(output);\n            }","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/Compressor.java#L98-L134","documentation":"During Snappy decompression the server validates the compressed payload with Snappy.isValidCompressedBuffer before inflating. If the payload fails validation, the frame is not genuinely Snappy-compressed data and this ProtocolException is thrown, closing the connection.","triggerScenarios":"Client negotiates snappy compression but sends a body that is not valid Snappy data — e.g. plaintext sent with compression enabled, or a corrupt/incorrectly framed compressed buffer.","commonSituations":"Mismatched compression settings (client says snappy, middleware strips compression); custom proxies re-encoding frames; fuzzer traffic.","solutions":["Ensure the client actually compresses bodies with Snappy when it negotiates the snappy codec.","Disable compression on the client (compression: null) if compression is not truly needed.","Verify no proxy/middleware alters frame bodies between client and server.","Check client library Snappy framing — write the uncompressed length, then Snappy.compress output."],"exampleFix":"// before: negotiation says snappy but body is plain bytes\nframe.compression = 'snappy'; frame.body = plaintext;\n// after\nframe.body = Snappy.compress(plaintext); // actually compress\nframe.compression = 'snappy';","handlingStrategy":"validation","validationCode":"boolean isSnappy = Snappy.isValidCompressedBuffer(body, 0, body.length);\nif (!isSnappy) throw new IllegalStateException(\"body sent with snappy compression but is not Snappy-compressed\");","typeGuard":"boolean looksLikeSnappyFrame(byte[] body) { try { return body.length > 0 && Snappy.isValidCompressedBuffer(body, 0, body.length); } catch (Exception e) { return false; } }","tryCatchPattern":"try { ... } catch (ProtocolException e) {\n    if (e.getMessage().contains(\"Snappy\")) { // disable compression or fix codec usage\n    }\n}","preventionTips":["Only enable snappy in connection options if the client actually compresses.","Round-trip test: compress, then validate with isValidCompressedBuffer before sending.","Ensure no proxy strips or re-encodes frame bodies.","Pin client codec library versions compatible with the server (lz4/snappy-java)."],"tags":["compression","snappy","protocol","deserialization"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}