Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aren't Javascript analytics scripts susceptible to easy data hacks?

On Production environments, Javascript based analytics scripts (Google Analytics, Facebook Pixel etc.), are injected into most web applications, along with the Unique ID/Pixel ID, in plain Javascript.

For example, airbnb uses Google Analytics. I can open up my dev console and run

setInterval(function() {ga('send', 'pageview');}, 1000);

which will cause the analytics pixel to be requested every 1 second, forever. That is 3600 requests an hour from my machine alone.

Now, this can easily be done in a distributed fashion, causing millions of requests per second, completely skewing the Google Analytics data for the pageview event. I understand that the huge amounts of data collected would correct this skewing to a certain extend, but that can be easily compensated by hiking up the amount of requests.

My question is this: are there any safeguards to prevent competitors or malicious individuals from destroying the data integrity of applications in this manner? Does GA or Facebook provide such options?

like image 620
nikjohn Avatar asked Nov 08 '22 00:11

nikjohn


1 Answers

Yes,but the unsafe part don't comes for the Javascript. For example, you can use the measurement protocol to flood data to one account. Here you can see a lot of people in the same comunity having thoubles with this (and it's quiet simple to solve.) https://stackoverflow.com/search?q=spam+google+analytics

All this measurement systems uses HTTP calls to fill the data on your "database". If you are able to build the correct call you can Spam Everyone and everywhere (but don't do it, don't be evil).

https://developers.google.com/analytics/devguides/collection/protocol/v1/?hl=es-419

This page of Google Analytics explain what is the protocol measurement, Javascript only work as framework to build and send the hit.

https://developers.google.com/analytics/devguides/collection/protocol/v1/?hl=es-419

But, so not everything is lost. For example, if you try to do that on you browser with that code, The Google Analytics FrameWork limit to 1 call per second and 150 per session (or cookie value). Yes it's not complicated to jump that barrier, but after that other barriers will come.

So if you use the Javascript framework are safe. Now imagine you do the same with python, sending http to the Google Analytics server. It's possible but: So here are 2 important things to says.

  • Google Analytics has a proactive "firewall", to detect Spammers and ban them.(How and when they do this is not public), but in my case i see a lot of less spammer that few years ago.

  • Also there is a couple of good practices to avoid this. For example, store only domains under a white list, creating a filter to allow only traffic from your domain https://support.google.com/analytics/answer/1033162?hl=en

  • Also it's a very good practice to protect you ecommerce, using a filter to include only data from certain store or with certain parameter, "for example brand == my brand" or "CustomDimension== true". Exclude transactions with products over $1.000 (check your limits and apply proactive filters). All this barrier make complex to broke.

If you do this, you will protect your domain a lot(because it's too much complicated to know the combination of UA + Domain Valid when you create a robot), but you know, all the system can be broken. In my experience i only see 2 or 3 cases of damage comming from spammer or people who wanna hurt, and in all this case could be prevented if I created a proactive filter. Usually spammer only spam ads into your account,almost never want to hurt you. Facebook, Piwik and other Tools happens more or less the same.

like image 51
Kemen Paulos Plaza Avatar answered Nov 14 '22 23:11

Kemen Paulos Plaza