Skip to content

Meteor.uuid is deprecated and untrusted on the client side #108

@MechJosh0

Description

@MechJosh0

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:

  1. Meteor.uuid() is deprecated.
  2. Open to abuse. There is no validation on the server side to check that the _id being passed is truly a random _id therefore a user could pass anything they wish. See my post on the demo website with an _id of 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions