Skip to main content
This page documents the technical protections built into WardForge following the security audit of March 26, 2026. It is aimed at administrators who want to understand the bot’s internal workings.

Overview

WardForge implements defense-in-depth with multiple independent layers. If one layer is bypassed, the next takes over.

1. Recursive Anti-Phishing

Problem addressed

Attackers use redirect chains to hide malicious URLs. A naïve scanner checks bit.ly/xyz (harmless) but never sees evil-phishing.com it redirects to.

Implementation

WardForge recursively resolves each URL by following HTTP redirects until the final destination.

Opaque domain handling

Some redirect domains do not reveal the destination URL without user interaction (e.g., get-qr.com, captcha gates). WardForge handles this specifically:
  • Resolution successful → scan the final URL against phishing databases
  • Resolution impossible (opaque domain) → warning generated without automatic blocking to avoid false positives
False positives are the priority to avoid. A warning without blocking on an opaque domain is preferable to unjustifiably blocking a legitimate URL.

Cycle detection

A visited set is maintained for each resolution. If a URL appears twice in the chain, resolution stops immediately to prevent infinite loops.

2. Decompression Bomb Prevention

Problem addressed

A decompression bomb is a small compressed file (a few KB) that expands to several gigabytes. If an attacker sends a .zip image or encoded file with malicious content, a naïve scanner might attempt to decompress the content into memory and crash the bot.

Implementation

WardForge enforces strict limits when processing attachments:
Applied controls:
  1. Size check before download: The Content-Length header is verified. If the size exceeds MAX_FILE_SIZE, the file is ignored without downloading.
  2. Pixel limit for QR images: Before passing an image to the QR decoder, dimensions are checked. An image of 1px × 4 billion pixels would be rejected.
  3. Decompression timeout: Each decompression operation runs in a context with timeout (asyncio.wait_for). If decompression exceeds the time limit, the operation is cancelled.
  4. Error isolation: Decompression exceptions are caught locally and logged without crashing the main worker.

3. API Anti-Spam Protection

Problem addressed

WardForge queries up to 3 external APIs (PhishTank, Google Safe Browsing, VirusTotal) per scanned URL. Without limiting, an attacker could send thousands of messages containing URLs to exhaust API quotas or overload the bot.

Implementation

An asyncio.Semaphore limits the number of simultaneous API requests:
Combined mechanisms:

Probabilistic scanning

To avoid scanning every URL sent by a trusted member, WardForge applies probabilistic sampling based on Trust Score:
A member with score 90 has only a 37% chance of being scanned on each message. A member with score 10 is scanned 93% of the time.

4. Memory Leak Prevention

Problem addressed

Long-running sessions (captcha, anti-spam) accumulate data in memory if not cleaned up. An attacker can create thousands of unfinished captcha sessions to exhaust the bot’s RAM.

Implementation

Periodic cleanup tasks run in the background for each affected cog:
Cogs with automatic cleanup:

5. Database Pool Isolation

Problem addressed

Direct database access from multiple cogs simultaneously can create race conditions and hanging connections on error.

Implementation

All queries go through a centralized pool with context management:
Independent queries are parallelized with asyncio.gather to reduce latency:

6. Captcha Verification

Algorithm

The math captcha uses secrets.choice (CSPRNG) instead of random to prevent answer prediction:
A per-session asyncio.Lock prevents race conditions if the user clicks multiple times simultaneously.

Limits

  • 3 attempts maximum per session
  • 5-minute timeout per session
  • Automatic expiration: unfinished sessions are cleaned up every 10 minutes
  • Result: +15 Trust Score (success) or -20 Trust Score + kick (failure)

7. Role Hierarchy and Escalation Prevention

WardForge systematically verifies the role hierarchy before any moderation action:

Moderator abuse detection

If a moderator performs too many actions in a short time (configurable threshold, default: 3 actions/10s), WardForge:
  1. Logs the event as suspicious
  2. Notifies administrators
  3. Can restrict the moderator account’s permissions if the threshold is exceeded

8. Global Ban Confidence Scores

Every entry in the global blacklist carries a confidence score: Servers can configure a minimum confidence threshold below which automatic banning on join is not triggered, avoiding false positives on low-confidence entries.

Security Parameters Summary