-
Notifications
You must be signed in to change notification settings - Fork 2
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
Say more about "deleting the constructor
property"?
#6
Comments
To explain why Bugs with shallow access can only chain a fixed or limited number of properties together, for example the statement Bugs with deep access are those that follow an object hierarchy recursively or iteratively, so they don't have a limit on how many properties they can chain together. These bugs are common and a lot more versatile to exploit. If The following is a recursive function that is vulnerable to pollution through deep access. Removing function merge(target, source) {
for (var key in source) {
if ( typeof source[key] === 'object' ) {
if(target[key] === undefined) target[key] = {};
target[key] = merge(target[key], source[key]);
} else {
target[key] = source[key];
}
}
} An example exploit is I want to call out that the statement above ( Removing As for automatically refactoring code at parse-time, I don't think we'd have enough information to accurately know when a |
Thanks for the example.
Unlike
So, I think this is basically not going to be viable - you will break too much code if you don't automatically rewrite
This inclines me more towards the option I suggested in #1, which I think is less likely to break code (and is also easier to learn). I realize it solves a slightly smaller class of bugs than the "cut all routes to the prototype" approach, but on the other hand if it can be deployed more widely I expect it would still end up eliminating more bugs total. |
Thanks, that's a useful explanation. From the research I've done, user-defined Nevertheless, it seems that the breakage risk is contained by both secure mode and automatic refactoring being opt-in, which would stop breakages while maximizing the number of code bases that can benefit from this. That is, if removing In your opinion, would the main blocker be how complex removing |
I'm worried about both, but more about the breakage potential. In particular, I don't think the opt-in mechanism really solves that problem, because a security mechanism is only useful if it's actually widely adopted, and we can't recommend everyone adopt a security mechanism that has a significant chance of breaking their code in a subtle way. |
The current shape of this proposal says it would (when enabled) "delet[e] the
__proto__
andconstructor
properties".I know what "deleting
__proto__
" means: it's a single getter/setter pair on Object.prototype, and it can indeed be outright deleted before any code executes (as for example Deno already does). That makes sense.I don't know what "deleting
constructor
" means.constructor
is an own property of theprototype
created along with any function, as inIt's also a property of the prototypes of most built-ins, of course, including Object.prototype, Array.prototype, etc.
Is the proposal that this property would no longer be created, but instead a symbol-named property would be created in its place, and it would be moved on all built-ins? And also all static access of
.constructor
would be changed at parse time - even when accessing properties not created by the engine, like if I didx = { constructor: "something" }; x.constructor === 'something'
? Or is there some other proposal?Also, I've encountered security vulnerabilities involving dynamic access of
__proto__
often enough to appreciate the scale of the security issues there, but I'm less familiar with examples involving dynamic access ofconstructor
. Some concrete examples, and a sense of the relative scale of the two issues, would be very helpful. Especially since my intuition is that changingconstructor
is going to be a lot more problematic than changing__proto__
.The text was updated successfully, but these errors were encountered: