Web Security · Middle · Question 4 of 75

Why is eval(userInput) or new Function(userInput) always dangerous?

Explanation

If any part of the string comes from users, they control the code. Strict CSP also blocks these calls unless 'unsafe-eval' is set.

Further reading

Problem with a question

Web Security · Middle · question 4

Test yourself

Take the Web Security · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz