What happened

Debugging a blocked ad script was a tangled mess of CSP headers, Cloudflare's policies, and ultimately, fraud detection by the ad network itself. The problem stemmed from attempting to embed an ad banner (hosted on a separate domain) within an iframe via a standard <script src> tag.

Initially, this worked, but soon the entire request was being blocked due to violations of the CSP’s strict content security policy. The key issue wasn't a single misconfiguration; it was the inherent conflict between a restrictive CSP and the ad network's defensive measures. The CSP, designed to protect the site from malicious scripts, rigidly enforced its rules—particularly concerning origins and inline execution. Simultaneously, the ad network, constantly battling fraudulent traffic (often disguised as legitimate users), aggressively flagged requests that resembled typical bot or proxy behavior. My testing setup – a VPN exit IP, a region the network barely served, and a headless browser directly hitting the invoke.js script - looked exactly like fraud from four directions at once.

“it's meant to be loaded as an embedded &lt;script src&gt; , so a bare hit with no referer gets refused on principle.”
— Dr Non

The counter-take

Traditional approaches to CSP configuration – relying primarily on allowlists – have proven insufficient when dealing with complex ecosystems like ad networks. A purely restrictive policy is simply too brittle, while a permissive one invites vulnerability. The key lies in understanding the underlying motivations and expectations of each party involved—in this case, the site’s security team and the ad network's fraud prevention system.

The AI angle

This incident highlights a growing asymmetry in the web's security landscape, driven by AI-powered fraud detection. As sophisticated botnets become more common, security vendors are increasingly reliant on automated systems to identify and block suspicious traffic. This creates a feedback loop where legitimate requests are often flagged as fraudulent due to their unusual characteristics.