Skip to content

Security, Safe Browsing & Bot Defense

How Shaf protects users, destination reputations, and enterprise brands from phishing, malicious URLs, bot scrapers, and volumetric abuse.

Security, Safe Browsing & Bot Defense

URL shorteners are prime targets for malicious actors seeking to disguise phishing landing pages, distribute malware, or execute automated credential scraping. A single malicious link can destroy a branded domain’s email deliverability and search engine reputation.

Shaf implements a defense-in-depth security architecture protecting link creators, branded hostnames, and downstream visitors.


Defense Layers Pipeline

Every link creation request and visitor redirect passes through automated security filters:

flowchart TD
    subgraph CreationPath["1. Link Creation Pipeline (Write Path)"]
        CreateReq["POST /api/v1/links"] --> ThreatScan{"Automated Threat Intelligence\n(Google Safe Browsing & DNS)"}
        ThreatScan -->|Malicious / Phishing| BlockThreat["Reject: 40303 MALICIOUS_URL"]
        ThreatScan -->|Clean| TurnstileGate{"Cloudflare Turnstile Check\n(Form & Unauthenticated API)"}
        TurnstileGate -->|Bot Signature| BlockBot["Reject: 40301 BOT_DETECTED"]
        TurnstileGate -->|Verified Human / Token| StoreDB[("Commit to D1 & KV Storage")]
    end

    subgraph ResolutionPath["2. Visitor Resolution Pipeline (Read Path)"]
        VisitReq["Visitor Requests Short Link"] --> WAFGate{"Cloudflare Anycast WAF\n(DDoS & Volumetric Scraping)"}
        WAFGate -->|Attack Signature| WAFBlock["Block at Anycast Edge"]
        WAFGate -->|Clean| PwdCheck{"Password Protected?"}
        PwdCheck -->|Yes| PwdChallenge["Render Turnstile & Password Challenge Form\n(Brute-Force Rate-Limited)"]
        PwdCheck -->|No| RoutingEval["Evaluate Smart Device/Geo Rules"]
        PwdChallenge -->|Valid Password| RoutingEval
        RoutingEval --> PrivacyHeaders["Apply Referrer Policy (strict-origin-when-cross-origin)"]
        PrivacyHeaders --> RedirectResp["HTTP 308 Redirect to Destination"]
    end

1. Automated Safe Browsing & Anti-Phishing

When a destination URL is submitted via the console or API, Shaf initiates an edge threat inspection before persisting the link:

Google Safe Browsing API

Target URLs are evaluated against Google’s global Safe Browsing threat lists covering malware hosts, social engineering landing pages, and unwanted software distributors used by Chrome, Safari, and Firefox.

Cloudflare Security DNS Intelligence

Destination domains are checked against Cloudflare’s 1.1.1.2 security resolver threat intelligence feeds, which continuously track zero-day phishing infrastructure and fast-flux DNS operations.

If a destination domain is flagged, link creation is blocked immediately with 40303 MALICIOUS_URL. The check runs in under 40ms without impacting overall API throughput.


2. Cloudflare Turnstile Bot Defense

Automated bot networks frequently attempt:

  • Slug Enumeration / Brute-Force Scanning: Systematically requesting sequential or dictionary slugs to uncover private documents.
  • Link Harvesting: Scraping public directories to steal competitor campaigns.
  • Automated Spam Injection: Submitting thousands of links through public forms.

Shaf integrates Cloudflare Turnstile — a privacy-preserving CAPTCHA alternative:

Evaluation Criterion Legacy CAPTCHAs Cloudflare Turnstile
User Experience Distorted images, audio puzzles, traffic delays Zero visible interaction for legitimate users
Privacy Protection Third-party tracking cookies & device profiling Non-interactive browser attestation; zero PII
Detection Accuracy Easily bypassed by modern AI vision models Machine learning behavioral analysis at edge
Edge Integration External third-party server roundtrip Native Cloudflare Workers runtime validation

3. Password Protection & Brute-Force Rate Limiting

For sensitive or internal links, Shaf allows creators to enforce password authentication:

  1. One-Way Cryptographic Hashing: Passwords are never stored in plaintext. They are hashed using PBKDF2 with a unique cryptographic salt per link.
  2. Brute-Force Lockout: Failed password submission attempts are throttled using an edge rate-limiter keyed on IP + Slug:
    • 5 incorrect attempts trigger an exponential lockout delay.
    • 10 incorrect attempts require completing an interactive Cloudflare Turnstile challenge.
  3. Session Masking: Password-protected links set an ephemeral, encrypted HMAC cookie on the client upon successful validation, granting a 2-hour access window without requiring re-entry.

4. Cloudflare WAF & Anycast DDoS Absorption

Because Shaf runs on Cloudflare’s global Anycast network:

  • Volumetric DDoS Mitigation: Massive layer 3/4/7 volumetric floods are automatically absorbed across 300+ data centers before packets reach Shaf application code.
  • Web Application Firewall (WAF): Real-time inspection blocks SQL injection, cross-site scripting (XSS), and path traversal attacks.
  • IP Reputation Throttling: Traffic originating from known malicious proxies or bulletproof hosting providers is automatically challenged or dropped.

5. Referrer Policy & Destination Privacy

When redirecting visitors to external landing pages, Shaf protects sensitive campaign parameters:

  • Referrer Policy: All HTTP 308 redirects enforce Referrer-Policy: strict-origin-when-cross-origin, ensuring destination servers do not receive sensitive internal URLs from your private intranet.
  • Link Cloaking Isolation: When cloaking is enabled, the destination page is framed inside a sandboxed full-viewport HTML container with strict Content-Security-Policy and X-Frame-Options headers to prevent clickjacking.

Type to search…

↑↓ navigate↵ selectEsc close