Skip to content

Fix MapBuffer OOB read vulnerability in release builds - #55296

Closed
zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D91478548
Closed

Fix MapBuffer OOB read vulnerability in release builds#55296
zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D91478548

Conversation

@zeyap

@zeyap zeyap commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

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

Differential Revision: D91478548

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 26, 2026
@meta-codesync

meta-codesync Bot commented Jan 26, 2026

Copy link
Copy Markdown

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D91478548.

@zeyap
zeyap force-pushed the export-D91478548 branch 2 times, most recently from e0a2c88 to 8edd7e5 Compare January 27, 2026 15:20
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
@meta-codesync meta-codesync Bot closed this in 716da5a Jan 27, 2026
@meta-codesync

meta-codesync Bot commented Jan 27, 2026

Copy link
Copy Markdown

This pull request has been merged in 716da5a.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants