Home > Articles > Programming > PHP

Securing PHP Web Applications: Cross-Site Scripting

  • Print
  • + Share This
In this chapter, the authors cover a special type of injection attack called cross-site scripting, or XSS.
This chapter is from the book

This chapter is from the book

  • In this chapter, we cover a special type of injection attack called cross-site scripting, or XSS. This is a special type of code injection attack (remember those from Chapter 5, “Input Validation”?) that doesn’t affect your system as much as it affects your users. Our example guestbook is exactly the type of site that is vulnerable to these attacks.

What Is XSS?

XSS is just a special case of code injection. In this type of attack, the malicious user embeds HTML or other client-side script into your Web site. The attack looks like it is coming from your Web site, which the user trusts. This enables the attacker to bypass a lot of the client’s security, gain sensitive information from the user, or deliver a malicious application. There are two types of XSS attacks:

  • Reflected or nonpersistent
  • Stored or persistent
  • + Share This
  • 🔖 Save To Your Account