Cybercriminals are now leveraging generative artificial intelligence (GenAI) to dynamically transform seemingly clean webpages into malicious phishing tools in real-time, a significant evolution in web-based threats that poses new challenges for cybersecurity detection and prevention efforts.
Security researchers at Palo Alto Networks discovered that attackers can embed specially crafted instructions within a benign webpage. When a user visits the site, it secretly requests code from public APIs of popular AI services like Google Gemini or DeepSeek. These requests are engineered with hidden prompts designed to trick the AI systems into generating malicious JavaScript code that bypasses safety guardrails. The generated code is then executed directly in the victim’s browser, instantly turning the page into a dangerous tool for credential theft or phishing, leaving no static payload for traditional security solutions to detect.
How Hackers Use GenAI to Create Real-Time Malicious Webpages
This innovative attack vector represents a concerning advancement where the malicious code is not pre-existing but is generated on the fly. Attackers exploit the vast capabilities of generative AI to create polymorphic code. This means each time a user visits a compromised page, the AI can generate a slightly different version of the malicious JavaScript, altering its syntax and structure while maintaining its harmful functionality.
The polymorphic nature of this AI-generated code is a primary reason it evades traditional detection systems. Security tools that rely on signature-based detection, looking for known malicious patterns, are rendered ineffective. The constant variation in code structure means that once a signature is identified, attackers can simply have the AI generate a new variant, staying one step ahead of defenses. This dynamic generation of JavaScript for phishing content makes the threat both elusive and highly adaptable.
Furthermore, the malicious code is disseminated through legitimate AI service domains. When a user’s browser requests code from these trusted sources, network monitoring tools often fail to flag the traffic as suspicious. This circumvents many network-based security measures that are designed to block known malicious IP addresses or domains. The attack cleverly hides within the flow of otherwise normal internet activity, making it exceptionally difficult to isolate and block at the network perimeter.
The execution of the malicious code directly within the user’s browser adds another layer of evasion. Unlike traditional malware that might exist as a file on a system, this threat is assembled and activated in the runtime environment of the browser. This means there is no discernible file on disk for antivirus scanners to find or for forensic analysis to uncover. The danger materializes only when the webpage loads and the AI-generated script runs, making detection a race against time.
Palo Alto Networks analysts demonstrated this technique, highlighting its effectiveness in enhancing existing phishing campaigns. They showed how attackers could systematically leverage GenAI to craft and deploy malicious content that bypasses common security inspections. The research underscores the need for advanced security solutions that can analyze the behavior of code at the point of execution within the browser itself, rather than solely relying on static analysis or network traffic inspection.
The implication of this evolving threat is a potential surge in sophisticated phishing attacks that are harder to detect and prevent. As GenAI technology becomes more accessible and is integrated into more services, the potential for its misuse in cyberattacks will likely grow. Organizations and individuals must remain vigilant, employing advanced endpoint security solutions that offer runtime behavioral analysis and are capable of identifying malicious activities as they occur, even when the code’s origin is trusted and its structure is constantly changing.

