3 ms·
No I think YOU don't get it. Anything sent to a web app via HTTP is user generated content. You can't assume it is ANYTHING.
by stephenr 13y ago
No I think YOU don't get it.
Anything sent to a web app via HTTP is user generated content. You can't assume it is ANYTHING.
- ayi 13y agoThat's what i'm saying. You shouldn't trust any data from sources like cookies, query strings and even http headers. If you blindly trust them, this is not a problem of programming language. You should sanitize data before using it.
- btilly 13y agoThe point is that if you build a data structure for MongoDB in any language other than PHP, and just include the user parameter where it belongs, the only thing that the user can supply there is a string and it is easy to verify that there is no possible security problem. MongoDB's APIs were designed around this fact as an easy way to avoid the possibility of SQL injection type attacks. In PHP the exact same approach turned out to be a security hole because if the user supplies the right input you get a data structure that is meaningful to MongoDB. As you say, you shouldn't assume anything about user generated content. But PHP's willingness to parse that input and turn it into something the programmer didn't expect to see often means that user generated content is harder to deal with in that language than you should reasonably expect it to be.
- stephenr 13y agoSeriously how hard is it to call filter_var() or even is_string() to ensure its a string?
- btilly 13y agoIt is impossible if you don't know you have to. For several years if you followed the examples in the MongoDB docs, you wouldn't have known you had to, because the people who wrote those docs didn't know you did either.
- stephenr 13y agoSo not understanding the language you are writing an extension for is more acceptable to you than allowing a basic but useful way to accept semi structured data in http requests?