Third-Party Scripts Without Subresource Integrity

Scripts or stylesheets are loaded from third-party servers without an integrity hash, so a malicious change to those files would run in the application's pages unchecked.

SeverityLow
CVSS 3.13.1 CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:N Open in the calculator
CVSS 4.02 CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-494: Download of Code Without Integrity Check
OWASP Top 10A08:2025 Software or Data Integrity Failures
MITRE ATT&CKT1195.002 Compromise Software Supply Chain, T1189 Drive-by Compromise
CategorySecurity Misconfiguration

Description

The application's pages load scripts or stylesheets from servers outside the organisation's control, such as public content delivery networks or a supplier's servers, without the integrity attribute. Subresource Integrity (SRI) lets a page state the cryptographic hash of the file it expects, and the browser refuses to use a file whose content does not match. Without it, the page runs whatever the third-party server delivers.

The weakness only matters if the third-party file is changed maliciously, for example because the provider or its account is compromised, the domain serving it changes hands, or a storage bucket hosting it can be written by others. The attacker's code then runs in the application's pages with the same access as the application's own script: it can read what users see and type, including credentials and payment details, act as logged-in users and change what the pages show. Exploitation depends on first compromising the third party, which is outside the attacker's direct reach and outside the organisation's control, but such incidents have affected widely used script providers, and one success reaches every user of every site that loads the file. The impact is greatest on pages that handle logins, payments or personal data.

SRI suits files fixed at a specific version. It cannot be used for resources that the provider changes deliberately, such as analytics or advertising tags or addresses that always serve the latest release, and a cross-origin resource loaded with it must be requested with the crossorigin attribute and served with suitable CORS headers. The issue is identified by reviewing the script and link elements that reference other origins.

Remediation

Remove the application's dependence on the integrity of third-party servers:

  • Add an integrity attribute holding a SHA-384 or SHA-512 hash of the exact file, together with crossorigin="anonymous", to every script and stylesheet link element that loads a fixed version of a file from another origin.
  • Reference specific versions rather than addresses that always serve the latest release, and update the hash deliberately when upgrading.
  • Prefer to serve copies of third-party libraries from the application's own servers, bundled through the build process, where they are covered by the same controls as the rest of the code.
  • For scripts that cannot use SRI, such as supplier tags, review whether they are needed on sensitive pages, and use a Content Security Policy to limit which origins may supply script.
<script src="https://cdn.example.net/library/1.2.3/library.min.js" integrity="sha384-..." crossorigin="anonymous"></script> Generating the hash of a file: openssl dgst -sha384 -binary library.min.js | openssl base64 -A

Confirm the fix by checking that third-party script and link elements carry integrity attributes and that the pages load without integrity errors in the browser's console.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Web Applications Findings

Every Web Applications finding