-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Prevent prototype pollution chaining to code execution via _.template, part 2 #4517
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
Prevent prototype pollution chaining to code execution via _.template, part 2 #4517
Conversation
I want to be careful endorsing this as any kind of real issue. I accepted the previous PR as kind of a throw away thought. However, I believe it's mostly academic and it's something we've not supported in the past. Traditionally, if you mutate |
@jdalton I would agree that an application intentionally carelessly mutating Object.prototype should expect that things break. For this particular issue, my concern is when an application unintentionally has a prototype pollution vulnerability, such as any application that used a slightly older version of lodash and used e.g. deep merge or clone would be. It's a hard problem to avoid in large code bases, as
Giving the same treatment to all other options might be a larger breaking change and is more likely to hit legitimate uses of options that inherit something. At the very least I'd urge accepting the change to the sanitizing of sourceURL. If variable and imports are polluted, they still seem to be masked by the default I'm happy to make a PR that only does the sourceURL sanitizing. |
I created #4518 which I hope is easier to accept. :) |
Existing JS APIs are susceptible to this today including descriptors for
For #4518 you can continue to preserve the |
I'm not sure I'm following. With defineProperty and proxy traps you can certainly change objects, but I'm not aware of it accepting strings in an options object that in turn execute as Javascript, which could be susceptible to a default being read off the prototype? An attacker that is able to influence objects through these calls would already be in a pretty privileged position, much more so than someone just able to pass a JSON object that passes through pollution-prone merge-like calls. |
If you do |
This is a followup to #4355 which unfortunately was incomplete, because of …
... which happens prior to the
hasOwnProperty
guard would merge in whatever happens to be on the prototype intooptions
, so it'd all be considered as part ofoptions
"own" properties. That might be a bug inassignInWith
, it's not clear whether that's intentional behaviour.My testing focused on the
sourceURL
part (which was easier to inject with thanvariable
), and it got stopped by the newline stripping. The newline stripping was also incomplete, as you can provide a unicode newline.I added a utility to get a property without looking at the prototype, which I guess might be a bit too much for this PR. Happy to remove that, but I think it'd be nice to have a utility like that in lodash. :)