← Back to Blog

US$ 2.7 million through a third-party script: what to ask about CSP and SRI

The Polymarket case shows that having a CSP does not mean being protected against third-party JavaScript. A guide: what failed, which controls work, which architecture and process decisions to make, and which metrics to track.

G
Gila Security
November 3, 2026
US$ 2.7 million through a third-party script: what to ask about CSP and SRI

On October 29, 2026, Polymarket had 726 wallets drained, for a total of about US$ 2.7 million. Counting traders affected by the trading pause, the announced reimbursement reaches about US$ 3.9 million. According to Hudson Rock’s analysis, nobody had a password, seed phrase or private key stolen. According to DebugBear itself, attackers compromised its DNS through the domain registrar, and the address of a performance monitoring script that Polymarket loaded began serving malicious code.

This article is a conversation between security and engineering. For the people who own risk and the people who own architecture and delivery, the Polymarket case raises the same question: what does our page load from third parties, and who checks what reaches the customer’s browser? Below: what the incident shows, why the CSP most companies already have does not cover this scenario, and how to reduce the risk without getting in the way of the team’s day-to-day work.

Executive summary

  • What happened: a vendor’s DNS was compromised by attackers at the domain registrar, and the address of the script, which was authorized on the page, started serving a tampered file. The code operated with the user’s own authenticated session.
  • Why common controls fail: a domain-list-based CSP (Content Security Policy) trusts the script’s address, not its content. Contracts, security questionnaires and the vendor’s own penetration tests also do not see the file being swapped at runtime.
  • What works: reduce the number of third-party scripts on critical screens, self-host what is essential and, for what stays external, pin the version and verify the content with SRI (Subresource Integrity), combined with a restrictive CSP.
  • What a header alone does not solve: if a malicious script does run, it acts as the user. Prevention has to happen before execution, and detection has to be continuous.
  • Decision requested: an owner for the topic, an inventory of third-party scripts on authenticated and payment screens, an approval flow in engineering for any new script, and tracking metrics.

How this article was made. The incident facts come from Hudson Rock’s analysis, The Hacker News (Nov 1), NBC News coverage and statements from Polymarket and DebugBear. The incident is recent: figures vary between sources (US$ 2.5M to US$ 2.7M) and may be updated. This article does not attribute responsibility to DebugBear, which, according to the company itself, was a victim of the DNS compromise. Sources are listed at the end.

What CSP and SRI are

A modern web page is not a single file. When you open a screen from your bank or your e-commerce site, the browser downloads and runs code from many places: your own server and vendors for analytics, chat, monitoring, advertising and A/B testing. Any of that code, once it runs, has the same powers as the page, including access to the logged-in user’s session.

CSP (Content Security Policy) is a security policy your server sends to the browser, in an HTTP header, stating where the page may load and run code from (and where it may send data). Anything not on the list, the browser blocks. It was designed mainly to contain code injection attacks such as XSS: if an attacker manages to insert <script src="https://attacker-site.com/x.js"> into the page, the CSP refuses it, because that domain was not authorized.

An analogy: CSP is the guest list at the door. It checks the name of whoever arrives, but does not look inside their bag.

SRI (Subresource Integrity) covers exactly that. You record on the page a “fingerprint” (hash) of the file you reviewed. Before running it, the browser computes the fingerprint of what it downloaded and compares. If the file was swapped, it does not run. It is the seal on the package: it does not matter who delivered it, what matters is whether the content is what was approved.

In short: CSP controls the origin, SRI controls the content. The Polymarket incident happened in the gap between the two.

The incident in four steps

  1. Polymarket loaded a third-party performance monitoring script (cdn.debugbear.com) on its trading pages.
  2. On Oct 29, DebugBear’s DNS records were compromised by attackers through its account at the domain registrar (DebugBear’s account of events). As a result, the same address began serving a malicious file instead of the original script.
  3. The logged-in user’s browser ran the file as if it were legitimate.
  4. According to Hudson Rock, the code has no routine that sends out a password, seed phrase or private key. It finds the already-authenticated trading client on the page and asks the session’s own signer to sign the operations. Funds moved over about 52 minutes, until Polymarket paused trading and removed the script.

The account authorized its own theft. As far as the analyses show, no cryptography or authentication was broken.

Why this is a governance problem, not a header problem

Three points that often escape the technical conversation:

1. Your vendor’s vendor is part of your attack surface. DebugBear was also a victim: according to it, the entry point was its account at the domain registrar, outside Polymarket’s application and DebugBear’s own code. Few companies ask a script vendor how it protects its own domain registration.

2. Third-party risk management often stops at the contract. Questionnaires and certifications assess the vendor at a point in time. The script, however, is downloaded and run on every visit, in your customer’s browser, with the authority of their session. That risk materializes at runtime and rarely shows up in the third-party inventory.

3. “We have a CSP” does not answer the right question. Hudson Rock itself notes that Polymarket’s CSP allowed the DebugBear host, and that trusting a CDN does not verify the bytes it delivers. A policy that authorizes the vendor’s domain keeps authorizing it after it is hijacked.

CSP and SRI: what each one does

ControlQuestion it answersWhat it does not cover
CSPWhere can a script come from? Blocks injection from unauthorized origins.Tampered content delivered by an authorized origin.
SRIIs the file exactly what was reviewed? The browser compares the hash and refuses a swapped file.Scripts without a pinned version, scripts that load other scripts, and inline code.
TogetherOnly runs what comes from an authorized origin and has the expected content.Malicious code that was already in the file when the hash was computed.

According to Aviatrix’s analysis, the script was loaded without SRI, and analysts point out that a pinned hash would have prevented the swapped file from running. Polymarket says it is redeploying the vendor script with additional integrity controls and monitoring.

The limits worth knowing

  • SRI requires a pinned version. Many vendors update the script on their server, at the same URL, without notice. With SRI, a legitimate update breaks functionality. This forces an update process, and it is a real operational cost.
  • SRI does not cover what the script loads afterward. If the approved file injects others, those fall outside the hash.
  • None of this helps if the malicious code has already run. Once active, calls to your site’s legitimate APIs use the user’s cookies. That is why the control is preventive, and change detection must exist as a second line.

Prioritizing actions: impact against effort

ActionEffect on riskEffortNote
Remove third-party scripts from critical screens (login, payment, transfer, profile changes)High: eliminates the vectorLowSession replay, A/B testing, chatbots and monitoring rarely justify themselves where value moves.
Self-host what is essential, with a pinned version and reviewHigh: removes the dependency on the vendor’s DNS and infrastructureMediumRequires an update process.
Pin version + SRI on what stays externalHigh against file swappingMediumDoes not work for scripts that change without notice.
Restrictive CSP (no 'unsafe-inline', no wildcards, with nonce or hash)Medium to high: reduces injection and limits where data can goMedium to highDeploy in report-only mode first.
Isolate widgets that do not accept SRI in a sandboxed, cross-origin iframeMediumMediumThe widget no longer operates inside the session.
Monitor changes and violations (CSP reports, periodic comparison with the approved set)Medium: detects what prevention let throughMediumAlso addresses PCI DSS 11.6.1.
Clauses and verification of the registrar for critical vendorsMediumLowTransfer lock, MFA and DNSSEC on the domain that delivers the script.

Adopting CSP and SRI without breaking the page or slowing the team

The risk is a security risk, but the levers are in engineering. Five architecture and process decisions:

  1. Treat a third-party script as a code dependency. Declare each script (origin, version, hash, owner and justification) in a versioned file in the repository, and require a pull request with security approval to add or update one. The script that reaches production outside that flow is exactly what CSP and SRI do not see.
  2. Close the tag manager shortcut. These tools let marketing and product publish code without going through a release. On critical screens, either do not use one, or restrict who can publish, what can be published, and require review. A CSP that authorizes the tag manager inherits the risk of everything it loads.
  3. Self-host and version what is essential. Copying the file to your CDN, with a pinned version and hash, removes the dependency on the vendor’s DNS and usually reduces external connections. The cost is the update process: automate detection of new versions and review of what changed.
  4. Choose the CSP trust model deliberately. A nonce- or hash-based policy is stronger than a domain list. The 'strict-dynamic' directive simplifies adoption, but makes the browser trust scripts loaded by an already-approved script, which leaves what it loads afterward unverified. Decide this explicitly, not by the framework’s default.
  5. Verify continuously, not only at deploy. An automated test that opens the critical screens in a headless browser and compares the domains and hashes of the scripts loaded against the approved list detects changes that happen after deploy, such as a remote file being swapped. Add CSP violation reports (report-to) to that.

Put the cost on the table. This model requires ongoing engineering effort and friction with teams that depend on third-party tools. Two decisions need to be made jointly by security and engineering: who holds a veto over a new script on a critical screen, and how quickly a script that has lost its justification is removed.

Step-by-step roadmap: from report-only CSP to enforcement

A restrictive CSP applied all at once, without preparation, tends to block legitimate scripts, styles, fonts and connections, and the page breaks. The path below therefore goes from the safest step to the strictest. Each step starts only when the previous one is stable, and the pace is your team’s.

1. See what exists. Inventory the third-party scripts on authenticated and payment screens, with a business owner, a justification, and a note on which have a pinned version and SRI. A survey like this often reveals scripts nobody remembers authorizing.

2. Decide the fate of each script. For each item, choose between removing it, self-hosting it, or keeping it external with a pinned version and SRI. Start with the ones that have no justification: removal has the biggest effect and the lowest risk to the page.

3. Publish the CSP in report-only mode. Use the Content-Security-Policy-Report-Only header with an initial policy that mirrors what the page loads today. In this mode nothing is blocked: the browser only reports what the policy would refuse. Start in staging and on a low-risk screen.

4. Read the reports and adjust. Collect violations (report-to) and separate legitimate use from noise, such as browser extensions. Review the directives most often forgotten: connect-src, frame-src, font-src, img-src, style-src and workers. Test full flows (login, payment, transfer) in more than one browser.

5. Pin versions and apply SRI to the scripts that stay external. Before turning SRI on, confirm with the vendor that the URL is versioned. If the file changes at the same URL without notice, SRI will break the feature, and the best option then is to host your own copy or isolate the widget.

6. Tighten the policy gradually. Remove wildcards and 'unsafe-inline', and replace the domain list with a nonce or hash. Make one change at a time and keep each one in report-only mode until new violations stop appearing.

7. Enable enforcement screen by screen. Move from Report-Only to Content-Security-Policy on a lower-traffic screen, with a rollback plan ready (the header must be able to go back to report-only in minutes). Then extend to critical screens, one at a time. Keep the next, stricter policy running in report-only mode alongside.

8. Put the check in the delivery process. Add to the pipeline the test that compares loaded scripts against the approved list, and turn on alerts for new domains and hashes.

9. Track and review. Follow the indicators in the next section, and review the approved list whenever a script is added, updated or removed.

How to know it is working

  1. Number of third-party scripts loaded on authenticated and payment screens, and its trend.
  2. Percentage of those scripts that are self-hosted or have a pinned version and SRI.
  3. Time between a change in a third-party script and the corresponding alert.
  4. Percentage of critical vendors that demonstrate controls over the registrar and DNS of the domain that delivers the code.
  5. CSP violations in production per month, and the share handled.

This is also an online banking risk

Replace “trader” with “account holder”. The architecture of a bank’s logged-in area is the same: an authenticated page loading dozens of third-party scripts (analytics, session replay, chatbot, monitoring, A/B testing) next to a session that schedules transfers, registers payment keys and approves devices. A script swapped at one of those vendors does not need the customer’s password: it operates as them, calling the bank’s own APIs with their cookies.

This also shows up in compliance requirements. PCI DSS 4.0 requires, for card payment pages, that every script be authorized, justified, integrity-assured and kept in an inventory (requirement 6.4.3), and that a mechanism detect unauthorized changes to HTTP headers and page content (requirement 11.6.1, evaluated at least weekly). Both have been mandatory since March 31, 2025. In Brazil’s financial sector, the cybersecurity policy under CMN Resolution 4,893 (amended by CMN Resolution 5,274/2025) extends to service providers, and it is worth asking whether your third-party inventory includes whoever delivers JavaScript to your customer’s browser.

Questions to start with

  1. How many third-party scripts load on our authenticated and payment screens? Who approved each one?
  2. If one of those domains were compromised today, how quickly would we know?
  3. Do our critical vendors protect the registrar and DNS of the domain that delivers the code?
  4. How many of those scripts have a pinned version and SRI, or are hosted by us?
  5. Does our CSP restrict by content (nonce, hash, SRI) or only by domain?
  6. Is there a review flow that prevents a new script, or an updated file, from reaching production without approval, including through the tag manager?

If the answer to most is “I don’t know”, the first step is the inventory. The difference between a header that costs US$ 0 and one that prevents US$ 2.7 million is a few lines of configuration, but only those who know what they load can write them.

Technical appendix for your team

Quick inventory. In the browser console, on the page that matters:

[...document.scripts]
  .filter(s => s.src && new URL(s.src).origin !== location.origin)
  .map(s => ({ src: s.src, integrity: s.integrity || null }));

Every row with integrity: null is a third-party script running without content verification. Also check the Network tab for scripts loaded by other scripts.

Script with a pinned version and SRI. The hash below is illustrative:

<script
  src="https://cdn.vendor.com/monitor-1.8.2.js"
  integrity="sha384-ILLUSTRATIVE-HASH-OF-THE-REVIEWED-FILE"
  crossorigin="anonymous"></script>

To generate the hash of a reviewed file, prefix the result with sha384-:

curl -sS https://cdn.vendor.com/monitor-1.8.2.js \
  | openssl dgst -sha384 -binary | openssl base64 -A

Automate the check in CI: a change in the remote file should break the build, not production.

Starting CSP (adapt to your environment and deploy first in Content-Security-Policy-Report-Only):

Content-Security-Policy:
  default-src 'self';
  script-src 'self' 'nonce-{random-per-request}';
  connect-src 'self' https://api.yourdomain.com;
  object-src 'none';
  base-uri 'none';
  frame-ancestors 'none';
  report-to csp-endpoint

Avoid 'unsafe-inline', 'unsafe-eval' and wildcards (https:, *.cdn.com) in script-src. Restrict connect-src to limit where exfiltrated data can go.


Want to know which third-party scripts run on your critical screens? The Gila Security team can map your third-party surface, review your CSP and test whether it actually blocks what it should. Get in touch.

References

The incident

Standards and technical documentation

Compliance