Logo

dev-resources.site

for different kinds of informations.

How to Replace Google Safe Browsing with Cloudflare Zero Trust

Published at
7/8/2024
Categories
google
cloudflare
safebrowsing
zerotrust
Author
ccbikai
Author
7 person written this
ccbikai
open
How to Replace Google Safe Browsing with Cloudflare Zero Trust

So, get this, right? I built the first version of L(O*62).ONG using server-side redirects, but Google slapped me with a security warning the very next day. Talk about a buzzkill! I had to scramble and switch to local redirects with a warning message before sending folks on their way. Then came the fun part โ€“ begging Google for forgiveness.

Now, the smart money would've been on using Google Safe Browsing for redirects. But here's the catch: Safe Browsing's got a daily limit โ€“ 10,000 calls, and that's it. Plus, no custom lists. And since I'm all about keeping things simple and sticking with Cloudflare, Safe Browsing was a no-go.

Fast forward to a while back, I was chewing the fat with someone online, and bam! It hit me like a bolt of lightning. Why not use a secure DNS server with built-in filters for adult content and all that shady stuff to check if a domain's on the up-and-up? Figured I'd give Family 1.1.1.1 a shot, and guess what? It actually worked! Problem was, no custom lists there either. Then I remembered messing around with Cloudflare Zero Trust Gateway back in my HomeLab days. Turns out, that was the golden ticket โ€“ a solution so good, it's almost criminal.

Here's the deal: Cloudflare Zero Trust's Gateway comes packing a built-in DNS (DoH) server and lets you set up firewall rules like a boss. You can block stuff based on how risky a domain is, what kind of content it has, and even use your own custom naughty-and-nice lists. And get this โ€“ it pulls data from Cloudflare's own stash, over 30 open intelligence sources, fancy machine learning models, and even feedback from the community. Talk about covering all the bases! Want the nitty-gritty? Hit up the official documentation.

So, I went ahead and blocked all the high-risk categories โ€“ adult stuff, gambling sites, government domains, anything NSFW, newly registered domains, you name it. Plus, I've got my own little blacklists and whitelists that I keep nice and tidy.

Risk List

Once I was done tweaking the settings, I got myself a shiny new DoH address:

DoH

To hook it up to my project, I used this handy-dandy code:

async function isSafeUrl(
  url,
  DoH = "https://family.cloudflare-dns.com/dns-query"
) {
  let safe = false;
  try {
    const { hostname } = new URL(url);
    const res = await fetch(`${DoH}?type=A&name=${hostname}`, {
      headers: {
        accept: "application/dns-json",
      },
      cf: {
        cacheEverything: true,
        cacheTtlByStatus: { "200-299": 86400 },
      },
    });
    const dnsResult = await res.json();
    if (dnsResult && Array.isArray(dnsResult.Answer)) {
      const isBlock = dnsResult.Answer.some(
        answer => answer.data === "0.0.0.0"
      );
      safe = !isBlock;
    }
  } catch (e) {
    console.warn("isSafeUrl fail: ", url, e);
  }
  return safe;
}

Enter fullscreen mode Exit fullscreen mode

And here's the kicker: Cloudflare Zero Trust's management panel has this sweet visualization interface that lets you see what's getting blocked and what's not. You can see for yourself โ€“ it's got the kibosh on some adult sites and those brand-spanking-new domains.

Visualization Interface

Oh, and if a domain ends up on the wrong side of the tracks, you can always check the log to see what went down.

Log

stat

zerotrust Article's
30 articles in total
Favicon
Modernizing Security Operations with Zero Trust Architecture onย AWS
Favicon
Iโ€™m joining Pomerium!
Favicon
Zero Trust in Endpoint Security: Securing the Frontlines of Cyber Defense
Favicon
Embracing Zero Trust Architecture: A Paradigm Shift in Cybersecurity
Favicon
Implementing Network Security: A Guide to Modern Methodologies
Favicon
Supply Chain Risk Management Strategy with Sennovate
Favicon
Enhancing T-Mobile's Security: Embracing Modern Zero-Trust Architecture
Favicon
Firewalls in Zero-Trust Security: Fortifying Modern Cyber Defenses
Favicon
Overcoming the Top Challenges of Adopting Zero Trust Architecture in 2024
Favicon
What does Zero Trust Security mean for you | IUG 2024
Favicon
๐Ÿ”’ Tip and Trick: MongoDB Security, Regulatory Compliance & Zero Trust ๐Ÿ”‘
Favicon
๐Ÿ”’ ๅบ”็”จๆŠ€ๅทง: MongoDBๅฎ‰ๅ…จใ€ๅˆ่ง„ๆ€งไธŽ้›ถไฟกไปป ๐Ÿ”‘
Favicon
How to Replace Google Safe Browsing with Cloudflare Zero Trust
Favicon
Step-by-Step Guide to Publish Internal SaaS Applications via Citrix Secure Private Access
Favicon
Cloudflare's ZeroTrust Part 0: What's my story?
Favicon
ZTA Revolutionizing Cybersecurity with Zero Trust
Favicon
Cloudflare's ZeroTrust Part 1: How can I access to my web/app in private network without NAT
Favicon
AWS Credentials for Serverless
Favicon
How Zero Trust Empowers Secure Remote Teams (A CTO's Perspective)
Favicon
Zero Trust and API Security: Implementing Robust Authentication with Edge Stack
Favicon
Childrenโ€™s Introduction Guide to Zero Trust
Favicon
How Zero-Trust Architecture Design Enables Global Business Processes
Favicon
Passwordless Zero Trust Access to AWS RDS
Favicon
What is Zero Trust Network Access (ZTNA)?
Favicon
Simplifying AWS Access with Border0
Favicon
Cloudflare Warp Team Enrollment Hacking on Ubuntu
Favicon
Demystifying the magic of Zero Trust with my daughter and opensource
Favicon
All your ssh and database servers accessible directly from your Browser
Favicon
The most flexible policy engine in the world
Favicon
what is Zero Trust?

Featured ones: