Cyber Security News

Hackers Use GenAI to Turn Legitimate Web Pages Malicious in Seconds

A Novel Attack Technique Leverages LLMs to Generate Polymorphic Malicious Code at Runtime Dynamically.

Imagine visiting a webpage that appears completely legitimate. No suspicious links, no detectable malicious code, no warning signs. Yet within seconds, it transforms into a sophisticated phishing page tailored specifically to you.

This isn’t a hypothetical threat it’s an emerging attack vector where adversaries weaponize generative AI to evade traditional security defenses.

Security researchers have identified a novel attack technique where threat actors exploit client-side API calls to large language model (LLM) services, generating malicious JavaScript dynamically in real time. The attack begins with a seemingly benign webpage.

Attackers use carefully engineered prompts to bypass AI safety guardrails, tricking the LLM into returning malicious code snippets that are then assembled and executed in the victim’s browser, resulting in a fully functional phishing page.

The sophistication of this approach lies in its evasive design. Each malicious payload is polymorphic syntactically unique yet functionally identical across visits.

Because the malicious code is generated dynamically at runtime rather than delivered as a static payload, it bypasses network-based security analysis. Additionally, since the code originates from trusted LLM domains, it evades traditional threat detection mechanisms.

How the Attack Works

The attack follows three distinct steps. First, threat actors select a malicious webpage from active phishing or malware campaigns to serve as a template.

Second, they translate the malicious JavaScript functionality into plain-text prompts, iteratively refining them to bypass LLM safety mechanisms.

Third, these engineered prompts are embedded within a webpage. When a victim loads the page, it requests the LLM API to generate malicious code snippets, which are then assembled and executed within the browser.

Workflow of the PoC. The first two steps are initial preparation, and the third is an example of generating malicious content to be rendered in the browser ( Source : Unit42 palo alto).

Researchers demonstrated this technique using the LogoKit phishing campaign as a proof of concept. The original attack uses a static JavaScript payload to transform a benign web form into a convincing phishing lure.

By converting this payload into LLM prompts, they successfully generated dynamic variants capable of stealing credentials and impersonating legitimate webpages.

Simple prompt rephrasing proved remarkably effective a generic request for an AJAX POST function was permitted where a direct request for “credential exfiltration code” was blocked.

Why This Matters

This attack model represents a significant escalation in web-based threats. Current research indicates that 36% of detected malicious webpages exhibit runtime assembly behavior, executing constructed child scripts with functions like eval().

The non-deterministic output of the model provided a high degree of polymorphism, with each query returning a syntactically unique yet functionally identical variant of the malicious code.

Polymorphism creating multiple variants of dynamically generated JavaScript code (source : Unit42 palo alto).

Once loaded in a victim’s browser, the page makes requests to trusted LLM services like DeepSeek or Google Gemini.

Adding LLM-generated polymorphic code dramatically increases the difficulty of detection.

The non-deterministic nature of LLM outputs creates constant code mutation, making signature-based detection ineffective.

Each victim receives a syntactically unique variant, preventing pattern-matching security tools from identifying the threat.

Moreover, the malicious code is transmitted through trusted domains, effectively bypassing network-based filtering.

Traditional network analysis and static payload detection are insufficient against this threat. Organizations should implement runtime behavioral analysis within browsers to detect and block malicious activity at the point of execution.

Additionally, restricting access to unsanctioned LLM services at workplaces can serve as a preventative measure.

The most effective defense combines in-browser protection with offline analysis using browser-based sandboxes that render webpages in isolated environments. This approach can identify behavioral anomalies during runtime execution.

As threat actors continue innovating, the security landscape faces a critical inflection point. This AI-augmented attack technique exemplifies how emerging technologies can be weaponized to circumvent established defenses.

Organizations must shift from static detection toward dynamic, runtime-focused security strategies to effectively counter this evolving threat.

Follow us on Google News, LinkedIn, and X to Get Instant Updates and Set GBH as a Preferred Source in Google.

Mayura Kathir

Mayura Kathir is a cybersecurity reporter at GBHackers News, covering daily incidents including data breaches, malware attacks, cybercrime, vulnerabilities, zero-day exploits, and more.

Recent Posts

Hackers Use ConnectWise SkyKick Credentials to Access Microsoft 365, Halting Cloud Backups

Attackers abused compromised ConnectWise Cloud Backup credentials to access Microsoft 365 customer environments, prompting ConnectWise…

1 day ago

Anthropic’s Claude AI Uncovers Origins of NSA-Provided Cryptographic Keys After 25 Years

Anthropic says an internal Claude research model reconstructed how the National Security Agency generated seeds…

2 days ago

Critical WordPress Flaws Allow Attackers to Execute Remote Code Without Authentication

Two WordPress Core vulnerabilities can be chained to execute remote code without authentication, according to…

2 days ago

OpenBSD Kernel Flaw Dating Back 37 Years Enables Local Privilege Escalation to Root

A newly disclosed OpenBSD kernel exploitation chain combines a shared memory accounting flaw with a…

2 days ago

GhostAction Hackers Hide Credential-Stealing Malware in Fake Font Files Across 94 GitHub Repositories

GhostAction attackers have expanded their GitHub credential theft campaign with a second stage that disguises…

2 days ago

SideCopy Hackers Target Indian Organizations With ReverseRAT Malware to Steal Data

Indian authorities have warned that SideCopy hackers are targeting Indian organizations, including academic institutions, with…

2 days ago