Securing and Trusting Third-Party Javascripts in Your Web App
Where
Day 2 Stream 2
BSides Las Vegas
Duration
27 min
Explains the risks of third-party JavaScript in web apps and how CSP, iframes and SRI mitigate them.
Summary
The talk starts by defining third-party JavaScript as code served from external servers that a site owner does not write or control, such as analytics, advertising and social sharing widgets. It then covers the three common ways these scripts reach a page: a direct script tag pointing at a vendor URL, vendor code pasted inline, and loading everything through a tag manager. Tag managers are popular with marketing teams because they let non-developers add or change scripts without redeploying the app.
The talk then turns to risk. A script running in the page gets full access to the DOM, can read sensitive input such as payment details, and can be changed by its owner at any time. The card-skimming attacks against shared checkout scripts show how compromising one vendor can expose many sites at once. Mitigations discussed include a Content Security Policy with script-source directives and nonces, which limits what loads but does not inspect what a script does; an iframe, which blocks DOM access but breaks analytics and tag managers that need the page; and Subresource Integrity, which pins a script to a hash. SRI fits poorly with tag managers, since their containers change without a code deploy and the hash goes stale.
The closing advice is practical. Keep scripts off sensitive pages such as checkout or password change where possible, teach teams that use tag managers about the risks, and bring in vendor security and legal reviews before trusting a provider. When a dynamic script must touch the DOM, the remaining risk is assessed, CSP is used as a baseline, and what is left is formally accepted.
Related talks
Day 2 Stream 2·25 min
Ali Kabeel
Shows how business logic flaws in web apps, like invite and reset flows, let attackers bypass intended rules.
OWASP Foundation·37 min
Michael
Security researchers examine technical aspects of AppSec EU 2017 Combining The Security Risks Of Native And Web Development Hybrid Apps.
Talks·59 min
Sheshananda Reddy Kandula
Explains how quantum computing threatens RSA and ECC and outlines first steps for AppSec teams toward post-quantum cryptography.


