I have a marketing team that wants to use social sharing buttons (Facebook, G +, SU, etc.) on our website. The security group raised a point where I was embarrassed to admit that I had not really considered this before: since third-party JS is an attack vector, we should not download it directly from third-party servers.
Risk
As an example, I will use Facebook. Someone from FB may add some hidden backdoor code to view users or at least get their email and name from our website. DNS cache poisoning can be used to serve malicious Javascript instead of the expected FB library. Etc - there are probably a lot more attacks here.
Possible solutions
-Want JS locally (after checking it for security holes) and run curl + diff on cron to monitor for updates - checking for these updates before hosting. This is not real, because FB and g + load additional libraries outside the site after loading their main library, and I did not find a way for this.
-Don't use social sharing buttons?
Is there any best practice here? My first reaction is that, come on, these are Google and Facebook. If something maliciously happens to their shared buttons, the entire Internet will know about it in 0.001 seconds. What are you saying?
source share