Fix out-of-bounds writing to browser messages - #13679
Draft
varjolintu wants to merge 2 commits into
Draft
varjolintu wants to merge 2 commits into
varjolintu wants to merge 2 commits into
Conversation
varjolintu
marked this pull request as draft
September 15, 2026 16:56
varjolintu
force-pushed
the
fix/browser_messaging_limits
branch
3 times, most recently
from
September 15, 2026 17:21
f2c11d5 to
7004bc1
Compare
varjolintu
force-pushed
the
fix/browser_messaging_limits
branch
from
September 15, 2026 17:39
7004bc1 to
148440b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #13679 +/- ##
===========================================
+ Coverage 63.14% 63.18% +0.04%
===========================================
Files 388 388
Lines 41119 41157 +38
===========================================
+ Hits 25963 26005 +42
+ Misses 15156 15152 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The changes affect cryptographic buffer sizing and messaging boundaries, warranting final human review.
Suppressed comments (2)
src/browser/BrowserMessageBuilder.cpp:33
- This hardcodes the 16-byte MAC overhead even though the sodium API exposes
crypto_box_MACBYTES(and the previous implementation used it). Keeping a separate literal can make the allocation and output length diverge fromcrypto_box_easy()if the implementation constant changes; derive this constant fromcrypto_box_MACBYTESinstead.
#define EXTRA_BYTES 16 // For crypto_box_easy()
tests/TestBrowser.cpp:140
Succesfulis misspelled in this newly added test comment; please useSuccessful.
// Succesful decryption
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds safeguards when encrypting or decrypting messages for browser integration / native messaging.
Socket/pipes are transferring base64 encoded messages that are always larger than the actual message. The socket buffer must remain with 1MB (TODO).
Both encrypt and decrypt now checks if the message, public key and nonce lenghts are valid. For encryption, the size of the buffer must be size+16 (this is what
crypto_box_easy()requires). For decryption, the base64 decoded buffer holds that extra 16 bytes, and the buffer for decrypted data is added with that amount.Note that this change does not handle possible fragmented messages.
Testing strategy
Automatic tests added for situations where key and nonce lengths are not valid. Modified the encrypt/decrypt functions to take the max length as a parameter, so proper tests can be constructed. Tested the limits by reducing the max length of the message.
Type of change