alexpikalov / cassandra-proto Goto Github PK
View Code? Open in Web Editor NEWCassandra binary protocol implementation
License: Apache License 2.0
Cassandra binary protocol implementation
License: Apache License 2.0
Hello ๐ฆ ,
we (Rust group @sslab-gatech) found a memory-safety/soundness issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.
cassandra-proto/src/frame/parser_async.rs
Lines 46 to 51 in 9bdbc91
cassandra-proto/src/frame/parser_async.rs
Lines 65 to 69 in 9bdbc91
We found two cases where an uninitialized buffer is created (body_bytes
& tracing_bytes
) and passed to user-provided Read
implementation. This is unsound, because it allows safe Rust code to exhibit an undefined behavior (read from uninitialized memory).
This part from the Read
trait documentation explains the issue:
It is your responsibility to make sure that
buf
is initialized before callingread
. Calling read with an uninitializedbuf
(of the kind one obtains viaMaybeUninit<T>
) is not safe, and can lead to undefined behavior.
It is safe to zero-initialize the newly allocated u8
buffer before read()
, in order to prevent user-provided Read from accessing old contents of the newly allocated heap memory.
Thank you for checking out this issue ๐
parser and parser_async have different method signatures
frame_parse signature is:
pub fn parse_frame<E>(
cursor_cell: &RefCell<dyn Read>,
compressor: &dyn Compressor<CompressorError = E>,
) -> error::Result<Frame>
where
E: std::error::Error,
frame_parse_async signature:
pub fn parse_frame_async<E, C>(
cursor: &mut C,
compressor: &dyn Compressor<CompressorError = E>,
) -> error::Result<Option<Frame>>
where
E: std::error::Error,
C: Read,
I think it makes sense to align these so that the async is a drop in replacement for the sync.
Does the async require the cursor or can the cursor be passed in a RefCell?
I'm trying to use this crate with cdrs-async, but the document is so poor, is there any plan to write some document for basic usage.
Hi, thanks for your work on this project!
I assume this project has the same license as cdrs but it would be great if you could explicitly add the MIT and Apache license files to this project.
all discussion is based on
https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec#L110
In some cases the initial OPTION message does not have an expected version. Specifically I have an example comprising 9 bytes:
0x42 0x00 0x00 0x00 0x05
0x00 0x00 0x00 0x00
0x42 = 66 = the code for the DSE v4 driver.
I think that the proper way to handle this is to skip the version verification until the STARTUP message is received. What I am unsure of is should the protocol 0x42 OPTIONS message be processed, silently ignored, or an ERROR returned.
Although maybe not technically part of the protocol, I think it would make a lot of sense to move it here as people who want to use cassandra-proto for lower level cassandra access will still need access to this.
I'm happy to provide a PR if this is something you would like to do.
I am working on a project that makes extensive use of cassandra-proto.
We currently have a fork with various features and fixes that I am trying to upstream.
And then there is a lot of further improvements I want to make after that including:
However the current pace of reviews here is pretty slow.
This is of course fine, you are working on this on your own time and have no obligation to review my PRs.
But this is limiting my ability to get cassandra-proto where it needs to be both for use in the project im working on and for use in cdrs and other projects.
So that leaves a few options:
cassandra-protocol
or something. - in the future if you are happy with the forked project then you can start using it for cdrscassandra-proto
name on crates.ioLet me know what your plans are for cassandra-proto and how we should proceed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.