Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Using the Parse JavaScript SDK? Be Careful!

Using the Parse JavaScript SDK? Be Careful!

14

Parse is a cloud platform that makes it easy for you to create applications without worrying about server infrastructure, databases or even hosting. The company, which was recently acquired by Facebook, has over 100,000 apps built on the platform, including iOS, Android and Web applications. The platform provides SDKs for a variety of platforms, but the one I’ll be covering is the JavaScript platform.

The JavaScript SDK is a great tool to add database storage and other features to your website, but there are a few things you need to be aware of. Namely, it’s quite easy for someone to modify your database or even access sensitive information. For example, I can run some JavaScript code through Google Chrome on a website using Parse to access names and email addresses.

Using the JavaScript console, the below script can access and print out names and email addresses from a Parse database quite easily:

If I run the above code on a Parse website using the JavaScript SDK, I get something similar to:

Parse User Info Hacking

If I wanted to, I can also see how popular a website is by counting the total number of registered users (or any other data):

Parse User Count

Even worse, if permissions (or ACL as it’s known in Parse) are not set correctly, a hacker is able to create or delete data as they wish. In the below example, I create a new table (or Class as it’s known in Parse) in Parse called “Fake”, and insert some data into it. To test that it worked, I then use a query to get the contents of the Class:

Create and Access Parse Object

I won’t show how to delete something for obvious reasons, but I’m sure anyone determined enough can work out how to delete an entire database of users by just looking over the Parse documentation. The above examples were executed on a production website I found via the Parse Application gallery, showing just how easy someone can access or delete data.

There are some obvious measures you can take to protect your data, however. I recommend the following actions:

  • Where possible, avoid the use of the JavaScript SDK altogether. Someone can easily look through your code to find your API keys, and then determine what Class names you use to access or modify data.
  • If you do use the JavaScript SDK, you should turn off the “” setting, found under [Settings] > [General Settings] > [App Permissions]. This will prevent hackers from creating new classes using the JavaScript SDK.
  • When creating objects, set the correct ACL permissions. Only allow an authenticated user to edit information, and only allow anonymous / public users to access non-sensitive information.
  • When accessing the default User class (which stores emails, usernames and password), avoid using the JavaScript SDK. Instead, use a server-side library (like PHP) to authenticate the user and then give the user access to the other data.
Hacking, JavaScript, Parse, Security

14 comments on “Using the Parse JavaScript SDK? Be Careful!”

  1. Nikolai Onken says:
    April 24, 2014 at 6:28 PM

    I also saw that the access token which you get after logging in is stored in localStorage and this token seems to be permanent, non-revokable. I must be missing something because it seems very very odd that once someone got access to your token (be it a person getting access to your machine) there is no way to forcefully log out the user. What am I missing? Seems totally insecure to me.

    Reply
  2. Dmitri Zaitsev (@Dmitri145) says:
    May 17, 2014 at 12:12 PM

    If the token is stored permanently, that is definitely odd. Is this a verified confirmed information? Does Parse confirm this?

    Reply
    • Niraj Shah says:
      July 3, 2014 at 2:30 PM

      Yes, I can confirm this to be true. Here is what Parse stores in local storage:

      Reply
  3. Parse.com: Using DataTypes, Pointers and ACL in PHP and JavaScript | Web Niraj says:
    July 3, 2014 at 2:24 PM

    […] One of the most common question I get with Parse is how to use Pointers, DataTypes and ACL – this tutorial covers how to do all three in both PHP and JavaScript. […]

    Reply
  4. Anthony DeFreitas says:
    September 16, 2014 at 3:50 AM

    The default _User class is readable by default but this can easily be changed and everything else can be locked down to a granular level.

    https://parse.com/docs/data#security

    Reply
  5. Jim Carter III says:
    October 21, 2014 at 6:39 PM

    Avoiding the JS SDK is an extreme recommendation. Like *any* product development, security should be both understood and risks known by the developers. Parse makes the security options clear. With a little planning and lot of testing, a JS app can be just as secure as anything else.

    Reply
    • Niraj Shah says:
      October 24, 2014 at 11:36 AM

      Yes, an extreme recommendation if you don’t know how to secure your data. In my research for this article, I found many production websites that didn’t even take a basic measures to secure their data or protect it from deletion. I agree, JS can be just as secure as server-side languages, but with Parse JS a lot of precautions need to be taken, and I found that a lot of developers aren’t even doing the basics.

      Reply
  6. She's Alright says:
    April 23, 2015 at 11:52 AM

    Why is it when I run the script it only spits back a max of 99 users and emails.

    Reply
    • Niraj Shah says:
      April 27, 2015 at 7:35 PM

      Use the limit parameter to increase the limit. E.g. /me/friends?limit=500.

      Reply
      • She's Alright says:
        May 1, 2015 at 1:36 AM

        I’m using this script but for some reason I still get the ” b.Error {code: 154, message: “Skips larger than 10000 are not allowed”} “. It’s as if my skips arent working properly. And it doesn’t seem to want to return all users. I’ve got about 300K + users. Any help is appreciated! Thanks!

        var div=$(“div”)[0];
        if(div.childNodes.length)
        for(var i=0;i<div.childNodes.length;i++)
        {
        if(div.childNodes[i].nodeType===3)
        div.removeChild(div.childNodes[i]);
        }

        var query = new Parse.Query("User");

        query.count({
        success: function(count) {
        var chunk = 1000;
        var cycles = Math.ceil(count / chunk);

        for (i = 0; i < cycles; i++) {
        var _query = new Parse.Query("User");
        _query.descending("updatedAt");
        _query._limit = chunk;
        _query._skip = i * chunk;

        console.log("getting results " + _query._skip.toString() + " to " + (_query.skip + _query._limit).toString());

        _query.find({
        success: function(results) {
        // cycle through the results
        for ( x in results ) {
        // print out the usernames and email addresses
        console.log( results[x].attributes.email );
        }
        },
        error: function(error) {
        console.log("error");
        console.log(error);
        }
        });
        }
        },
        error: function(error) {
        console.log("error");
        console.log(error);
        }
        });

      • Niraj Shah says:
        May 7, 2015 at 4:29 PM

        As the error says, you can’t skip more than 10,000 records. The workaround is to use the createdAt column to get the rest of the data. E.g. Get the first 1,000 users and look at when the last user was created. On the second cycle, don’t set the skip but instead look for createdAt less than the date or the last user.

  7. Nand says:
    June 10, 2015 at 5:00 AM

    Thank Niraj, wwe can use cloud code to store our query,

    Reply
  8. Jb says:
    August 10, 2017 at 2:34 AM

    Thanks Niraj. How would I use your script on a website? I’m not sure how to test it. I copy-pasted into chrome console but said “Parse undefined”

    Reply
    • Niraj Shah says:
      September 26, 2017 at 10:49 AM

      Sounds like the website you’re attempting to use this on doesn’t have the Parse JavaScript SDK installed.

      Reply

Leave a Reply to Dmitri Zaitsev (@Dmitri145)Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy