Shopify / Shopify/react-native-skia

Replace `NativeBufferFactory` with a more secure implementation

Open
#3,062 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
8.6k
Forks
647
Avg merge
1d 17h
Merged PRs (30d)
35

Description

Description

Skia.NativeBuffer is badly designed.

The MakeFromImage function sadly returns pointers as BigInts.

https://github.com/Shopify/react-native-skia/blob/15edae07d096255fd854fb6ac1f815477194ec8c/packages/skia/cpp/api/JsiNativeBuffer.h#L20-L25

The Release function accepts a BigInt argument, which is expected to be the pointer for which the memory should be freed. It should've encapsulated the pointers and restricted this with a check to ensure the value can't be tampered with from JavaScript side.

https://github.com/Shopify/react-native-skia/blob/15edae07d096255fd854fb6ac1f815477194ec8c/packages/skia/cpp/api/JsiNativeBuffer.h#L27-L34

Ideally, the JavaScript side does not get an arbitrary way to free any hardware pointers beyond the ones it's explicitly been granted.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/skia/cpp/api/JsiNativeBuffer.h, especially MakeFromImage and Release, to understand how native pointers cross the JavaScript boundary. Define the replacement around encapsulated, non-tamperable handles; done means JavaScript can release only hardware pointers explicitly granted to it, rather than arbitrary pointer values.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, react-native
Domain
mobile-dev, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.