Home > Glossary > CompTIA PenTest+ > Cross-Site Scripting (XSS)

📖 What is Cross-Site Scripting (XSS)?

Cross-Site Scripting (XSS) is a vulnerability where an attacker injects malicious scripts into trusted websites, which are then executed in the victim's browser. This allows attackers to steal session cookies, redirect users, or deface pages by manipulating the client-side code.

🥋 Sensei Says:

"Distinguish between Stored (persistent), Reflected (non-persistent), and DOM-based XSS; the exam often asks which type requires the payload to be saved on the server."

📚 Certification: CompTIA PenTest+ (PT0-002)

🔑 What are the Key Concepts of Cross-Site Scripting (XSS)?

  • Stored XSS occurs when the malicious script is permanently saved on the target server, such as in a database, comment field, or user profile.
  • Reflected XSS involves a payload that is delivered via a link or request and is immediately reflected back to the user's browser without being stored.
  • DOM-based XSS happens entirely on the client side, where the vulnerability exists in the page's JavaScript rather than the server-side code.
  • The primary goal of XSS attacks is often to steal session cookies using document.cookie, enabling session hijacking and unauthorized account access.
  • Effective mitigation strategies include strict input validation, context-aware output encoding, and the implementation of a robust Content Security Policy (CSP).

🎯 How does Cross-Site Scripting (XSS) appear on the PT0-002 Exam?

A scenario might describe a penetration tester finding a vulnerability in a guestbook where any user visiting the page triggers an alert box; identify this as Stored XSS.

You may be asked to analyze a URL containing a script tag in a query parameter and determine that it represents a Reflected XSS attack vector.

Expect questions where you must choose the best remediation for XSS, such as selecting output encoding over simple input filtering to prevent script execution.

❓ Frequently Asked Questions

What is the most critical difference between Reflected and Stored XSS?

The difference is persistence. Reflected XSS requires a victim to click a malicious link to trigger the payload, while Stored XSS is hosted on the server and affects any user who views the compromised page.


Why is DOM-based XSS harder to detect with server-side logs?

Because the payload is processed entirely within the browser's Document Object Model, the malicious script often never reaches the server, leaving no trace in the server-side access or error logs.


How does output encoding prevent XSS attacks?

Output encoding converts special characters (like < and >) into their HTML entity equivalents (like &lt; and &gt;), ensuring the browser renders the input as literal text instead of executing it as code.

Related Terms from CompTIA PenTest+

📝 Related Study Guides

Comparison 8 min read

CISSP vs CISM: Which Certification Should You Pursue in 2026?

Choose CISSP if you want broad technical security expertise across eight domains, including cryptography, network security, and software development. Choose CISM if you're focused on information security management, governance, and risk management from a leadership perspective. CISSP is ideal for hands-on security architects, while CISM is designed for security managers and directors.

Career Guide 9 min read

The IT Certification Roadmap: Where to Start in 2026

Start your IT certification journey in 2026 with CompTIA A+ for general IT foundations, then branch into networking (Network+), cybersecurity (Security+), or cloud computing (AWS Cloud Practitioner or Azure Fundamentals) based on your career goals. Each path leads to advanced certifications like CISSP, AWS Solutions Architect, or CISM within 2-3 years of focused progression.

Comparison 10 min read

CISSP vs CISM: Which Certification Should You Pursue in 2026?

The CISSP is a broad, technical-to-managerial certification focusing on security operations and architecture across eight domains. In contrast, CISM is a specialized management certification centered on governance, risk management, and program development. Choose CISSP for comprehensive security expertise and CISM if you are pivoting specifically into security leadership and governance roles.

🧠

Test Your Knowledge

Think you understand Cross-Site Scripting (XSS)? Put it to the test with our practice exam.

Try 10 Free Questions

⭐ 1,000 expert-curated questions available with Premium

Upgrade Premium