-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
use in
to check for prototype violation
#484
Conversation
in
to check for prototype violation
Well. hmm. why not just do or more performant:
Then you can allow even "bad" names. |
I really prefer the second one or simply doing WDYT? |
Object.create(null) is super slow. imho this should be discussed. same as we did with delvedor/find-my-way#333 Well. hmm. i should write that benchmark i promised few weeks ago for find-my-way. |
Wow, the performance difference is huge 😄 |
How about making the body null prototype? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in
will look through the prototype chain, so a no in here
Yeah, but Its prototype is So equivalent to |
@Uzlopak not sure anymore about that... I don't think it should be possible with multipart but if someone sneaks in a custom proto object then you certainly have prototype poisoning The checks should stay even if we make it a null proto object function NullObject () {}
NullObject.prototype = Object.create(null)
// {}
a = new NullObject()
// NullObject {}
a
// NullObject {}[[Prototype]]: ObjectNo properties
a['__proto__'] = {shh: 5}
// {shh: 5}
b = Object.assign({}, a)
// {}
b.shh
// 5 |
I think was already planned for fastify v5. isn't it? |
I think this was referring for parameters object. idk. |
I think just to align the multipart parser with the default JSON parser, we should make |
Can I persuade someone to approve? 😁 To reiterate, This should be a free performance improvement 🤠 |
Well. Do we had before this PR unit tests covering prototype pollution checks? |
We have checks for proto pollution: fastify-multipart/test/multipart-security.test.js Lines 16 to 105 in 109a116
Let me add a few more |
Ah, i think there is also another issuer with using If we dont use a null object this means, that we use Object. Object has e.g. If this PR lands, it will make it impossible to use keys like That is my assessment of @climba03003 remark. I am not at my PC to check it. Can you check it please? Maybe this can be done if we switch to NullObject body. |
No, it is much more simpler than that
For the prototype chain, ECMAScript defines that So instead of calling |
Ah, i see. @climba03003 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, but please dont merge before we did not convinced @climba03003
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, after a few test Object.prototype
is allowed to modify.
It's 36% faster and provides clearer intent
Benchmark
Checklist
npm run test
andnpm run benchmark
and the Code of conduct