Commit 716da5a
Fix MapBuffer OOB read vulnerability in release builds (#55296)
Summary:
Pull Request resolved: #55296
## 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
fbshipit-source-id: 07a70f071938cb27d43a30536a66282fd748f4e91 parent e8eb374 commit 716da5a
2 files changed
Lines changed: 53 additions & 30 deletions
Lines changed: 51 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
57 | 66 | | |
58 | | - | |
59 | | - | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| |||
74 | 85 | | |
75 | 86 | | |
76 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| |||
86 | 100 | | |
87 | 101 | | |
88 | 102 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
97 | 113 | | |
98 | 114 | | |
99 | 115 | | |
100 | 116 | | |
101 | 117 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
105 | 123 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
109 | 131 | | |
110 | 132 | | |
111 | 133 | | |
112 | 134 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 135 | + | |
116 | 136 | | |
117 | 137 | | |
118 | 138 | | |
119 | 139 | | |
120 | 140 | | |
121 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
122 | 146 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
127 | 151 | | |
128 | 152 | | |
129 | 153 | | |
130 | 154 | | |
131 | | - | |
132 | | - | |
| 155 | + | |
| 156 | + | |
133 | 157 | | |
134 | 158 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 159 | + | |
139 | 160 | | |
140 | 161 | | |
141 | 162 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
| |||
0 commit comments