-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix: traceids not random when using webcrypto
#825
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #825 +/- ##
=======================================
Coverage 78.29% 78.29%
=======================================
Files 142 142
Lines 6354 6354
Branches 1228 1228
=======================================
Hits 4975 4975
Misses 1172 1172
Partials 207 207
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Size check report:
|
Fix non-random hexadecimal generation when using the webcrypto api, which in turn creates non-random traceIds, that always end in 00
Overview
A bug in the generation of random hexadecimal values when using
webcrypto
means the traceIds used for the distributed tracing spans are not fully random, and all traceIds will end in00
. The W3C spec says this value should be random, and this can cause issues for organizations who are enforcing browser span sampling by using drop rules versus the last characters of the spans.The cause is a double out of bounds, once when iterating over an array using
++var
instead ofvar++
and second when the size of the hex value is 32 characters, due to theUint8Array
used for the webcrypto random number generation length being hardcoded to31
.Related Issue(s)
Issue: #826
Testing
Due to the use of random number generation this requires a slightly different setup. This gist shows the code and results I used to diagnose and test the patch.
https://gist.github.com/paddyo/c861c640a2328aaf0d09d30c103bb3dd
This was tested on
node 21.2.0
which allowed easy use of module hooks.