Some tips on demonstrating XSS in a Hapi application
Recent browser versions have included some basic protections against XSS. You may need to turn this off (temporarily!) to try out these examples.
With handlebars, use an extra brace, i.e.
{{{ ... }}}
to remove the default sanitisation.
The following is a simple example to show how a parameterised route can cause an XSS vulnerability:
{
method: 'GET', path: '/welcome/{lname}',
handler: function (request, reply) {
reply('Welcome ' + request.params.lname + '! Go <a href="/login">here</a> to log in.');
}
},
This can be exploited with the URL:
http://localhost:4000/welcome/John