Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safeguard around js caching api #1146

Merged
merged 2 commits into from
Dec 5, 2023
Merged

Conversation

sesposito
Copy link
Member

Prevent js objects and other types to leak vm context through the localcache by disallowing such types to be cached and restricting to primitive data types only on put.

Prevent js objects and other types to leak vm context through the
localcache by disallowing such types to be cached and restricting
to primitive data types only on put.
@sesposito sesposito requested a review from zyro November 22, 2023 18:31
switch v.(type) {
case string, int64, float64, bool:
default:
panic(r.NewTypeError("unsupported value type: must be string, numeric or boolean"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a chance this would cause panics in existing modules that use types outside of this list?
I.e. would it make sense to issue a warning/error instead of panicking to prevent breaking backward compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

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

Goja types that are passed by reference (e.g.: a JS object) carry with them internally a reference to the original VM where they were instantiated, if these objects are manipulated concurrently it can cause the VM to panic.

@sesposito sesposito merged commit c091d69 into master Dec 5, 2023
3 checks passed
@sesposito sesposito deleted the spe/js-localcache-input-check branch December 5, 2023 16:45
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.

None yet

2 participants