Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› JavaScript Integrity Checking
Cyber Security

JavaScript Integrity Checking

← Back to Glossary
By NHI Mgmt Group Updated October 29, 2026 Domain: Cyber Security

JavaScript integrity checking is a control that verifies a script has not been altered before it runs in a browser or web application. It usually relies on a cryptographic hash or signature, so the browser can block modified code and reduce the risk of tampered scripts executing on the page.

What JavaScript Integrity Checking Does

JavaScript integrity checking helps a browser or web application verify that a script is unchanged before execution. The control is aimed at preserving code authenticity at the point of delivery, so altered JavaScript can be blocked rather than trusted implicitly.

At a practical level, this matters because browser-delivered scripts often sit on the critical path for rendering, authentication flows, payment logic, analytics, and other high-value interactions. If an attacker can modify the script in transit, through a compromised dependency, or on the hosting path, the browser may execute code that the site owner never intended to run.

How Integrity Verification Works

Integrity checking usually depends on a cryptographic hash or a signature that is compared against the expected value before execution. In web delivery, the essential idea is simple: the client verifies the script against a known-good reference, and only matching content is allowed to run.

This protects the integrity of the code artifact, not the broader website by itself. A page can still be vulnerable in other ways, but integrity verification reduces the chance that a tampered script becomes the attacker’s execution vehicle inside the browser.

In practice, the control is strongest when the reference value is protected by the same trust boundary that delivers the page and when the script source is stable enough that the expected digest does not change unexpectedly. If the reference can be rewritten by the same attacker who can alter the script, the protection weakens quickly.

Why It Matters for Web Security

JavaScript is unusually sensitive because it frequently handles trusted client-side behaviour and has direct access to the user session, DOM, tokens in memory, and browser-mediated actions. If malicious code replaces a legitimate script, the attacker may gain a front-row position inside normal user interactions without needing to defeat the server first.

Integrity checking is therefore a supply-chain and delivery control as much as a browser control. It is useful against compromised third-party libraries, malicious CDN replacement, unsafe deployment changes, and other tampering scenarios where the script itself becomes the attack surface.

It also supports defence in depth. Even when server-side controls are strong, the browser still needs a way to reject altered code that reaches the page, especially when multiple teams, vendors, or build steps influence what is shipped.

Operational Limits and Assumptions

Integrity checking only works when the protected script is actually the one the browser receives and the expected value is correct. It does not stop every form of web attack, and it cannot compensate for unsafe logic already present in the approved script.

The control is also sensitive to deployment discipline. Legitimate script updates must be coordinated with the integrity metadata, and teams need a reliable way to manage changes without breaking users or creating pressure to disable the protection during releases.

For that reason, JavaScript integrity checking should be treated as part of a broader content trust model that includes secure build pipelines, trustworthy hosting, and review of third-party script dependencies. SLSA is relevant here because it frames the upstream provenance and integrity of software artefacts before they reach the browser.

Risk and Threat Considerations

When JavaScript integrity checks are absent, bypassed, or poorly maintained, tampered scripts can become a high-impact browser compromise path. That is especially dangerous when a page loads third-party code, because the attack can ride on a legitimate integration point rather than an obvious intrusion.

Failure mechanism: An attacker alters the script in transit, at the hosting layer, or through a compromised dependency, and the browser has no trustworthy integrity check to reject the modified code before execution.

Impact: The modified script can steal session data, alter page content, redirect users, inject fraud, or pivot into broader account compromise and supply-chain exposure.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

SLSA, NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
SLSASupply-chain Levels for Software ArtifactsJavaScript integrity checking protects delivered code artefacts from tampering.
Recommendation — Verify script provenance and integrity before deployment and delivery.
NIST SP 800-53 Rev 5SI-7 — Software, Firmware, and Information IntegrityIntegrity verification of executable content directly fits software integrity controls.
Recommendation — Apply SI-7 to detect and block altered scripts before execution.
OWASP ASVSV13 — ConfigurationScript integrity depends on secure web delivery and trustworthy application configuration.
Recommendation — Configure web delivery so integrity metadata and script references cannot be silently altered.
CIS Controls v8CIS-16 — Application Software SecurityThe control supports secure handling of web application code and dependencies.
Recommendation — Enforce application integrity checks across build and deployment pipelines.

Practitioner Guidance

Why practitioners should care: Treat integrity checking as a release and trust-boundary control, not a cosmetic browser feature. It is most valuable where client-side scripts are business-critical, externally hosted, or updated through multiple teams and pipelines.

Common misunderstanding: Integrity metadata is not a substitute for secure development or dependency control. A script that passes integrity verification can still be harmful if the approved artifact itself is malicious or if the expected hash is managed insecurely.

Use OpenSSF as a broader reference point for supply-chain security thinking, and align script integrity with the same discipline you apply to build provenance, dependency review, and release approval.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 29, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org