Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit Cap'n Proto and drasticly reduce the amount of unsafe code #67

Open
DemiMarie opened this issue Feb 29, 2020 · 5 comments
Open

Audit Cap'n Proto and drasticly reduce the amount of unsafe code #67

DemiMarie opened this issue Feb 29, 2020 · 5 comments

Comments

@DemiMarie
Copy link

I would love to use Cap'n Proto, but it is full of unsafe code (~3000 lines).

@Shnatsel
Copy link
Member

Are you referring to the runtime library, or the code it generates?

https://crates.io/crates/capnp seems to have ~200 daily downloads. A protobuf implementation such https://crates.io/crates/protobuf or https://crates.io/crates/prost would be a higher-value target with ~3000 daily downloads each.

@tarcieri
Copy link
Member

I'd love to see an audit of prost. It should be fairly trivial as it appears to have 6 usages of unsafe

@Shnatsel
Copy link
Member

I've opened #68 for prost.

@DemiMarie
Copy link
Author

@Shnatsel The runtime library seems to be the biggest risk; layout.rs is ~3000 lines of incredibly unsafe code. Given that it is a direct port of a C++ implementation, this is not particularly surprising. The use of raw pointers may be necessary to circumvent Rust’s aliasing rules, but since these pointers are virtually all to primitive integer types with no invariants, it should be possible to wrap these uses in safe, bounds-checked APIs.

@DemiMarie
Copy link
Author

Like protobufs, Cap’n Proto is exposed to untrusted data from the network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants