Software Secured Company Logo.
Services
Services
WEB, API & MOBILE SECURITY

Manual reviews expose logic flaws, chained exploits, and hidden vulnerabilities

Web Application Pentesting
Mobile Application Pentesting
Secure Code Review
Infrastructure & Cloud Security

Uncovers insecure networks, lateral movement, and segmentation gaps

External Network Pentesting
Internal Network Pentesting
Secure Cloud Review
AI, IoT & HARDWARE SECURITY

Specialized testing validates AI, IoT, and hardware security posture

AI Pentesting
IoT Pentesting
Hardware Pentesting
ADVANCED ADVERSARY SIMULATIONS

We simulate attackers, exposing systemic risks executives must address

Red Teaming
Social Engineering
Threat Modelling
PENETRATION TESTING AS A SERVICE

PTaaS provides continuous manual pentests, aligned with release cycles

Penetration Testing as a Service
OWASP TOP 10 TRAINING

Practical security training strengthens teams, shifting security left effectively

Secure Code Training
Ready to get started?
Identify real vulnerabilities confidently with zero-false-positive penetration testing
Learn More
Industries
Industries
INDUSTRIES
Data and AI

AI pentesting uncovers adversarial threats, ensuring compliance and investor trust

Healthcare

Penetration testing protects PHI, strengthens compliance, and prevents healthcare breaches

Finance

Manual pentests expose FinTech risks, securing APIs, cloud, and compliance

Security

Penetration testing validates SecurTech resilience, compliance, and customer trust

SaaS

Pentesting secures SaaS platforms, proving compliance and accelerating enterprise sales

CASE STUDY

“As custodians of digital assets, you should actually custodize assets, not outsource. Software Secured helped us prove that our custody technology truly delivers on that promise for our clients in both the cryptocurrency and traditional finance”

Nicolas Stalder,
CEO & Co-Founder, Cordial Systems
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
Compliance
Compliance
COMPLIANCE
SOC 2 Penetration Testing

Pentesting validates SOC 2 controls, proving real security to auditors and customers

HIPAA Penetration Testing

Manual pentesting proves HIPAA controls protect PHI beyond documentation

ISO 27001 Penetration Testing

Pentests uncover risks audits miss, securing certification and enterprise trust

PCI DSS Penetration Testing

Pentesting validates PCI DSS controls, protecting sensitive cardholder data

GDPR Penetration Testing

GDPR-focused pentests reduce breach risk, regulatory fines, and reputational loss

CASE STUDY

“Software Secured’s comprehensive approach to penetration testing and mobile expertise led to finding more vulnerabilities than our previous vendors.”

Kevin Scully,
VP of Engineering, CompanyCam
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
PricingPortal
Resources
Resources
COMPLIANCE
Blogs
Case Studies
Events & Webinars
Partners
Customer Testimonials
News & Press
Whitepapers
API & Web Application Security Testing

The Highest Threat: The Hidden Weakness in Modern API & Web Application Security

Alexis Savard
November 21, 2025
Ready to get started?
Our comprehensive penetration testing and actionable reports have 0 false positives so you can identify
Learn More
Login
Book a Consultation
Contact
Blog
/
API & Web Application Security Testing
/
Penetration Testing Methodology

3 Types of Cross-site Scripting Attacks & 4 Mitigation Strategies

Understanding the three main types of XSS attacks can help you plan to mitigate them using one of these four recommended strategies.

By Warren Moynihan
・
12 min read
Table of contents
Text Link
Text Link

Cross-site scripting (XSS) is an application security vulnerability that allows a hacker to inject malicious code into a website or mobile application. XSS flaws have been known and studied since the 2000s. Understanding the different types of XSS attacks is crucial as these flaws have been known and studied since the 2000s. Despite their popularity and plague, they are still frequently found and do not show signs of disappearing anytime soon. The impact of an XSS attack can be an important finding in penetration testing. XSS attacks occur when a malicious user enters a piece of code as input data. The malicious code is eventually interpreted as DOM markup and runs on a victim’s browser. With their code running on the victim’s browser, the attacker can steal confidential information and perform other actions in the context of that user, also bypassing numerous security controls like the same-origin policy.

Three Common Types of XSS Attacks

Stored XSS Attack Explanation

Stored XSS is when the malicious script is injected into a vulnerable app where it is persisted or stored on the vulnerable page of the application. When a victim loads the affected page in the application the malicious script will execute the context of a user’s session. Here is an example of stored XSS in the Elementor Page Builder tool.

Generated image

‍

Reflected XSS Attack Overview

Reflected XSS attacks occur when a victim is tricked by the attacker into visiting a malicious link within the vulnerable application. The malicious link may be introduced to the victim via social engineering, phishing, or watering hole-style attacks. In this scenario, these non-persistent scripts are injected into a user’s browser session and executed as a direct reflection within HTTP responses returned by the server. Here is an example of reflected XSS in the JetBrains TeamCity tool.

‍

Generated image

‍

‍

Understanding DOM-Based XSS Attacks

DOM-based XSS also involves a malicious link and may be introduced to the victim in a similar attack vector as reflected XSS, although unlike what we’ve seen so far DOM-based XSS attacks do not require interaction with a server. The attacker’s code is stored and executed in the browser. Thus, securing our server-side code will offer no protection against DOM-based attacks. The attack’s independence from the server also makes detection more complex.

Generated image

‍

‍

Exploring the Growing Popularity of XSS Issues

Actions an attacker can take when their code is running on a user’s browser include:

  • Steal the user’s sensitive information, such as login credentials, credit card information, and other private/sensitive data.
  • Hijack a user’s session (if your application allows JavaScript to read HTTP session information).
  • Send and receive data from a malicious web server.
  • Access the user’s webcam, microphone, and location through HTML 5 APIs or other known browser vulnerabilities.
  • Advanced phishing techniques that will be difficult for both non-technical and technical users to identify.

The presence of XSS vulnerabilities depends on various factors, and these factors explain why such flaws are still being found at an increasing rate. Not all developers are necessarily trained in the risks associated with XSS and the impact of these vulnerabilities is sometimes not perceived correctly. As systemic security starts with the code, developers lack the knowledge and frameworks to integrate and manage many security elements. When a site or an application is coded without a framework, it is, unfortunately, easy to write code that is vulnerable to XSS and to overlook the verifications and controls of the data received.

‍

Effective Strategies for Mitigating XSS Attacks

No single technique will solve XSS. However, using the right combination of defensive techniques is necessary to prevent XSS. There are various ways to try and protect yourself and your organization from this class of vulnerability, and we will go into various prevention methods.

1- Implementing Framework Security Measures

Fewer XSS bugs appear in applications built with modern web frameworks. These frameworks steer developers towards good security practices and help mitigate XSS by using templating, auto-escaping, and more. Understand how your framework prevents XSS and where it has gaps. There will be times when you need to do something outside the protection provided by your framework. This is where Output Encoding and HTML Sanitization are critical. OWASP is producing framework-specific cheat sheets for React, Vue, and Angular.

2- Adopting a Proactive XSS Defense Philosophy

For XSS attacks to be successful, an attacker needs to insert and execute malicious content in a webpage. Each variable in a web application needs to be protected. Ensuring that all variables go through validation and are then escaped or sanitized is known as perfect injection resistance. Any variable that does not go through this process is a potential weakness. Frameworks make it easy to ensure variables are correctly validated and escaped or sanitized.

However, frameworks aren't perfect and security gaps still exist in popular frameworks like React and Angular. Output Encoding and HTML Sanitization help address those gaps.

3- Leveraging Output Encoding Techniques

Output encoding is recommended when you need to safely display data exactly as a user typed it in. Variables should not be interpreted as code instead of text. This section covers each form of output encoding, where to use it, and where to avoid using dynamic variables entirely.

Start with using your framework’s default output encoding protection when you wish to display data as the user typed it in. Automatic encoding and escaping functions are built into most frameworks.

If you’re not using a framework or need to cover gaps in the framework then you should use an output encoding library. Each variable used in the user interface should be passed through an output encoding function. A list of output encoding libraries is included in the appendix.

There are many different output encoding methods because browsers parse HTML, JS, URLs, and CSS differently. Understanding the various types of XSS attacks is crucial when selecting the appropriate output encoding method. Using the wrong encoding method may introduce weaknesses or harm the functionality of your application.

4- Importance of HTML Sanitization in XSS Prevention

Sometimes users need to author HTML. One scenario would be to allow users to change the styling or structure of content inside a WYSIWYG editor. Output encoding here will prevent XSS, but it will break the intended functionality of the application. The styling will not be rendered. In these cases, HTML Sanitization should be used.

To learn more about XSS protection and specific output coding code snippets, visit OWASP’s XSS Cheat Sheet.

‍

Conclusion

In summary, mastering the three XSS variants—Stored, Reflected, and DOM-based—is the first step toward robust web application security. By combining framework-provided protections with rigorous output encoding and targeted HTML sanitization, you establish multiple layers of defense that greatly reduce the attack surface. Embrace a “perfect injection resistance” mindset: validate every input, escape or encode every output, and sanitize any user-authored HTML. Finally, augment your development controls with regular security reviews or a professional penetration test to catch any gaps before they reach production. With these practices in place, you’ll be positioned not just to defend against today’s XSS threats, but to stay ahead of tomorrow’s.

‍

About the author

Warren Moynihan

Continue your reading with these value-packed posts

API & Web Application Security Testing

The Good, The Bad and the Ugly? Lessons from Incident Responses

Omkar Hiremath
Omkar Hiremath
9 min read
October 31, 2022
API & Web Application Security Testing

The Complete Guide to The Risks of Broken Access Control

Shimon Brathwaite
Shimon Brathwaite
9 min read
June 28, 2023
Mobile App Penetration Testing

Mobile Penetration Tests: The 3 Major Mobile Security Controls

Sherif Koussa
Sherif Koussa
8 mins min read
March 22, 2023

Get security insights straight to your inbox

Helping companies identify, understand, and solve their security gaps so their teams can sleep better at night

Book a Consultation
Centralize pentest progress in one place
Canadian based, trusted globally
Actionable remediation support, not just findings
Web, API, Mobile Security
Web App PentestingMobile App PentestingSecure Code Review
Infrastructure & Cloud Security
External Network PentestingInternal Network PentestingSecure Cloud Review
AI, IoT & Hardware Security
AI PentestingIoT PentestingHardware Pentesting
More
PricingPortalPartnersContact UsAbout UsOur TeamCareers
More Services
Pentesting as a ServiceSecure Code Training
Industries
Data and AIFinanceHealthcareSecuritySaaS
Compliance
GDPR PentestingHIPAA PentestingISO 27001 PentestingPCI DSS PentestingSOC 2 Pentesting
Resources
BlogsCase StudiesEvents & WebinarsCustomer TestimonialsNews & PressWhitepapers
More
PricingPortalPartnersContact UsAbout UsOur TeamCareers
Resources
BlogsCase StudiesEvents & WebinarsCustomer TestimonialsNews & PressWhitepapers
Security & CompliancePrivacy PolicyTerms & Conditions
2025 ©SoftwareSecured