Cyber Security

The Script You Didn't Write: Protecting Your Website and Customers From Third-Party Code

← Back to all articles

Here's a question worth putting to your web team this week: how many companies can change what runs on your website?

Not just your developers. Count the analytics tool, the chat widget, the cookie banner, the tag manager, the testing service and the booking plugin. Each one loads code from someone else's server straight into your customers' browsers, and most businesses have never written that list down.

On 16 November, that trust was turned against some of the best-known websites in the world.

What happened

An attacker exploited a vulnerability in the account sign-up flow of Optimizely, a platform companies use to test different versions of their web pages, and used it to add malicious JavaScript to some customer projects, Optimizely told BleepingComputer. Because those projects load on customers' websites, the code ran for anyone who visited.

Security researcher Scott Helme and his team at Report URI checked 1,611 Optimizely scripts and found 188 infected ones, belonging to 178 organisations. The sites named in reporting include Zoom, CNN, the BBC, Salesforce, GitLab, KLM and Air France, and Report URI expects the real total to be higher.

According to Report URI and Infosecurity Magazine, the code:

  • swapped cryptocurrency wallet addresses for the attacker's own;
  • skimmed card numbers, expiry dates and security codes typed into sites' own forms;
  • collected cookies and took screenshots;
  • tried to infect iPhones and iPads that had not been updated.

Optimizely says it blocked the vulnerable path, deployed a fix, removed the injected code and notified affected customers. By late evening UTC the same day, only one of the 188 infected files still contained the malicious code.

The part worth noticing

None of these companies was hacked in the usual sense. Their servers, passwords and firewalls were fine. The attacker went after a supplier whose code they had invited onto their own pages.

One detail matters for anyone who takes payments online. Card details entered into hosted payment fields, the boxes supplied by payment providers such as Stripe or Adyen, were out of the code's reach. The cards at risk were the ones typed into a website's own forms.

Why this matters for UAE businesses

You don't need to be the BBC for this to apply to you. A trading company's quote request form, a hotel's booking page, a clinic's appointment form and a distributor's customer portal all collect names, phone numbers and sometimes payment details, and most of them load several third-party scripts.

If one of those scripts is turned against you, your customers see your brand, not the supplier's. Personal data taken from your site can also raise questions under the UAE's Personal Data Protection Law (PDPL). And if you accept cards, the PCI DSS standard already expects this work: version 4.0 asks you to keep an inventory of every script on your payment pages, justify each one (requirement 6.4.3) and detect unauthorised changes (requirement 11.6.1).

If you are a reseller, system integrator or MSP that builds or runs websites for clients, the same questions apply to every site you look after.

Your action plan

Here is what we would do, in this order.

This week

  1. List every script on your site. Open your tag manager and your page source and write down every third-party service: what it does, who added it and who can change it. Start with your checkout, quote, booking and login pages.
  2. Remove what you no longer use. Old trackers, a chat tool you replaced, a test that ended last year. Every script you remove is one less supplier that can put code on your pages.
  3. Lock down the accounts that can change your site. Turn on MFA for your tag manager, your website platform and every marketing tool that can publish code, and remove anyone who has left or no longer needs access.

This month

  1. Keep card entry off your own forms. Use your payment provider's hosted payment page or hosted fields, so card details never pass through code you don't control.
  2. Limit where scripts can load from and send data to. A Content Security Policy tells browsers which domains your pages may load code from and send data to, so a hijacked script cannot quietly post card details to an unknown server. For scripts that rarely change, Subresource Integrity lets the browser refuse a file that has been altered.
  3. Watch your most sensitive pages. Set up monitoring that alerts you when a new script appears or an existing one changes on your payment, quote and login pages.

Before you need it

  1. Know how to pull a script fast. Agree who can switch off a third-party tool in your tag manager or site settings within minutes, and keep the support contact for each supplier somewhere you can find it during an incident.

Our view

Third-party tools make websites better, and nobody is suggesting you give them up. But every script you add is a supplier with a key to your shopfront. Know who they are, give them as little room as possible and watch what they do. The first step takes an hour: make the list this week.

If you would like help reviewing the scripts on your website, setting up a Content Security Policy or choosing web security and monitoring tools, contact our team.

Drawing on reporting from Report URI, BleepingComputer, Infosecurity Magazine, PCI Security Standards Council.

Chat with us WhatsApp