N
N
Nikolai Antonov2017-01-09 20:49:50
JavaScript
Nikolai Antonov, 2017-01-09 20:49:50

Why did the xss attack work in this example?

Problem #4 from the xss game website .
Answer: if you insert it into the form, ');alert('xssthen the alert will work. That data will be substituted into the function as the "seconds" argument:

function startTimer(seconds) {
        seconds = parseInt(seconds) || 3;
        setTimeout(function() {
          window.confirm("Time is up!");
          window.history.back();
        }, seconds * 1000);

It seems in line 2 the attack itself seems to be happening.
Why doesn't the same code work in this example? example #2 jsfiddle

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2017-01-09
@abyrkov

BecausestartTimer('');alert('');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question