Fix MapBuffer OOB read vulnerability in release builds - #55296
Closed
zeyap wants to merge 1 commit into
Closed
Conversation
zeyap
force-pushed
the
export-D91478548
branch
2 times, most recently
from
January 27, 2026 15:20
e0a2c88 to
8edd7e5
Compare
Summary: ## Changelog: [Internal] [Fixed] - Fix MapBuffer OOB read vulnerability in release builds This fixes a security vulnerability where MapBuffer accessors could leak memory or crash when handling missing keys in release builds. **Problem:** The `react_native_assert` macro is defined as `((void)0)` when `REACT_NATIVE_DEBUG` is not defined (production builds). This means the assertions in `getInt`, `getLong`, and `getDouble` are completely stripped out in release builds. When `getKeyBucket` returns -1 (key not found), the code proceeds to read from an invalid offset, causing: - Out-of-bounds memory reads - Information disclosure (leaking sensitive data) - Potential crashes **Solution:** Added runtime checks that work in release builds (debug build will abort at react_native_assert). This approach will not trigger more crash in release build. **Affected methods:** - `MapBuffer::getInt()` - `MapBuffer::getLong()` - `MapBuffer::getDouble()` Note: `getBool()` and `getString()` are protected because they call `getInt()` internally. [Session trajectory link](https://www.internalfb.com/intern/devai/devmate/inspector/?id=T247828667-0acc36ee-5abf-4f89-a444-3f8e1c959b51) Reviewed By: javache Differential Revision: D91478548
zeyap
force-pushed
the
export-D91478548
branch
from
January 27, 2026 15:36
8edd7e5 to
351a087
Compare
|
This pull request has been merged in 716da5a. |
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.
Summary:
Changelog:
[Internal] [Fixed] - Fix MapBuffer OOB read vulnerability in release builds
This fixes a security vulnerability where MapBuffer accessors could leak memory or crash when handling missing keys in release builds.
Problem:
The
react_native_assertmacro is defined as((void)0)whenREACT_NATIVE_DEBUGis not defined (production builds). This means the assertions ingetInt,getLong, andgetDoubleare completely stripped out in release builds. WhengetKeyBucketreturns -1 (key not found), the code proceeds to read from an invalid offset, causing:Solution:
Added runtime checks that work in release builds (debug build will abort at react_native_assert). This approach will not trigger more crash in release build.
Affected methods:
MapBuffer::getInt()MapBuffer::getLong()MapBuffer::getDouble()Note:
getBool()andgetString()are protected because they callgetInt()internally.Session trajectory link
Differential Revision: D91478548