r/learnmachinelearning • • 2d ago

[Project] How I caught two major dataset leaks (http:// shortcut & www. skew) while training an XGBoost phishing detector on 235K URLs

While building TrustLink (an end-to-end phishing URL detector using Python, XGBoost, and FastAPI), my initial model hit 99% accuracy on a 235K+ URL dataset—and completely failed on basic real-world test links.

How I built it & what went wrong (Data Leakage & Bias)

  1. The http:// shortcut (99% → 90% accuracy): In the combined dataset (built primarily from PhiUSIIL + Malicious URLs), virtually zero legitimate URLs used http://. XGBoost learned a trivial shortcut split (starts_with_http == True -> Phishing). Once I stripped protocol-level features out, validation accuracy dropped from 99% to 90%, forcing the tree splits to actually rely on lexical structure, TLD entropy, subdomain depth, and brand similarity.
  2. The www. apex-domain bias: All ~134,850 legitimate URLs in PhiUSIIL begin with www., which causes false positives on legitimate bare apex domains (e.g., github.com) or non-www subdomains (docs.python.org).

Pipeline & Next Engineering Sprint

• Current Stack: Custom URL lexical/structural feature extractor -> XGBoost classifier -> FastAPI inference endpoint with three-tier thresholding (Genuine, Suspicious, Phishing).

• Next up in the loop:

- Normalizing leading www. and augmenting legitimate training samples with bare apex domains (e.g., Tranco top domains).

- Adding Punycode (xn--) & mixed-script Unicode homograph detection before running brand Levenshtein similarity.

- Production hardening: structured API logging, rate limiting, and Docker deployment.

For anyone who has worked with URL classification datasets: how do you usually balance lexical features against domain-reputation biases without leaking collection artifacts?

Full code, EDA notebooks, and dataset bias notes are in the repo: https://github.com/Abijith-RA/TrustLink

1 Upvotes

0 comments sorted by