LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Web Development/Tutorials / Embedding Third-Party Files on Websites: Checking Origins,...
Read this article in other languages:

Embedding Third-Party Files on Websites: Checking Origins, Permissions and Tamper Protection

Embedding Third-Party Files on Websites: Checking Origins, Permissions and Tamper ProtectionEmbedding Third-Party Files on Websites: Checking Origins, Permissions and Tamper Protection

Management Summary

Websites often load code and other files from outside suppliers to add useful functions without building everything themselves. This also introduces a dependency on what the supplier delivers and what the imported code is allowed to do. An integrity check compares a file with an expected digital fingerprint and can block an unexpected version. It does not prove that the expected code is harmless. Understanding suppliers, permissions and controlled updates is therefore central to dependable external integrations.

Contents
  1. Origin, domain and operator are different concepts
  2. Embedding determines capabilities
  3. What Subresource Integrity protects
  4. Controlled releases
  5. Markup is not a network measurement
  6. Limits of the linked checker
  7. Questions and answers
  8. Sources

External files are a normal part of a website. Three separate questions matter: which address supplies a file, what capabilities does the embedded content receive, and is a specific file version expected? A host list answers only part of the problem.

Origin, domain and operator are different concepts

A browser origin combines scheme, host and port. https://example.com and https://static.example.com have different origins. Grouping by registrable domain can help an inventory, but does not prove common technical control: subdomains can be delegated to services. Conversely, different domains can share an operator.

An up-to-date Public Suffix List records suffixes such as com and co.uk. It is more suitable for domain grouping than simply retaining the last two labels, which would mistake co.uk for a registrable domain. Even correct grouping does not establish service ownership, responsibilities or the details of an integration.

Origin, capabilities and integrity require separate checks.
Origin, capabilities and integrity require separate checks.

Embedding determines capabilities

  • Scripts: An allowed external script runs in the embedding document’s context and can change content or form values there. Access to other origins is still restricted. HttpOnly cookies, for example, remain unreadable to JavaScript; browser rules and a CSP constrain particular actions.
  • Stylesheets: CSS changes presentation and can request additional resources. A stylesheet is not a JavaScript program, but trusting CSS is more than a decorative decision.
  • Iframes: A frame has a separate document context. Across different origins, the same-origin policy restricts direct DOM access. The choice of sandbox restrictions and other permissions needs separate assessment.
  • Images and media: An image file normally gains no JavaScript access to the containing document. A request can nevertheless disclose an IP address and, depending on browser rules, referrer policy and cookie settings, additional information. “Passive” does not mean privacy-neutral.

HTML order is not a universal execution order. In particular, async can change script ordering; images and stylesheets are not executed like JavaScript.

What Subresource Integrity protects

Subresource Integrity (SRI) compares a fetched file with an expected cryptographic hash: a check value calculated from the file contents. A valid hash that does not match prevents use of the resource. This protects the pinned file against unexpected changes, but does not establish harmless code or automatically cover subsequently loaded files.

A nonempty integrity attribute does not prove successful verification. The algorithm, digest, response and loading conditions must match. Cross-origin files also require a suitable CORS response. Classic scripts and stylesheets commonly use crossorigin="anonymous" for this purpose. That mode omits credentials for cross-origin requests; same-origin requests can still include credentials. JavaScript modules already use CORS.

Controlled releases

A versioned file path makes content and hash easier to match. Deployment should pair the reviewed file with its hash, followed by a browser loading test and console inspection. Hashing an unreviewed response merely makes potentially harmful code reproducible.

A continuously updated file at a fixed address is not inherently unverifiable. SRI does, however, require a coordinated release process or a stable version supported by the supplier. Unannounced changes can break the integration. Without that process, loading remains a documented trust decision; the number of files is not a security score.

Markup is not a network measurement

HTML-only analysis misses dynamically loaded scripts, CSS resources and interactions. Conversely, preloads, duplicate references, alternative media sources and never-activated elements can overstate actual requests. Markup counts are neither a reliable lower bound nor a complete request inventory.

A defensible inventory records the final URL, time, status, response type and complete HTML. A browser network panel adds requests and initiators for defined page states, such as before and after consent or interaction. An error or blocking page is not an uneventful homepage.

Limits of the linked checker

The Third-Party Origin and Subresource Integrity Checker reports clues from HTML. The implementation checked on 25 October 2026 does not download subresources for hash verification and treats any nonempty integrity value as present.

Further limits matter: domain grouping uses a short exception list instead of the full Public Suffix List. Pattern matching does not reliably handle srcset or the effect of base, can count tags inside comments and counts duplicate references separately. A foreign iframe can even appear alongside a misleading finding about the absence of foreign active resources. Individual findings need verification; a green overall result is not security approval.

Questions and answers

Does CSP replace a hash?

A Content Security Policy (CSP) can use sources, nonces and hashes; a host allowlist is only one approach. Nonces authorize selected inclusions without verifying unchanged file content. With strict-dynamic, trust can extend to subsequently loaded scripts. SRI and CSP serve complementary purposes.

Does HTTPS mean trustworthy content?

HTTPS protects transport, not against harmful content on the delivery server. Browsers can block HTTP resources within HTTPS pages or upgrade requests according to resource type. Finding no mixed content in HTML does not establish complete protection.

Are protocol-relative addresses already insecure?

//cdn.example.net/file.js inherits the base URL’s scheme in a browser. On an HTTPS page this is not automatically mixed content. Explicit HTTPS addresses simplify inspection; the linked checker nevertheless assumes HTTPS for this notation even with an HTTP base.

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA and formconfirmed to protect against spam.

Write a comment

Edge cases the article misses and questions about the code are welcome here.

The email address is not published. Required fields are marked with an asterisk.

LUKASWOJCIK.COM · NEWSLETTER

Fresh ideas in your inbox

New articles, practical tools and updates from the projects.

Choose topics (optional)
No selection: all topics.

Subscription starts after confirmation by email. · Privacy

Privacy · Newsletter

Email address, language, selected topics and subscription/confirmation dates are stored to deliver the newsletter. Double opt-in is required. Every issue includes an immediate unsubscribe link. Formconfirmed checks the signup for spam. No email open or click tracking.

Read the full privacy policy ↗