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

deps: cherry-pick 0bcb1d6f from upstream V8 #18212

Closed
wants to merge 1 commit into from

Conversation

MylesBorins
Copy link
Contributor

This has landed in 6.5, but we shouldn't have to wait!

Original commit message:

Introduce --disallow-code-generation-from-strings

Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
to the command line.

Bug: v8:7134
Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
Reviewed-on: https://chromium-review.googlesource.com/809631
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49911}

Refs: v8/v8@0bcb1d6

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. v8 engine Issues and PRs related to the V8 dependency. labels Jan 17, 2018
@MylesBorins MylesBorins added security Issues and PRs related to security. semver-minor PRs that contain new features and should be released in the next minor version. labels Jan 17, 2018
@MylesBorins
Copy link
Contributor Author

@jasnell
Copy link
Member

jasnell commented Jan 17, 2018

It should be noted that this flag has no impact on vm.runInThisContext() (and the other variants). This is notable in that vm.runInThisContext() can be easily used as a workaround for a lack of eval

const eval = vm.runInThisContext;
n = 1;
eval('n++');
// n == 2

@MylesBorins
Copy link
Contributor Author

@jasnell do you think it might make sense to create a node specific flag that enables not only this flag but stops the ability to execute code in other fashions as well?

@bengl
Copy link
Member

bengl commented Jan 17, 2018

@MylesBorins If that were done, there would need to be some other way of loading code for require, or some kind of whitelist, or a Symbol passed in or something to give the require logic the ability to vm.runInThisContext regardless of the flag.

https://github.com/nodejs/node/blob/master/lib/module.js#L628

@jasnell
Copy link
Member

jasnell commented Jan 17, 2018

Yep, given our internal reliance on vm.runInThisContext() etc, we need to be careful here. If nothing else, we land this with some documentation around it that it's not 100% effective.

@MylesBorins
Copy link
Contributor Author

@jasnell "this" as in this specific PR or a future PR?

@jasnell
Copy link
Member

jasnell commented Jan 18, 2018

Perhaps a second commit in this PR? Not sure exactly where that should go. Maybe in the cli.md or in vm.md.

@hashseed
Copy link
Member

I faintly remember that this would also disable wasm. Do you want to make sure? Does that match your expectation?

@mcollina
Copy link
Member

Would this block new Function() as well?
There are valid use cases for this.

I prefer not to spread bad information that running with this flag is the way to go to improve security.

@bnoordhuis
Copy link
Member

given our internal reliance on vm.runInThisContext()

That shouldn't be affected, v8::ScriptCompiler is a different mechanism. But that's why this flag shouldn't be promoted as a security mechanism - it's too easy to subvert with require('vm').runInThisContext(...).

Aside: node --prof-process is probably broken with this flag on, it uses eval().

@hashseed
Copy link
Member

Would this block new Function() as well?

Yes. Otherwise you could just use that to bypass eval.

@jasnell
Copy link
Member

jasnell commented Jan 18, 2018

But that's why this flag shouldn't be promoted as a security mechanism

Absolutely agree. It's a good flag to have, but promoting it as a security mechanism is just a facade. Like locking the front door while leaving all the windows and the back door open with signs that say "Free Cookies Inside"

@BridgeAR
Copy link
Member

BridgeAR commented Feb 1, 2018

Where do we stand here? There is also #18453 that probably already included this as well?

@MylesBorins
Copy link
Contributor Author

I'm not sure what we should do regarding documentation of this feature. Would it make sense to wait for 6.5? I was thinking it might make sense to cherry-pick to 8.x in a future semver-minor. This is the beginning of a larger story around locking down eval.

should we land this as is?
should we block on docs?
should we wait for 6.5?

@MylesBorins
Copy link
Contributor Author

@MylesBorins
Copy link
Contributor Author

CI is green and I have 3 LGTMs. Are people ok with this landing without any documentation?

Copy link
Member

@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.

Can you update lib/internal/v8_prof_processor.js to use vm.runInThisContext() instead of eval()?

MylesBorins added a commit to MylesBorins/node that referenced this pull request Feb 13, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 17, 2018
PR-URL: nodejs#18623
Refs: nodejs#18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{nodejs#49911}

Refs: v8/v8@0bcb1d6
@MylesBorins
Copy link
Contributor Author

@bnoordhuis 99d693d has landed on master

@jasnell thoughts re: skipping docs?

MylesBorins added a commit that referenced this pull request Feb 21, 2018
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins added a commit that referenced this pull request Feb 21, 2018
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins added a commit that referenced this pull request Feb 21, 2018
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins
Copy link
Contributor Author

ping @bnoordhuis and @jasnell

@jasnell
Copy link
Member

jasnell commented Feb 26, 2018

I signed off. I'd still prefer the doc addition.

@MylesBorins
Copy link
Contributor Author

@jasnell more than happy to add the doc addition but struggling to figure out the right place to do it, do you have any suggestions?

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 2, 2018
@MylesBorins
Copy link
Contributor Author

since i'm not seeing anything actionable on where to add the docs I'm going to go ahead and land this.
Landed in: 8a54f4f

@MylesBorins MylesBorins closed this Mar 6, 2018
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
@MylesBorins MylesBorins mentioned this pull request Mar 6, 2018
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
MylesBorins pushed a commit that referenced this pull request Mar 7, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49911}

PR-URL: #18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
PR-URL: nodejs#18623
Refs: nodejs#18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Original commit message:

    Introduce --disallow-code-generation-from-strings

    Exposing the existing Context::AllowCodeGenerationFromStrings(false) API
    to the command line.

    Bug: v8:7134
    Change-Id: I062ccff0b03c5bcf6878c41c455c0ded37a1d743
    Reviewed-on: https://chromium-review.googlesource.com/809631
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{nodejs#49911}

PR-URL: nodejs#18212
Refs: v8/v8@0bcb1d6
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
addaleax pushed a commit that referenced this pull request Jun 30, 2018
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
rvagg pushed a commit that referenced this pull request Aug 16, 2018
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. build Issues and PRs related to build files or the CI. semver-minor PRs that contain new features and should be released in the next minor version. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.