eval()

The JavaScript function that runs a string as code.

Evaluating strings that contain user input lets attackers run arbitrary code.

In more detail

The code runs with access to the variables around the call, which makes its effects hard to predict. If any part of the string comes from users, attackers can run their own code, which is why eval is treated as an injection sink and blocked by strict CSP.

Related terms

Taught in

References