Skip to content

Malware Included: Imported 3rd Party JavaScript as Attack Vectors

Michael Schrenk

Michael Schrenk analyzes how top websites import third-party JavaScript, exposing web supply chains to remote script tampering, credential theft, and malware delivery.

Summary

Architecture and Background

Modern web applications heavily incorporate third-party JavaScript for analytics, tag management, advertising networks, and user tracking. These remote scripts execute within the origin context of the host application, inheriting unrestricted access to the Document Object Model (DOM), cookies, and sensitive user inputs.

Vulnerability Analysis

Schrenk conducted an empirical automated audit across the top 1,000 internet websites, examining how external dependencies are imported. The research revealed widespread lack of subresource integrity (SRI), uncontrolled script tag chaining, and excessive reliance on multi-tier content delivery networks (CDNs) that create brittle web supply chains.

Exploitation and Demonstrations

A single compromised CDN, hijacked domain, or rogue internal developer on a third-party service can weaponize benign scripts. Injected payloads execute invisible session hijacking, formjacking (Magecart attacks), keylogging, or distributed cryptomining directly inside visitors' authenticated sessions.

Remediation and Defensive Strategies

Organizations must enforce strict Content Security Policy (CSP) headers, implement Subresource Integrity (SRI) hashes on all external assets, and audit script dependencies continuously. Self-hosting critical client-side libraries and deploying sandboxed iframe architectures mitigates exposure to upstream vendor compromise.

Related talks

Main Stage·22 min

  • DEF CON
  • AppSec
  • Date: Aug 2013
  • Location: Las Vegas

Kenneth Lee

Kenneth Lee details how to use CSP to stop XSS KENNETH LEE PRODUCT SECURITY ENGINEER, ETSY INC.

cross-site-scriptingcontent-security-policyweb-security+1