Skip to content

Fix TypedArray.prototype.with TOCTOU heap over-read#1415

Merged
saghul merged 1 commit intomasterfrom
improve-ta-with
Mar 21, 2026
Merged

Fix TypedArray.prototype.with TOCTOU heap over-read#1415
saghul merged 1 commit intomasterfrom
improve-ta-with

Conversation

@saghul
Copy link
Contributor

@saghul saghul commented Mar 20, 2026

Re-validate the typed array after JS_ToPrimitive (which can trigger
user code that resizes or detaches the backing ArrayBuffer).

Ref: bellard/quickjs#492

Re-validate the typed array after JS_ToPrimitive (which can trigger
user code that resizes or detaches the backing ArrayBuffer).

Ref: bellard/quickjs#492
Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular class of bugs keeps popping up, doesn't it?

Wild thought: maybe we should start renaming functions that (directly or indirectly) invoke JS so it's more obvious where extra attention is needed.

For example, JS_ToPrimitive would become JS_ToPrimitiveOSE (for Observable Side Effects.) The downside is lots of churn, obviously.

@saghul
Copy link
Contributor Author

saghul commented Mar 21, 2026

This particular class of bugs keeps popping up, doesn't it?

It does! 😅

Wild thought: maybe we should start renaming functions that (directly or indirectly) invoke JS so it's more obvious where extra attention is needed.

For example, JS_ToPrimitive would become JS_ToPrimitiveOSE (for Observable Side Effects.) The downside is lots of churn, obviously.

Not wild! Right now we do have a but of an inherited mix: JS_ vs js_ vs js__. Coming up with some rules going forward would be good.

Honestly I'm not very worried about churn. It was annoying when manually porting patches over, but AI is good at figuring that out.

I wonder if some soem macro in the function prototype can help? static void side_effects js_toprimitive. Yes you don't see it in the call site, but you do when you chase it? LEt's open a new issue and brainstorm.

@saghul saghul merged commit e6e4e76 into master Mar 21, 2026
122 checks passed
@saghul saghul deleted the improve-ta-with branch March 21, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants