Skip to content

security/csp: report whether the policy would contain a hijacked third-party script (connect-src, 'strict-dynamic', 'unsafe-eval', reporting) #2087

Description

@nc9

Problem

On 16 November 2026 attackers wrote a loader into the Project JavaScript of many Optimizely customer projects (Report URI write-up). The malicious code arrived from cdn.optimizely.com, a host those sites already allowed.

Report URI evaluated the affected organisations' policies against what the payload needed: 68 had no CSP, 50 had one that allowed the payload and the data theft, 17 ran the payload but blocked the data theft through connect-src, and 24 blocked the payload. Per that analysis:

  • a connect-src limited to the hosts the site needs stopped the stolen data leaving;
  • 'strict-dynamic' let the payload through, because a script inserted by a trusted script is trusted too;
  • 'unsafe-eval' let an inline copy of the payload run;
  • allowing the vendor's host did nothing, because the vendor's host served the code.

security/csp grades the header for a missing or report-only policy, 'unsafe-inline', 'unsafe-eval', wildcards and a first-party proxy path. It does not look at connect-src, says nothing about 'strict-dynamic' on a page that loads third-party scripts, and does not check that violations are reported anywhere. A site can pass it and still have nothing that contains a compromised vendor.

Wanted

For a page that loads third-party scripts, squirrel says plainly whether its CSP would limit a compromised one, and which gap is open. Whether this extends security/csp or becomes its own rule is up to the implementer.

Acceptance Criteria

  • A page that loads at least one third-party script, under a policy with no connect-src and no default-src that restricts connections, gets a finding saying script on the page can send data to any host.
  • A connect-src (or inherited default-src) containing *, https: or another scheme-only source gets the same finding. A list of hosts does not.
  • A page that loads third-party scripts under 'strict-dynamic' gets an informational finding explaining that scripts those vendors insert are trusted too.
  • 'unsafe-eval' on a page with third-party scripts is reported with that context; the existing csp-unsafe-scripts finding is unchanged for pages without them.
  • An enforced policy with neither report-to nor report-uri gets an informational finding that violations are not being collected.
  • A page that loads no third-party script gets none of the new findings.
  • Each new check has a fixture that fires it and one that does not, and the existing security/csp fixtures still pass.
  • The docs describe each new check and its limit (it reads the header and the fetched HTML, it does not execute the page). If a new rule is added, the README and docs category tables list it.

Activity

  1. added
    enhancement
    size: M
    rules
    security
    on Nov 16, 2026
  2. added theissue type on Nov 17, 2026
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

    enhancementrulessecuritysize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions