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

[K9VULN-2510] Require explicit v8 flag initialization. Disable eval. #612

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

jasonforal
Copy link
Collaborator

What problem are you trying to solve?

For security reasons, we should disable the JavaScript eval function because it allows arbitrary strings to be executed as JavaScript.

What is your solution?

  • Explicitly initialize v8 with flags. This manual initialization is enforced at compile time by the type state pattern the V8Platform uses.
  • Enable the disallow-code-generation-from-strings flag (which v8 disables by default).

Alternatives considered

What the reviewer should know

  • We can't simply do the v8 equivalent of globalThis.eval = undefined because the Function object could also be used to dynamically execute the contents of a string (and a reference to that can always be retrieved).

@jasonforal jasonforal requested a review from juli1 January 17, 2025 22:28
…a stage to type state implementation. Refactor `V8Platform<CfgTest>` and `V8Platform<Initialized>` to be constructed via the same function to ensure parity in tests.
@jasonforal jasonforal merged commit 67af393 into main Jan 21, 2025
75 checks passed
@jasonforal jasonforal deleted the jf/K9VULN-2510 branch January 21, 2025 14:31
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