How To Vet and Manage The Behavior of Third-Party Scripts on Your Website

By Jscrambler 5 min read

Vetting and managing third-party scripts on your website helps you avoid website failures caused by them. Also, the third-party JavaScript management Cheat Sheet is especially relevant when developing software products, namely web applications.

Third-party code has become the norm, accelerating the development lifecycle.

What are the impacts of this third-party code on application security?

We explore the current state of web application development, the associated security risks, and how to vet and manage third-party scripts on your website.

The Current State of Web App Development

The current demanding and dynamic market puts added pressure on development teams to deliver products faster.

To keep up, teams have to shorten the web app development lifecycle, which raises concerns about application security.

To understand the core of the security concerns, we first need to understand that to speed up the development lifecycle, teams rely on various third-party scripts, frameworks, and libraries.

70% of the code in the average web app is sourced from third parties. And with 35 third-party components and 31 fourth-party components on average, it’s no wonder that the typical web application contains a huge mashup of client-side code (as illustrated below).

But why does this result in a larger attack surface?
mashup-of-client-side-codeWhen development teams use externally sourced code, they inherently trust that third-party code, along with any fourth-party code it uses, and so on.

Companies end up with a long chain of code dependencies without clear visibility into what they’re running and what each piece of code actually does.

The risks of the lack of visibility over third-party code

The main problem with lacking visibility and control over third-party code is that third-party scripts have the same privileges as internally developed code. This means a third-party chat plugin can start interfering with a payment form (which is precisely what happened in the Ticketmaster/Inbenta Magecart attack of 2018).

Because modern web apps pass a lot of sensitive data through the client side, a rogue third-party script can leak it.

When an attacker breaches a third-party script provider, companies using that script have no visibility into the attack.

Web application firewalls and other network defenses consistently fail to detect the attack because it originates from a trusted source.

Attackers have a window to exfiltrate any collected data and send it to a drop server they control. In Magecart web skimming attacks, research shows they rose 20% during the pandemic and remain active, on average, for 22 days before being detected and removed.

Consequences of a Third-party Script-based Attack

With the development of strict regulations like GDPR and CCPA, leaking sensitive user data to attackers is a clear violation of users’ privacy rights. When it comes to payment data, this can also mean a breach of PCI DSS compliance.

Breaching compliance with any of these regulations can result in financial costs from hefty fines.

Magecart attacks are well-known third-party-based attacks because they have resulted in some of the highest fines seen under security and privacy compliance regulations.

Beyond direct compliance breaches, companies must also consider reputational damage, which can lead to business losses and leave a permanent dent in customer relationships.

Vetting and Managing the Behavior of Third-party Scripts

First, you must gain visibility into which third-party scripts are running on the website and what types of actions they are performing (i.e., their behavior).

We provide a free website inventory report that gives a snapshot of these scripts and their behavior, broken down into actionable insights.

The report starts by detailing how many domains receive data from the website and how many are third-party.
website-inventory-report-third-party-scripts-behavior

It also analyzes the assets loaded on the website, including how many come from third parties and how many different domains load them.
Get-visibility-into-third-Party-scripts

Another key detail is the number of poisoning events detected on forms and network events, which may indicate that third-party scripts are collecting form data or intercepting network traffic (data leakage).
poisoning-events-Manage-behavior-of-Third-Party-scripts

The report also presents high-level tables displaying critical client-side security threats, such as the one below.
inventory-table-example-with-warnings-and-events

The report includes other tables and graphs with detailed information on specific detections, such as:

  • Code or native API poisoning
  • Source domains
  • Destination domains
  • Resources and scripts
  • Breakdown of scripts into first- and third-party
  • A digested overview of the critical issues.

This information allows you to vet third-party script behavior and is an important step toward reducing the website’s attack surface.