How we train AI to uncover malicious JavaScript intent and make web surfing safer
Mar 19, 2025Juan Miguel Cejuela, Zhiyuan Zheng

Summary
Introduced a new AI model for Page Shield that detects specific malicious JavaScript intents (Magecart, crypto mining, malware) by parsing JavaScript into concrete syntax trees (CSTs) using tree-sitter, converting them to an AST-like structure, and feeding this into a message-passing graph convolutional network (MPGCN). The model handles obfuscated code by treating it as is and leveraging graph structure information. The TF-GNN library is used for implementation, with consideration for switching to PyTorch Geometric due to sparse matrix support limitations.
More from the Website Security & Threat Management trail
- We tested our own WAF with frontier AI models. Here’s what we found
- When scanners miss the attack: how Cloudflare Client-Side Security protects storefronts
- Introducing automatic remediation policies with Cloudflare CASB
- Introducing context-aware vulnerability discovery and remediation with Cloudflare Managed Defense and OpenAI Daybreak Models
- Introducing Adaptive Intelligence: undermining the economics of every bot attack