Skip to content

Commit

Permalink
remove _WORKLET_RUNTIME global property
Browse files Browse the repository at this point in the history
It exposed a memory pointer to the JS runtime. Leaking a memory address
could potentially be used to exploit memory corruption bugs. For
example, it's useful to defeat ASLR.

Also, it wrote data to an ArrayBuffer without checking the array length,
which may cause out-of-bounds memory writes.
  • Loading branch information
matias-la committed Sep 21, 2023
1 parent ed2984b commit 1049159
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
13 changes: 0 additions & 13 deletions android/src/main/cpp/NativeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,6 @@ void NativeProxy::installJSIBindings() {
std::shared_ptr<jsi::Runtime> animatedRuntime =
facebook::jsc::makeJSCRuntime();
#endif
auto workletRuntimeValue =
runtime_->global()
.getProperty(*runtime_, "ArrayBuffer")
.asObject(*runtime_)
.asFunction(*runtime_)
.callAsConstructor(*runtime_, {static_cast<double>(sizeof(void *))});
uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
workletRuntimeValue.getObject(*runtime_).getArrayBuffer(*runtime_).data(
*runtime_));
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(animatedRuntime.get());

runtime_->global().setProperty(
*runtime_, "_WORKLET_RUNTIME", workletRuntimeValue);

auto version = getReanimatedVersionString(*runtime_);
runtime_->global().setProperty(*runtime_, "_REANIMATED_VERSION_CPP", version);
Expand Down
10 changes: 0 additions & 10 deletions ios/native/REAInitializer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ - (void)setBridge:(RCTBridge *)bridge;
auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
#endif
auto workletRuntimeValue = runtime.global()
.getProperty(runtime, "ArrayBuffer")
.asObject(runtime)
.asFunction(runtime)
.callAsConstructor(runtime, {static_cast<double>(sizeof(void *))});
uintptr_t *workletRuntimeData =
reinterpret_cast<uintptr_t *>(workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime));
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(reanimatedModule->runtime.get());

runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue);

auto version = getReanimatedVersionString(runtime);
runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
Expand Down

0 comments on commit 1049159

Please sign in to comment.