Skip to content

Remove probability of collision in connection IDs by switching to u128 in Proxy #536

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

Merged
merged 3 commits into from
Jun 9, 2025

Conversation

r-n-o
Copy link
Contributor

@r-n-o r-n-o commented Jun 4, 2025

Summary & Motivation (Problem vs. Solution)

There's a non-insignificant probability that connection IDs collide (~0.003%) given the current space is u32::MAX ($2^{32}$) sized. Moving to u128 to make this irrelevant.

This was an informational-level finding by Trail of Bits during their last audit of this codebase.

How I Tested These Changes

Existing coverage

@r-n-o r-n-o requested a review from mark-nesbitt June 4, 2025 16:24
@r-n-o r-n-o requested review from a team as code owners June 4, 2025 16:24
Copy link
Contributor

@james-callahan james-callahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use a longer random key? e.g. 128bits?

Moving to auto-increment seems like it could cause us issues with any later multithreaded developments.

@r-n-o
Copy link
Contributor Author

r-n-o commented Jun 6, 2025

Good point @james-callahan, I've switched to u128 and brought back random connection ID assignment. Don't think we're concerned about the extra memory here. I've kept the vec->hashmap move because it gets us constant-time lookups.

@r-n-o r-n-o changed the title Remove probability of collision in connection IDs by auto-incrementing them in Proxy Remove probability of collision in connection IDs by switching to u128 in Proxy Jun 6, 2025
@r-n-o r-n-o requested a review from james-callahan June 6, 2025 23:11
Copy link
Contributor

@mark-nesbitt mark-nesbitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mark-nesbitt mark-nesbitt merged commit 3a236e1 into main Jun 9, 2025
8 checks passed
@mark-nesbitt mark-nesbitt deleted the rno/fix-connection-id-collision branch June 9, 2025 14:14
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

Successfully merging this pull request may close these issues.

3 participants