-
-
Notifications
You must be signed in to change notification settings - Fork 732
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
Property 'hasOwnProperty' of object #<Object> is not a function #73
Comments
In the context of this function, |
Not if someone is trying to compromise your server via bad urls :) I will try to dig up the request that causes failure, but I will say that this should be fixed and is indeed broken ;) I am using an up to date version of express 4.12 but obviously would be more idea if I reproduced against this module directly which I will try to do if you want proof. |
If you can prove it with a test case I'll definitely fix it, but seeing as this method is what is creating the |
Have a test now, you were right @defunctzombie great find! |
fixed in 2.4.1 |
Thanks for the quick response! @dougwilson ping to bump express qs usage |
Thanks for the ping :) I was already planning to roll a |
The good news is it doesn't cause a crash in Express (phew), only an annoying 500 error. |
Yep :) caught it via our error logging On Friday, March 13, 2015, Douglas Christopher Wilson <
|
So apparently this is not a bug fix, but a complete behavior change. It basically can be described as "Ignore keys that override |
It basically means that any random module you loaded in your code base can now affect your |
@defunctzombie let me know how you feel about this finding, but to me, this change is way too impactful to ever make it into Express 3/4 since this module is the default query string parser and it's basically asking people to restructure their entire application if they want to use certain query string parameter names + the enhanced syntax here. Express currently handles any errors from this module (like the one you posted) in a way that does not impact the application, simply generating a 400 Bad Request error on requests that have a |
At the most basic level, though, I feel like this library is very inconsistent, now:
|
I am not sure what the exact fix should be here but I can say that it On Sunday, March 15, 2015, Douglas Christopher Wilson <
|
@defunctzombie oh, I didn't realize, I though you were saying it was just an annoyance, otherwise I would have released a new Express days ago :( I'm going to add a |
Hmmm.. I see the problem. I'll rethink this and see if I can come up with a better solution first thing tomorrow morning |
A try/catch would be good then maybe we can think about what the fix here On one hand using reserved object properties as names isn't good but on the Maintainers, thoughts? On Sunday, March 15, 2015, Douglas Christopher Wilson <
|
Yes, @defunctzombie I'm slapping out across-the-board |
Wait a minute, lol, the Express server doesn't crash at all; it just sends back a 500 response:
Which means there is nothing critical to take care of right now (at 2am Monday morning). Basically it's just an annoyance right now and not a DoS vector, say. |
Sorry, I did indeed mean to say it sends a 500. We log all 500s as app 500 is still not ideal and we should think about the fix because a 500 On Sunday, March 15, 2015, Douglas Christopher Wilson <
|
@defunctzombie I agree we need to take care of it. I was just working on pushing this stuff out, ran into the weird changes in the app.use(function (err, req, res, next) {
if (err.name === 'TypeError'
&& typeof err.status !== 'number'
&& String(err.message).indexOf("'hasOwnProperty'") !== -1) {
err.status = 400
}
next(err)
}) |
@defunctzombie while we wait for this issue to be resolved, I think I'm actually going to change the wrapper not to return a 400, but rather an empty object |
In the current case tho I think a 400 is correct, no? The client specified Failing silently will lead to users possibly complaining to app authors On Monday, March 16, 2015, Douglas Christopher Wilson <
|
@dougwilson @defunctzombie so I'm trying to think through this.. I definitely feel like it's best to continue refusing to overwrite keys that belong to the object's prototype, since this is a security concern. After all, the reason you were seeing errors at all is because someone was attempting to write to the Yes, it does mean that users who are tainting Thoughts? |
In the end, this is why the return should be of |
I tend to agree. I'll look into shuffling things a bit. |
Ok, so even with the change I made a bit ago you still effectively get keys that match prototype methods stripped due to additional checks. What I'm going to do is shuffle things so that this module only deals with objects created via This is definitely a major change though, and I have a couple other things that I want to land in 3.0.0, so give me a day or two to get that done. |
Awesome stuff! Great discussion and I think the end result will be a On Monday, March 16, 2015, Nathan LaFreniere notifications@github.com
|
In the meantime, I'm going to use whatever version of |
https://github.com/hapijs/qs/blob/master/lib/parse.js#L32
When the object is created via
Object.create(null)
it does not have object properties. Instead, the following should be used:The text was updated successfully, but these errors were encountered: