Skip to content
FIRERUN.

The BaaS & deploy-platform newsroom for builders

Subscribe

Firebase

Firebase Web SDK Fixes Trusted Types, but Strict CSPs Need One Name

Add firebase-js-sdk-policy to a strict trusted-types CSP before upgrading, or Firebase Auth, App Check and Analytics scripts stop loading.

Hand-drawn editorial illustration for "Firebase Web SDK Fixes Trusted Types, but Strict CSPs Need One Name"

Firebase Auth and App Check now load their scripts on web pages that enforce Trusted Types, but only if the page’s Content Security Policy allows one policy name. The Firebase JavaScript SDK 13.4.0, released Nov. 16, routes every external script it loads through a single Trusted Types policy called firebase-js-sdk-policy (firebase-js-sdk 13.4.0 release notes, Nov. 16, 2026). A site whose CSP names its allowed policies has to add that one, or the Google sign-in, reCAPTCHA and gtag scripts fail to load.

Key Takeaways

  • Auth (gapi and reCAPTCHA), App Check (reCAPTCHA) and Analytics (gtag) now share one Trusted Types policy, firebase-js-sdk-policy.
  • Pages with require-trusted-types-for 'script' can now run Auth and App Check, which the pull request behind the change says failed before.
  • A CSP with a trusted-types directive must list firebase-js-sdk-policy. If it doesn’t, the SDK logs an error naming the policy when a script fails to load.
  • Sites that already allowed the name for Analytics need no CSP change.

What Changed

Trusted Types is a browser defense against DOM-based cross-site scripting. With require-trusted-types-for 'script' in a CSP, the browser refuses to set a script’s src from a plain string. Code has to pass a value created by a named policy, and the trusted-types directive can limit which policy names are allowed.

Before this release, only Analytics followed that rule. According to the pull request behind the change, #10609, Auth set script sources with setAttribute('src', url) and App Check assigned script.src as a plain string, so both broke on pages that enforce Trusted Types. Analytics already used a policy with the same firebase-js-sdk-policy name, but created it on every gtag insertion and threw if the CSP didn’t allow it.

The fix moves the work into @firebase/app. A new internal helper creates the policy once and accepts only known Firebase script URLs: gtag, gapi and reCAPTCHA’s api.js and enterprise.js. Auth 1.13.11, App Check 0.13.2 and Analytics 0.10.26 now load scripts through it. The pull request was opened by SDK maintainer hsubox76 on Nov. 11 and merged Nov. 13.

It supersedes an outside fix that sat for nearly a year. A contributor opened pull request #9402 on Dec. 1, 2025 to fix a “trusted types violation” in Auth’s script loader using Google’s safevalues library. It is still open. The new pull request said it skipped safevalues, citing its runtime URL checks, collisions between duplicate copies and a development build that breaks in web workers.

The same release changed the Crashlytics web SDK, which Firebase announced in public preview on its blog Nov. 19. Crashlytics 0.2.0 moved to OpenTelemetry 3.x and now types customAttributes, log() and recordError() with OpenTelemetry’s Attributes, so code that passed other attribute types may need edits.

The Take

Until this release, a team that enforced Trusted Types had to give up Firebase sign-in or write its own policy to let Firebase’s script URLs through. The SDK now does that job itself, and only for URLs it knows.

The catch is the allowlist. A CSP that lists its allowed policies but not this one will block Auth and App Check scripts as soon as firebase is bumped to 13.4.0. Before upgrading, add firebase-js-sdk-policy to the trusted-types directive. Then test sign-in and App Check on a staging page with the browser console open. A missing name shows up there as an error that names the policy.

Sites without a trusted-types directive have nothing to change.

Stay in the loop

Get new articles in your inbox

We'll only email you when a new article drops. Unsubscribe anytime.