KeySpaceConstrainedParams is supposed to prevent the application from clients that send too many keys+values by limiting the amount of space they can take up. I don't think that this is the correct approach, and also, in its current version it isn't very useful because anyone who wants to do damage can circumvent the protection mechanism with ease being that nesting is supported.
The code in question is:
The current limit applies to every KeySpaceConstrainedParams instance in isolation, but the childrens are not being considered, which means that for the possible resulting structures, the limit is actually much higher (actually, it is infinite, there is no limit when nesting is involved)
My opinion is that having this isn't really useful, and should be handled by any server that sits in-front of our app (nginx, apache, whatever).
This is supposed to protect again a vulnerability in older Ruby versions. Nesting is not an issue either. This is not supposed to save memory but to avoid hash collisions (where you can keep ruby calculating and comparing bits for hours with just a 5 MB payload).
Fair enough, thanks for the explaination. Lets say I wanted to implement params using a Flask-like MultiOrderectDict implementation (as a possible to get what I'm asking for in #355), would you say that I should still have to take care of this?
Do you remember which versions of Ruby are vulnerable?
Ok, found it: http://osvdb.org/show/osvdb/78118