-
Notifications
You must be signed in to change notification settings - Fork 102
Description
On the client side, when we create a new post we use the Meteor.uuid() function to create a random string for the post _id, this is sent to the method and inserted into the database as perfectly fine to use as long as it passes check(_id, String).
There are two problems with this:
Meteor.uuid()is deprecated.- Open to abuse. There is no validation on the server side to check that the
_idbeing passed is truly a random_idtherefore a user could pass anything they wish. See my post on the demo website with an_idof lolcats.
A breakdown on how someone who cannot see the repo could work this out for those wondering:
On the client console you can call Meteor.connection._methodHandlers to see a list of available methods. You can see near the bottom posts.create: e(e,t,r), in chrome you can right click this and "Show function definition", now we can see the method function itself which is (after unminified):
methods({
"posts.create": function() {
function e(e, t, r) {
n.check(e, String), n.check(t, String), n.check(r, String);
var s = new Date,
u = {
_id: e,
title: t,
content: r,
createdAt: s,
saving: !0
};
o.Posts.insert(u)
}
return e
}()
})
Now we know what is expected to be passed through and how each variable is being checked. So if we wanted, we could now do:
Meteor.call('posts.create', 'lolcats', 'My Title', 'The Content') and server will accept this.
Now this isn't much of a security issue, this only opens the ability for a troll to have some fun. However, a personal project I'm fine with, a business website I'd like to close this. One solution would be to create the Meteor.uuid() on the server side however we would lose the method stub ability, I'm sure there are other solutions but this is all I can think of at the moment.