<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Or Cohen</title>
    <description>The latest articles on DEV Community by Or Cohen (@ordesign).</description>
    <link>https://dev.to/ordesign</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4274877%2Fe0a1b314-0a73-4ffc-bcd5-0e5b44fee950.png</url>
      <title>DEV Community: Or Cohen</title>
      <link>https://dev.to/ordesign</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ordesign"/>
    <language>en</language>
    <item>
      <title>Packing 79,463 CNAME-Cloaked sGTM Domains Into a &lt;5ms Cloudflare Worker Blocklist Checker</title>
      <dc:creator>Or Cohen</dc:creator>
      <pubDate>Mon, 30 Nov 2026 18:08:40 +0000</pubDate>
      <link>https://dev.to/ordesign/packing-79463-cname-cloaked-sgtm-domains-into-a-5ms-cloudflare-worker-blocklist-checker-3p6m</link>
      <guid>https://dev.to/ordesign/packing-79463-cname-cloaked-sgtm-domains-into-a-5ms-cloudflare-worker-blocklist-checker-3p6m</guid>
      <description>&lt;p&gt;While auditing 2,328 live European websites from Frankfurt on Google Consent Mode v2 (&lt;code&gt;gcs&lt;/code&gt;/&lt;code&gt;gcd&lt;/code&gt; transitions across Cold Load -&amp;gt; Reject All -&amp;gt; Accept All), one recurring pattern stood out:&lt;/p&gt;

&lt;p&gt;Sites paying for &lt;strong&gt;server-side Google Tag Manager (sGTM)&lt;/strong&gt; — often hosted on Stape or Cloud Run behind a custom subdomain like &lt;code&gt;sgtm.example.com&lt;/code&gt; or &lt;code&gt;metrics.example.com&lt;/code&gt; — were still losing tracking hits because &lt;strong&gt;their custom subdomain had already landed on public CNAME-cloaking and DNS ad-blocker lists&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I wanted to build an instant, zero-login checker that runs entirely at the edge on &lt;strong&gt;Cloudflare Workers&lt;/strong&gt; with &lt;code&gt;&amp;lt; 5ms&lt;/code&gt; cold start and lookup latency, zero external DNS queries, and zero database round-trips.&lt;/p&gt;

&lt;p&gt;Here is how we packed &lt;strong&gt;79,463 domains&lt;/strong&gt; across 5 major filter lists into a compact Worker bundle.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The 5 Blocklists We Indexed
&lt;/h2&gt;

&lt;p&gt;Ad-blocker and DNS filter maintainers actively sweep CNAME-cloaked first-party tracking proxies. Merging and deduplicating the 5 most widely deployed lists (used by AdGuard, Brave, NextDNS, Pi-hole, and uBlock Origin) yields &lt;strong&gt;79,463 unique indexed domains&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Blocklist Source&lt;/th&gt;
&lt;th&gt;Raw Entries&lt;/th&gt;
&lt;th&gt;Indexed sGTM / Proxy Domains&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AdGuard CNAME-Cloaked Trackers (&lt;code&gt;stape_justdomains&lt;/code&gt;)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;69,332&lt;/td&gt;
&lt;td&gt;49,569&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HaGeZi Multi Normal DNS Blocklist&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;179,620&lt;/td&gt;
&lt;td&gt;23,077&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AdGuard DNS Filter (&lt;code&gt;AdguardSDNSFilter&lt;/code&gt;)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;195,395&lt;/td&gt;
&lt;td&gt;21,827&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;EasyPrivacy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;47,855&lt;/td&gt;
&lt;td&gt;4,409&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1Hosts (Lite)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;202,954&lt;/td&gt;
&lt;td&gt;1,335&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(A single domain can appear in multiple lists — e.g. both &lt;code&gt;adguard_cname&lt;/code&gt; and &lt;code&gt;hagezi_multi&lt;/code&gt;.)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Why a Naive JSON Object Blows Up Cloudflare Worker Cold Starts
&lt;/h2&gt;

&lt;p&gt;Dropping a raw JSON map of &lt;code&gt;79,463&lt;/code&gt; domain strings -&amp;gt; list arrays into a Cloudflare Worker causes two immediate problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Bundle size &amp;amp; memory:&lt;/strong&gt; Plain JSON with list names repeated 79k times quickly balloons past multi-megabyte Worker size limits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cold-start CPU:&lt;/strong&gt; Parsing a massive JSON object or building a &lt;code&gt;new Set(...)&lt;/code&gt; on every isolate boot burns tens of milliseconds of startup CPU before the first request is even served.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Our Fix: Bitmask Buckets + Front-Coded Blocks + Lazy Binary Search
&lt;/h3&gt;

&lt;p&gt;Instead of storing an array of list names per domain, we assign each of the 5 lists a single bit (&lt;code&gt;1 &amp;lt;&amp;lt; 0&lt;/code&gt; through &lt;code&gt;1 &amp;lt;&amp;lt; 4&lt;/code&gt;), group domains by their 5-bit mask (&lt;code&gt;1..31&lt;/code&gt;), sort each bucket lexicographically, and &lt;strong&gt;front-code&lt;/strong&gt; adjacent entries in fixed-size blocks separated by blank lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;analytics.chimar.com
Lityskydive.nl        # shares 11-char prefix ("analytics.c") + "ityskydive.nl"
Mur.cz                # shares 12-char prefix ("analytics.ci") + "ur.cz"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because every block starts with one unencoded header domain, the Worker &lt;strong&gt;never decompresses the whole index at startup&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;At request time, it binary-searches only the block headers inside each bitmask bucket (zero heap allocations for untouched blocks).&lt;/li&gt;
&lt;li&gt;Only the single candidate block that could contain the target domain is decoded sequentially.&lt;/li&gt;
&lt;li&gt;For any queried hostname like &lt;code&gt;collect.sgtm.brand.de&lt;/code&gt;, we walk parent suffixes (&lt;code&gt;collect.sgtm.brand.de&lt;/code&gt; -&amp;gt; &lt;code&gt;sgtm.brand.de&lt;/code&gt; -&amp;gt; &lt;code&gt;brand.de&lt;/code&gt;) so wildcard/parent rules match immediately:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;matchedRule&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;matchedMask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lookupDomainBitmask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;matchedRule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;matchedMask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: &lt;strong&gt;&amp;lt; 5ms cold start and lookup latency&lt;/strong&gt; inside a standard Cloudflare Worker, with zero external API calls.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Catching "Not Listed Yet" Subdomains With Giveaway-Prefix Heuristics
&lt;/h2&gt;

&lt;p&gt;Even if a brand-new &lt;code&gt;sgtm.example.com&lt;/code&gt; subdomain hasn't been scraped into &lt;code&gt;adguard_cname&lt;/code&gt; yet, filter-list maintainers regularly sweep obvious tracking prefixes. Alongside exact blocklist matching, we check subdomain labels against high-risk giveaway prefixes (&lt;code&gt;sgtm&lt;/code&gt;, &lt;code&gt;ssgtm&lt;/code&gt;, &lt;code&gt;sst&lt;/code&gt;, &lt;code&gt;gtm&lt;/code&gt;, &lt;code&gt;tagging&lt;/code&gt;, &lt;code&gt;metrics&lt;/code&gt;, &lt;code&gt;analytics&lt;/code&gt;, &lt;code&gt;telemetry&lt;/code&gt;, &lt;code&gt;tracking&lt;/code&gt;, &lt;code&gt;collect&lt;/code&gt;, &lt;code&gt;pixel&lt;/code&gt;, &lt;code&gt;stats&lt;/code&gt;) and surface a &lt;code&gt;HIGH / MEDIUM / LOW&lt;/code&gt; heuristic risk rating.&lt;/p&gt;

&lt;p&gt;If you're deploying server-side GTM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefer &lt;strong&gt;A/AAAA records or Same-Origin routing&lt;/strong&gt; over CNAMEs whenever your DNS host supports it.&lt;/li&gt;
&lt;li&gt;Pick a &lt;strong&gt;neutral subdomain&lt;/strong&gt; instead of &lt;code&gt;sgtm.*&lt;/code&gt; or &lt;code&gt;metrics.*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Pair Custom Loader with request-path encoding so &lt;code&gt;/g/collect&lt;/code&gt; isn't trivially pattern-matched.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It Live (Free, No Login)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;sGTM Subdomain Blocklist Checker:&lt;/strong&gt; &lt;a href="https://consentpulse.dev/tools/sgtm-blocklist-checker" rel="noopener noreferrer"&gt;https://consentpulse.dev/tools/sgtm-blocklist-checker&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Consent Mode v2 6-Bit Base64 &lt;code&gt;gcd&lt;/code&gt; Decoder:&lt;/strong&gt; &lt;a href="https://consentpulse.dev/tools/gcd-decoder" rel="noopener noreferrer"&gt;https://consentpulse.dev/tools/gcd-decoder&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full 2,328-Site EU Consent Mode v2 Benchmark Study:&lt;/strong&gt; &lt;a href="https://consentpulse.dev/benchmarks/consent-mode-v2-study" rel="noopener noreferrer"&gt;https://consentpulse.dev/benchmarks/consent-mode-v2-study&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've run into interesting edge cases with CNAME-cloaking detection or Cloudflare Worker static-index packing, I'd love to hear how you approached it in the comments!&lt;/p&gt;

</description>
      <category>cloudflare</category>
      <category>webdev</category>
      <category>analytics</category>
      <category>privacy</category>
    </item>
  </channel>
</rss>
