September 26, 2026
Understanding XSS in the Era of AI-Generated Code
How AI-assisted development is reshaping an old web security challenge.

By Anjali Patil
3 min read
In January 2026, a social network called Moltbook launched with an unusual promise: a platform for AI agents to interact with each other, built almost entirely through AI coding tools.
Within days, researchers found a Supabase API key exposed in the app's client-side JavaScript, with Row Level Security never enabled on the underlying database. They could query production data directly, pulling API tokens and user details with no exploit required.
What stood out to me wasn't how sophisticated the attack was, but how ordinary the underlying mistake turned out to be. No zero-day, no novel technique, no advanced adversary. Just the same basic error the security community has been flagging for decades.
Cross-site scripting (XSS) is one of the oldest, most documented vulnerabilities on the web, and it still shows up in modern applications constantly.
The Vulnerability That Refuses to Retire
XSS happens when an attacker injects malicious JavaScript into a page other users load. A comment section, a search field, a username field, anywhere user input gets displayed back without proper handling is a potential target.
The browser can't tell the difference between code the application wrote and code an attacker snuck in. It just runs it, with the same trust the real site has earned.
If XSS were solved, I'd expect it to be fading from vulnerability reports. Instead, MITRE's 2025 CWE Top 25 ranked it the most common weakness across thousands of reported vulnerabilities. Better frameworks, better browser protections, decades of developer awareness, and it's still everywhere.
Why It Never Actually Left
Frameworks such as React, Angular, and Vue have made many common XSS mistakes harder to introduce, but they haven't eliminated the problem entirely. In practice, vulnerabilities still appear when applications handle user content outside those built-in safeguards.
To me, that's why XSS never really disappeared. The obvious mistakes have become less common, but the underlying challenge remains the same: making sure untrusted input is never treated as executable code.
A simple example is a search feature that inserts user input directly into a page as HTML. If that input is not handled safely, content intended as text can end up being interpreted as executable code.
AI coding assistants add another layer to this problem. They allow developers to generate working code much faster than before, but they also make it easier to introduce mistakes that may never receive the same level of review as hand-written code.
When Code Generation Outpaces Security Review
Research keeps showing that AI coding assistants struggle with secure input handling, and XSS is one of the clearest examples. Veracode's 2025 GenAI Code Security Report tested more than 100 LLMs across several languages and found that AI-generated code frequently failed to defend against XSS.
There's a structural reason for this.
XSS requires dataflow analysis: tracing data from where it enters an app to where it finally executes, often across functions, files, and services.
LLMs are generally better at producing code that looks correct than at reasoning through how data moves across a whole system. Pattern-matching gets you functional software, but security bugs usually hide in the relationships between components, not in single lines of code. XSS falls squarely into that gap.
AI Is Also Part of the Solution
I don't think the story ends with AI creating more vulnerabilities. The same technology is increasingly being used to find them.
One example is Google's Big Sleep, a collaboration between DeepMind and Project Zero that helped identify previously unknown vulnerabilities in widely used software. Projects like this suggest that AI is starting to play a role in vulnerability discovery, not just code generation.
We're seeing the same trend in security testing. Tools such as Pentest Copilot by BugBase use LLMs to assist with reconnaissance, analysis, and workflow coordination, allowing testers to spend less time on repetitive tasks and more time investigating actual findings.
To me, the more interesting question isn't whether AI is helping or hurting security. It's doing both. The same systems that help developers produce software faster are also helping defenders find weaknesses faster.
Moltbook and Big Sleep feel like two sides of the same story. One demonstrates how quickly software can be built and deployed. The other demonstrates how quickly vulnerabilities can be discovered. XSS sits between those two trends, a decades-old vulnerability that continues to survive because code is being produced faster than it can be reviewed.