-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Disable __proto__ #31951
Comments
cc @nodejs/tsc @nodejs/security @nodejs/v8 |
From a security / dev perspective, there really is no reason not to disable the getter/setter for The core issue here is that even the most security-aware developers still get caught not thinking about it when using external inputs. It's impossible to completely seal internal logic from some external input coming in that contains I am seriously considering deleting the getter/setter when hapi loads and being done with it, letting any other non-hapi module that requires it to fail and get people to fix it. But this would be much better dealt with for everyone at the node core level (or v8). It's just a getter/setter on the Object prototype. |
There are two parts to
The second one is extremely popular for creating object literals with a null prototype, so I doubt we could disable it. I don't think the |
I'm not convinced there's anything reasonable we can do at the Node.js level here by default without causing massive backwards compat issues. I wouldn't be opposed to running an experiment tho so see if that's wrong. |
It's part of JS; I don't think node dot JS should ever be in the position of disabling parts of the language, even with a flag. (also most of these vulnerabilities are due to doing dangerous things with unsanitized user input, which is a bad practice that causes problems with or without |
Drive-by comment:
For the vulnerabilities listed, which are about the setter on Object.defineProperty(Object.prototype, '__proto__', { set: void 0 }); |
IMO there isn't anything node can/should do about this. Developers just need to implement better patterns. The typical scenario I've seen that relates to this kind of issue is people using Additionally, I'm not entirely sure why someone would be attempting the kind of operation in the OP (
|
For context, here is a real life RCE in Kibana using prototype pollution: https://research.securitum.com/prototype-pollution-rce-kibana-cve-2019-7609/ |
I know we have |
I recently looked into the feasibility of doing a
It's not really, though. At least, as it is currently specced in the optional for non-browsers section.
The second form could still be valid, and is not a security concern, as you can't accidentally get user input into a literal. |
Note that the specific JSON issue quoted in the issue is blocked when enabling the Edit: it's just |
It's not part of JS.
|
The |
In practice, most of Annex B is not really optional if you want to write or use portable code, but yes, that would be the loophole that would allow node to remove it, using the method described upthread. |
to this point, TC39 is working on getting rid of annex b and putting all the things contained within (more or less) in the main body of the spec. |
@devnek what is the planned status of |
@ChALkeR merge it but it remains able to be removed and virtually all hardening systems are expected to remove it. I'd note just because something is in the spec, doesn't mean it needs to be preserved/encouraged in all scenarios. Sloppy mode for example is permanently in the spec, but not encouraged. Having a sane set of default hardening behaviors is prudent and is how a variety of systems work, see CSP limitations on eval etc. |
What I'd propose at this point is either: (a) An initial experimental CLI flag for Node.js that disables (b) Development of a preload module that essentially does the same thing. This would allow us to begin verifying what would break and help the ecosystem move things along. My preference is for option (a). Once we collect information about what breaks, we can decide how to proceed on from there. |
I’m personally a fan of b) because I don’t quite see the need to do something in core. |
I think that (a) is better is a sense that it would make testing that easier for the ecosystem users. |
@kanongil I've opened up a PR (it also removed a linting error to migrate that code) |
Babel at some previous versions apparently produced code which included: if (superClass) subClass.__proto__ = superClass (which is now changed to attempting This might be hard due to those. |
As a flag I do think this allows people to opt-in to breakage and shouldn't be thought of as breaking code without users expressing consent for the breakage. |
Here's another one to add to the list: |
That particular CVE imo is nonsense; the vulnerability is that you can attack yourself on purpose. |
Deno unconditionally removes |
@bmeck Deno is also not really concerned about full compatibility with Node.js, as I understand it? |
@addaleax correct, this is just noting a different environment doing something similar for similar reasons. If an increased number of environments disable |
Adds `--disable-proto` CLI option which can be set to `delete` or `throw`. Fixes #31951 PR-URL: #32279 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
Adds `--disable-proto` CLI option which can be set to `delete` or `throw`. Fixes #31951 PR-URL: #32279 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
Adds `--disable-proto` CLI option which can be set to `delete` or `throw`. Fixes nodejs#31951 PR-URL: nodejs#32279 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
Adds `--disable-proto` CLI option which can be set to `delete` or `throw`. Fixes #31951 PR-URL: #32279 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]>
What is the state of this in v15.5.1 Current. As I understand the setter has been disabled ? |
@GrosSacASac it is enabled by default but can be disabled via CLI flag |
I believe babel/babel#12693 should fix the babel side, that was the last part in babel codebase that generated |
Since what version ? I could not find it in the changelogs ? |
@GrosSacASac If you are speaking about Babel fix — that PR I linked is not merged yet. That is, that PR only affects |
Sorry, I was asking about Node |
|
Babel v7.12.13 should be fine even in loose mode. |
There have been quite a few CVE related to
__proto__
in the last while. I think it would be good to have a flag to enable/disable it.A quick example:
(It's not strictly related to JSON, as it can also apply to multipart data or other serialization format).
Some vulnerabilities:
I don't know if this is fixable / manageable on our side (vs V8), but
__proto__
still causes significant vulnerabilities.Note that there are some modules to help with this, including https://github.com/hapijs/bourne.
The text was updated successfully, but these errors were encountered: