How it works...

There are two mains types of XSS, reflected and persistent. Persistent XSS is where an attacker was able to implant a code exploit within a persistent layer of our architecture (for instance, a server-side database, but also caching layers and browser persistent could come under the same banner). Reflected XSS is reliant on a single interaction with a server, such that the content returned by the server contains the code exploit.

In our case, the main problem is a reflected XSS vulnerability.

The way the href attribute of the anchor tag (<a>) is constructed from input parameters allows an attacker to create a URL that can effectively break context (that is, the context of being an HTML attribute), and inject code into the ...

Get Node Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.