0
votes

Is it possible for a hacker to modify my data that gets put into offline pouchdb then syncs to online couchdb? Yes I will have ssl enabled on the server.

In my current setup. vue.js spa for pwa deployment.

const response = await this.postService(
          {
            _id: newId,
            dateCreated: date,
            updated: [],
            viewed: [],
            viewedCount: 0,
            approved: true
          },
          sync
        );

I'm sending this obj to function to put obj into local pouch db and then syncs to online couchdb. Now if someone can edit the obj data approved: true I would be in a lot of trouble trying to ban a user.

postService(dataObject, sync) {
      // to do make sure couchdb had validation function
      var self = this;
      // to do this.$store.dispatch("PostServiceSynced", false);
      return postsOffDb
        .put(dataObject)
        .then(function(response) {
          // to do enable sync 
          // if (sync) {
          // sync offline to online db
          postsOffDb.replicate
            .to(postsOnDb, {
              live: true,
              retry: true,
              back_off_function: function(delay) {
                if (delay === 0) {
                  return 1000;
                }
                return delay * 3;
              }
            })
            .on("change", function(change) {
              // yo, something changed!
              console.log("posts replicate change", change);
            })
            .on("complete", function() {
              // yay, we're done!
              console.log("postsOffDb replicated");
            })
            .on("error", function(err) {
              // boo, something went wrong!
              console.log("err", err);
              return response;
            });
          // }
          return response;
        })
        .catch(function(err) {
          console.log("postService err", err);
          }
          return err;
        });
    },

My work around would be send the obj to a middleware express.js add the default data like approved: true there. Then send it to couchdb. But then I would miss out on a reason to use the syncing services of couchdb I may as well go with mongodb? Anybody have the know how?

1
Any data beyond your control is hackable. This includes data stored in PouchDB. There is no way around this. The best you can do is data validation when it re-crosses the barrier into your control. And this has nothing to do with CouchDB. It is fundamentally true of literally every database or data storage mechanism. - Flimzy
Thanks, Flimxy. I"m a newbie to attempting to make an offline first app. Definitely, a little more to think about. I thought that pouchdb might be only editable by the originating website. Then once created make validation functions design documents for validating the data before it enters pouchdb then sync to couchdb. What about if its a mobile app made with capactior ? Users can't mess with the data on your mobile can they? - Travis Klein
Once the data leaves your control, assume it can be edited by anyone. It's trivial for someone with knowledge, to edit data stored by pouchdb (or any other database). - Flimzy

1 Answers

0
votes

Flimzy's comments help answer the question for sure. I came across the google group here that has good info also