-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Object.freeze(NODEJS_BUILTIN_GLOBAL_AND_ITS_PROTOTYPE)
may lead to crash
#45336
Labels
confirmed-bug
Issues with confirmed bugs.
Comments
I don't understand you are asking, are you:
|
import globals from "globals";
for (const k of [...new Set(Object.values(globals).map(x => Object.keys(x)).flat())]) {
if (k in globalThis) {
const v = globalThis[k]
try { Object.freeze(v) } catch { }
try { Object.freeze(v.prototype) } catch { }
}
}
|
Object.freeze(NODEJS_BUILTIN_GLOBAL_AND_ITS_PROTOTYPE)
may lead to crash
Here's a smaller repro: $ node --no-experimental-global-webcrypto --use-strict -e 'Object.defineProperty(global, "crypto", { configurable: false });crypto'
node:internal/modules/cjs/helpers:181
delete object[name];
^
TypeError: Cannot delete property 'crypto' of #<Object>
at get (node:internal/modules/cjs/helpers:181:9)
at [eval]:1:66
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:307:38)
at node:internal/process/execution:83:21
at [eval]-wrapper:6:24
at runScript (node:internal/process/execution:82:62)
at evalScript (node:internal/process/execution:104:10)
at node:internal/main/eval_string:50:3
Node.js v20.0.0-pre |
aduh95
added a commit
to aduh95/node
that referenced
this issue
Nov 6, 2022
marco-ippolito
pushed a commit
to marco-ippolito/node
that referenced
this issue
Nov 23, 2022
Fixes: nodejs#45336 PR-URL: nodejs#45344 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
v18.12.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
Protect from prototype pollution inspired by https://github.com/snyk-labs/nopp/blob/main/index.js
reproduce.mjs
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No error.
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: