Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
Third-party scripts are programs a site loads from outside, and the risk that they are tampered with. The term originally means adding functions such as analytics, advertising, chat, and maps with programs distributed by an outside provider. Because they run inside your own site, if the source is rewritten, the effect reaches your site.
How do third-party scripts work?
Picture a shop that puts up a signboard prepared by another company at its entrance. The content of the board is decided by that company, not the shop. If the company's side is rewritten, a false notice appears at the shop's door. The customer takes it as something that happened at the shop, though the shop did nothing wrong.
MITRE's CWE-830 defines the weakness where functionality such as a widget is taken in from another domain and its code runs inside your own domain. The definition adds that this may give an untrusted provider full access to and control of the product. OWASP Top 10:2021 also gives, as examples of parts from untrusted sources, plugins and libraries, and the content of a CDN (a mechanism that spreads delivery across the world). Specific cases and checks are on the third-party scripts page.
Why do third-party scripts matter?
A script loaded on the same page as a payment or login screen runs inside that page. When you think about damage such as formjacking, the origin of code that runs on the same page is a subject for checking. Even if you have not updated anything, a change at the outside source changes how your site behaves.
W3C's Subresource Integrity (SRI) specification is one way to check. You record in advance a value (a digest) that represents the content of the file to load, and the browser compares it with the file it received and does not run it if they differ. W3C explains, as background to the specification, that even when TLS and similar mechanisms confirm the server, they do not confirm the content itself.
The method does not suit parts whose provider changes content often. Consider CSP, a setting that tells the browser which sources are allowed, as well. In operation, it also helps to remove tags you do not use and to decide who judges whether to add a new one.
To talk through whether to keep a script, contact us.
Related terms
- Formjacking: swapping the payment screen for a fake one to steal card numbers.
- CSP: a setting that tells the browser which sources it may load from.
- Tampering: a site's contents being rewritten without permission.
- Software integrity failures: not confirming that update files or parts are genuine.
Next step
How to list the external scripts you load is explained in measures against tampering. The free URL check shows only what is visible from outside. For a decision on whether to keep using a script, contact us.
Frequently asked questions
Do analytics and advertising tags count as third-party scripts?
Yes. Anything that loads a program distributed by an outside provider, rather than one kept on your own server, is a third-party script. List what you load, and remove tags you do not use.
Are we safe if we use no third-party scripts?
The more you use, the more risk you add, but not using them does not make you safe on its own. Site updates and login protection can have holes too. Reduce those with weak reasons for use, and add a way to verify the content of what you keep.
Frequently asked questions
Do analytics and advertising tags count as third-party scripts?
Yes. Anything that loads a program distributed by an outside provider, rather than one kept on your own server, is a third-party script. List what you load, and remove tags you do not use.
Are we safe if we use no third-party scripts?
The more you use, the more risk you add, but not using them does not make you safe on its own. Site updates and login protection can have holes too. Reduce those with weak reasons for use, and add a way to verify the content of what you keep.