Skip to content

security/sri: exempt Shopify platform scripts and add an exempt_hosts option #546

Closed

Description

@nc9

Split from #483 (part 2). security/sri reports scripts that the store owner cannot pin, because the platform or vendor updates them in place. SRI_EXEMPT_HOSTNAMES already exempts this class for Stripe, PayPal, GTM, GA and Facebook, but only by hostname, and the rule docs tell users to disable the rule for any other self-updating script.

Reported on a real Shopify store (squirrel 0.0.103), security/sri flagged "7 cross-origin resources without Subresource Integrity", including:

  • https://cdn.shopify.com/shopifycloud/shop-js/modules/v2/loader.init-shop-cart-sync.de.esm.js (injected by Shopify)
  • https://cdn.shopify.com/storefront/standard-actions.js (injected by Shopify)
  • https://cdn.shopify.com/extensions/<uuid>/<app>/assets/<name>-latest.js (theme app extension, path ends in -latest)
  • https://static.klaviyo.com/onsite/js/<id>/klaviyo.js
  • https://plausible.io/js/script.pageview-props.revenue.tagged-events.js
squirrel audit https://www.alpensattel.de/ -m 8 --http --offline --disable-discovery-probes \
  --rule-include security/sri -f json -o out.json -y

Notes from triage:

  • Exempting all of cdn.shopify.com is not safe: it also serves versioned theme and app assets that can carry an integrity hash. Exempt by path prefix instead (/shopifycloud/, /storefront/).
  • A hardcoded vendor list goes stale, so the rule also gets a user option (exempt_hosts) for hosts a site owner knows are self-updating.
  • A generic "unversioned URL means info" rule is deliberately not part of this issue: it would flip existing tests that use unversioned example URLs and changes what the rule means.

Acceptance Criteria

  • Scripts under cdn.shopify.com/shopifycloud/ and cdn.shopify.com/storefront/ are not reported at warning level by security/sri
  • A rule option exempt_hosts lets a site exempt additional hostnames; it is documented and validated
  • A versioned third-party script without integrity on another host is still flagged
  • A theme or app asset on cdn.shopify.com outside the exempt prefixes is still flagged
  • docs/rules/security/sri.mdx lists the path-prefix exemptions and the exempt_hosts option, and no longer says "eleven hostnames" if the count changes
  • Test: extend packages/rules/tests/sri.test.ts with the two Shopify platform URLs above: not reported
  • Test: same file, a cdn.shopify.com theme asset URL with ?v=: still reported
  • Test: same file, a versioned cdn.jsdelivr.net/npm/[email protected]/x.js: still reported
  • Test: same file, a host listed in exempt_hosts: not reported; a host not listed: reported
  • Existing sri.test.ts cases for the current exempt hostnames stay green
  • The PR description states whether the squirrelscan agent skill needs a change (the skill links to the rule pages, which are the reference, so usually none); if it does, a follow-up is filed against squirrelscan/skills

Activity

  1. added
    bug
    P3
    size: S
    rules
    security
    on Oct 7, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    ContributorAuthor

    Reproduced on 0.0.108 with a local fixture page loading the three Shopify URLs from the issue (platform paths and a -latest extension asset), a theme asset with ?v= and a versioned jsDelivr script: security/sri, check sri, warn, 5 cross-origin resource(s) without Subresource Integrity, all five listed.

    origin/main still has this: packages/rules/src/security/sri.ts exempts by hostname only (SRI_EXEMPT_HOSTNAMES, no Shopify entry, no path prefixes) and has no exempt_hosts option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3bugrulessecuritysize: S

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions