Skip to content

Secure IT

Stay Secure. Stay Informed.

Primary Menu
  • Home
  • Sources
    • Krebs On Security
    • Security Week
    • The Hacker News
    • Schneier On Security
  • Home
  • The Hacker News
  • Why React Didn’t Kill XSS: The New JavaScript Injection Playbook
  • The Hacker News

Why React Didn’t Kill XSS: The New JavaScript Injection Playbook

[email protected] The Hacker News Published: July 29, 2025 | Updated: July 29, 2025 5 min read
0 views

React conquered XSS? Think again. That’s the reality facing JavaScript developers in 2025, where attackers have quietly evolved their injection techniques to exploit everything from prototype pollution to AI-generated code, bypassing the very frameworks designed to keep applications secure.

Full 47-page guide with framework-specific defenses (PDF, free).

JavaScript conquered the web, but with that victory came new battlefields. While developers embraced React, Vue, and Angular, attackers evolved their tactics, exploiting AI prompt injection, supply chain compromises, and prototype pollution in ways traditional security measures can’t catch.

A Wake-up Call: The Polyfill.io Attack

In June 2024, a single JavaScript injection attack compromised over 100,000 websites in the biggest JavaScript injection attack of the year. The Polyfill.io supply chain attack, where a Chinese company acquired a trusted JavaScript library and weaponized it to inject malicious code, affected major platforms including Hulu, Mercedes-Benz, and WarnerBros. This wasn’t an isolated incident targeting vulnerable forms or outdated systems. This was a sophisticated injection that turned websites’ own security tools against them, proving that traditional JavaScript defenses have become dangerously obsolete.

The Threat Landscape Has Changed

Gone are the days when a simple innerHTML sanitization could keep your app secure. Today’s attackers are leveraging:

  • Supply chain compromises targeting your favorite npm packages
  • Prototype pollution attacks that can hijack your entire object model
  • AI-driven prompt injections that trick LLMs into generating malicious code
  • DOM-based XSS in single-page applications that bypass server-side protections

The numbers tell the story: 22,254 CVEs were reported by mid-2024, a 30% jump from 2023 and 56% increase from 2022. With 98% of websites using JavaScript client-side and 67.9% of developers relying on it as their primary language, the attack surface has never been larger.

What Makes This Different

Most security guides still focus on decade-old attack patterns. This comprehensive analysis breaks down modern threats with a defense-in-depth approach that prioritizes protections by impact:

For real-world code samples and a prioritized roadmap, see the full guide

The Framework Reality Check

Even modern frameworks aren’t bulletproof:

This React code looks safe but isn’t –

// 🚨 Vulnerable: unsanitized input

Better approach with proper sanitization –

// ✅ Secure: React component with DOMPurify

Why it matters:

dangerouslySetInnerHTML bypasses React’s built-in XSS protection by directly injecting HTML into the DOM. When user content contains malicious scripts, they execute immediately in the victim’s browser, potentially:

  • Stealing authentication cookies and session tokens
  • Performing actions on behalf of the user
  • Redirecting to malicious sites
  • Keylogging sensitive information

DOMPurify sanitizes HTML by parsing the content and removing any potentially malicious elements while preserving safe formatting tags like , ,

, etc.

The Banking Sector Under Siege

The financial industry has become prime target for sophisticated JavaScript injection attacks. In March 2023, IBM uncovered a malware campaign that targeted over 40 banks across the Americas, Europe, and Japan, compromising more than 50,000 individual user sessions. The attack leveraged advanced JavaScript web injections that detect specific page structures used by banking platforms, then dynamically inject malicious scripts to steal user credentials and one-time password tokens.

What made this campaign particularly dangerous was its adaptive behavior, the malware constantly communicated with command-and-control servers, adjusting its tactics in real-time based on page states and security detection attempts. Using sophisticated obfuscation techniques, the malware could patch functions to remove traces of its presence and avoid execution when security products were detected, proving that traditional JavaScript defenses are no match for modern, dynamically evolving threats.

The Store Raw, Encode on Output Principle

One of the guide’s most practical insights reinforces a fundamental security best practice: always store raw data and encode based on output context.

This approach:

  1. Store raw, unencoded data in your database
  2. Apply context-specific encoding at render time based on where data appears
  3. Use different encoding methods for each output context (HTML entities for HTML content, JavaScript escaping for JS contexts, URL encoding for URLs, CSS escaping for stylesheets)

This context-aware encoding approach prevents double-encoding issues, maintains data integrity, and ensures proper protection regardless of how the data is eventually displayed, something any TypeScript developer building robust domain models will appreciate. The key insight is that the same user input might need HTML encoding when displayed in a div, JavaScript escaping when used in a script tag, and URL encoding when used in a link parameter.

WebAssembly Security Considerations

While WebAssembly offers performance benefits and sandboxing, it’s important to understand its security implications. The guide examines how Wasm introduces specific considerations that developers should be aware of:

  • Source code vulnerabilities carry over: Memory-unsafe languages like C/C++ compiled to Wasm retain their original vulnerability patterns (buffer overflows, use-after-free, etc.)
  • Reduced transparency: The binary format makes security auditing more challenging compared to readable JavaScript source
  • Novel attack surfaces: Side-channel attacks through timing analysis and potential VM escape vectors, though these remain largely theoretical

WebAssembly’s sandboxed execution model does provide strong isolation, but like any technology, it requires thoughtful implementation and shouldn’t be viewed as an automatic security upgrade from JavaScript.

Emerging AI Threats

As LLMs become integrated into web applications, a new attack vector has emerged: prompt injection attacks. Malicious users craft prompts that trick AI models into generating JavaScript code that executes on the client side, a completely new category of injection vulnerability. You can learn more about it in the full guide.

The Bottom Line

Modern JavaScript security isn’t about implementing a checklist, it’s about understanding how attackers think and building layered defenses that adapt to evolving threats. Whether you’re building with React, Angular, or Vue, the fundamental principle remains: never trust client-side code, always validate server-side, and encode based on context.

The complete guide provides implementation examples for all major frameworks, practical code samples, and a prioritized approach that helps teams tackle the most critical vulnerabilities first.

Download the full PDF playbook here.

Found this article interesting? This article is a contributed piece from one of our valued partners. Follow us on Google News, Twitter and LinkedIn to read more exclusive content we post.

About The Author

[email protected] The Hacker News

See author's posts

Original post here

What do you feel about this?

  • The Hacker News

Post navigation

Previous: CISA Adds PaperCut NG/MF CSRF Vulnerability to KEV Catalog Amid Active Exploitation
Next: Cybercriminals Use Fake Apps to Steal Data and Blackmail Users Across Asia’s Mobile Networks

Author's Other Posts

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse whatsapp-sim.jpg

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse

December 2, 2025 0 0
Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera korean.jpg

Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera

December 2, 2025 0 1
GlassWorm Returns with 24 Malicious Extensions Impersonating Popular Developer Tools hacked.jpg

GlassWorm Returns with 24 Malicious Extensions Impersonating Popular Developer Tools

December 2, 2025 0 0
Malicious npm Package Uses Hidden Prompt and Script to Evade AI Security Tools npm-mal.jpg

Malicious npm Package Uses Hidden Prompt and Script to Evade AI Security Tools

December 2, 2025 0 1

Related Stories

whatsapp-sim.jpg
  • The Hacker News

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse

[email protected] The Hacker News December 2, 2025 0 0
korean.jpg
  • The Hacker News

Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera

[email protected] The Hacker News December 2, 2025 0 1
hacked.jpg
  • The Hacker News

GlassWorm Returns with 24 Malicious Extensions Impersonating Popular Developer Tools

[email protected] The Hacker News December 2, 2025 0 0
npm-mal.jpg
  • The Hacker News

Malicious npm Package Uses Hidden Prompt and Script to Evade AI Security Tools

[email protected] The Hacker News December 2, 2025 0 1
iran-hacking.jpg
  • The Hacker News

Iran-Linked Hackers Hits Israeli Sectors with New MuddyViper Backdoor in Targeted Attacks

[email protected] The Hacker News December 2, 2025 0 0
SecAlerts.jpg
  • The Hacker News

SecAlerts Cuts Through the Noise with a Smarter, Faster Way to Track Vulnerabilities

[email protected] The Hacker News December 2, 2025 0 0

Trending Now

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill 1

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill

December 6, 2025 0 0
SMS Phishers Pivot to Points, Taxes, Fake Retailers SMS Phishers Pivot to Points, Taxes, Fake Retailers 2

SMS Phishers Pivot to Points, Taxes, Fake Retailers

December 4, 2025 0 0
India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse whatsapp-sim.jpg 3

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse

December 2, 2025 0 0
Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera korean.jpg 4

Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera

December 2, 2025 0 1

Connect with Us

Social menu is not set. You need to create menu and assign it to Social Menu on Menu Settings.

Trending News

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill 1
  • Uncategorized

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill

December 6, 2025 0 0
SMS Phishers Pivot to Points, Taxes, Fake Retailers SMS Phishers Pivot to Points, Taxes, Fake Retailers 2
  • Uncategorized

SMS Phishers Pivot to Points, Taxes, Fake Retailers

December 4, 2025 0 0
India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse whatsapp-sim.jpg 3
  • The Hacker News

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse

December 2, 2025 0 0
Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera korean.jpg 4
  • The Hacker News

Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera

December 2, 2025 0 1
GlassWorm Returns with 24 Malicious Extensions Impersonating Popular Developer Tools hacked.jpg 5
  • The Hacker News

GlassWorm Returns with 24 Malicious Extensions Impersonating Popular Developer Tools

December 2, 2025 0 0
Malicious npm Package Uses Hidden Prompt and Script to Evade AI Security Tools npm-mal.jpg 6
  • The Hacker News

Malicious npm Package Uses Hidden Prompt and Script to Evade AI Security Tools

December 2, 2025 0 1
Iran-Linked Hackers Hits Israeli Sectors with New MuddyViper Backdoor in Targeted Attacks iran-hacking.jpg 7
  • The Hacker News

Iran-Linked Hackers Hits Israeli Sectors with New MuddyViper Backdoor in Targeted Attacks

December 2, 2025 0 0

You may have missed

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill
  • Uncategorized

Drones to Diplomas: How Russia’s Largest Private University is Linked to a $25M Essay Mill

Sean December 6, 2025 0 0
SMS Phishers Pivot to Points, Taxes, Fake Retailers
  • Uncategorized

SMS Phishers Pivot to Points, Taxes, Fake Retailers

Sean December 4, 2025 0 0
whatsapp-sim.jpg
  • The Hacker News

India Orders Messaging Apps to Work Only With Active SIM Cards to Prevent Fraud and Misuse

[email protected] The Hacker News December 2, 2025 0 0
korean.jpg
  • The Hacker News

Researchers Capture Lazarus APT’s Remote-Worker Scheme Live on Camera

[email protected] The Hacker News December 2, 2025 0 1
Copyright © 2026 All rights reserved. | MoreNews by AF themes.