cloudflare / cloudflare/quiche

quiche/src/tls.rs and crypto.rs use an unsafe bindings strategy

Open
#1,559 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
11.9k
Forks
1.1k
Avg merge
3d 7h
Merged PRs (30d)
16

Description

https://github.com/cloudflare/quiche/blob/master/quiche/src/tls.rs#L1255 contains a pile of hand-written bindings for BoringSSL functions. BoringSSL is not ABI-stable, so this is not a supported way to use the library. This will result in subtle memory errors, with no checking that you've gotten it right.

Indeed, there are already mistakes:
https://github.com/cloudflare/quiche/blob/master/quiche/src/tls.rs#L1442C8-L1443

BoringSSL uses size_t, not int, for those functions. That means this crate only works correctly on calling conventions where int and size_t are compatible. Specifically, on 64-bit platforms, you're relying on the upper half of the 64-bit register having a defined value when it is used to pass in a 32-bit parameter. You're in luck that most calling conventions require this, but this is not guaranteed.

This should be replaced with something robust, e.g. bindgen.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the hand-written BoringSSL bindings in quiche/src/tls.rs and crypto.rs, including the declarations around tls.rs lines 1255 and 1442. Review how bindgen could replace this strategy and verify that the resulting bindings use the correct BoringSSL types and calling conventions; done means the manual bindings are replaced with a robust approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.