Never reconstruct 1.3 record numbers above 2^48-1

In DTLS 1.2, it was syntactically impossible to make a record number
over 2^48-1 or an epoch number over 2^16-1. This was nice because it
meant record numbers could be packed into an 8-byte structure.

DTLS 1.3 attempted to lift these constraints, but ineffectively. The
epoch count cannot go past 2^16-1 due to how the message number works.
The outgoing record count has no reason to exceed 2^48-1 because we
would have to send 5 petabytes to count that high even with empty
records, and indeed we check this right now.

The incoming record count is complicated. Record number reconstruction
*could* count that high if we receive 2^33 records (the max we can jump
is 2^15 at a time). This is within the realm of possibility for an
attacker, but too high to practically count via unit tests, and useless
for a well-behaved sender because the sender has no reason to skip
sequence numbers.

The result is that we need to use more memory and worry about a case
that we cannot practically test, which is only useful for attackers.
This is not useful. Instead, change the record number reconstruction
logic to never give back record numbers past 2^48. If the peer manages
to send 5 petabytes and count that high without rekeying, we'll jam the
record number and start dropping those packets. An error would be
preferable, but that would be a codepath we cannot effectively test, so
I opted to just bodge the reconstruction logic.

With this done, we can pack the record numbers again. The next CL will
introduce a DTLSRecordNumber type to abstract the various bit
manipulations we've been doing.

Bug: 42290594
Change-Id: I8bb0584a792578cf1d2a9df0b0c035d794c85beb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/72270
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Nick Harper <nharper@chromium.org>
Commit-Queue: Nick Harper <nharper@chromium.org>
3 files changed
tree: d126f85de8d62589d346ae399ed6aaa28646d248
  1. .bcr/
  2. .github/
  3. cmake/
  4. crypto/
  5. decrepit/
  6. docs/
  7. fuzz/
  8. gen/
  9. include/
  10. infra/
  11. pki/
  12. rust/
  13. ssl/
  14. third_party/
  15. tool/
  16. util/
  17. .bazelignore
  18. .bazelrc
  19. .clang-format
  20. .gitignore
  21. API-CONVENTIONS.md
  22. BREAKING-CHANGES.md
  23. BUILD.bazel
  24. build.json
  25. BUILDING.md
  26. CMakeLists.txt
  27. codereview.settings
  28. CONTRIBUTING.md
  29. FUZZING.md
  30. go.mod
  31. go.sum
  32. INCORPORATING.md
  33. LICENSE
  34. MODULE.bazel
  35. MODULE.bazel.lock
  36. PORTING.md
  37. PrivacyInfo.xcprivacy
  38. README.md
  39. SANDBOXING.md
  40. STYLE.md
README.md

BoringSSL

BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.

Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is. We don't recommend that third parties depend upon it. Doing so is likely to be frustrating because there are no guarantees of API or ABI stability.

Programs ship their own copies of BoringSSL when they use it and we update everything as needed when deciding to make API changes. This allows us to mostly avoid compromises in the name of compatibility. It works for us, but it may not work for you.

BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built up a large number of patches that were maintained while tracking upstream OpenSSL. As Google's product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved in maintaining all these patches in multiple places was growing steadily.

Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's not part of the NDK) and a number of other apps/programs.

Project links:

To file a security issue, use the Chromium process and mention in the report this is for BoringSSL. You can ignore the parts of the process that are specific to Chromium/Chrome.

There are other files in this directory which might be helpful: