Skip to content
Skillpedia
Security75k · #2753

avoid-eval

What it does

This skill checks code for uses of eval and other ways to run text as code. It is for developers who want to prevent a common and serious type of website attack.

When to use it

  • ✓When you find eval or new Function in your code.
  • ✓When a timer is given a text string to run.
  • ✓When you are reviewing code that handles data from users.

Skill link

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/avoid-eval/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/avoid-eval/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Search my project for eval calls and replace them with safer code.”

5 new skills a week. 1 minute to read.

How it works

The agent searches the code for eval, new Function and timers given text strings, then swaps them for JSON parsing, object lookups or function references.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Never use eval() or unsafe dynamic code execution

eval() and its equivalents are the root cause of some of the most severe XSS vulnerabilities. If any user-controlled string reaches eval(), an attacker can execute arbitrary JavaScript in your users' browsers — stealing sessions, making requests as the user, or redirecting to malicious sites. Content Security Policy (CSP) blocks eval() but not new Function(), and there is never a legitimate use case that can't be solved without it.

Quick Reference

  • eval() executes arbitrary strings as code — any user input passed to it is a critical security hole
  • new Function() is equally dangerous and not caught by CSP eval restrictions
  • setTimeout('code', delay) and setInterval('code', delay) also evaluate strings — use function references instead
  • Use JSON.parse() instead of eval() for parsing JSON

Check

Search this codebase for any use of eval(), new Function(), or setTimeout/setInterval with string arguments.

Fix

Replace eval() calls with safe alternatives: JSON.parse for data, object lookups for dynamic dispatch, and Function references for timers.

Explain

Explain why eval() is dangerous, how it enables XSS attacks, and what safe alternatives exist for each use case.

Code Review

Review scripts, client components, and browser execution paths related to Never use eval() or unsafe dynamic code execution. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/avoid-eval

FAQ

Why is eval dangerous?

The skill says if user input reaches eval, an attacker can run JavaScript in other visitors' browsers.

Does a content security policy stop this?

The skill says CSP blocks eval but not new Function, so both need to be removed from the code.

What should I use to parse JSON?

JSON.parse, which the skill recommends instead of eval.

Details

Original description by the author

Use when reviewing scripts, client components, bundles, or runtime behavior related to Never use eval() or unsafe dynamic code execution. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

Popularity

GitHub stars
75k
Ranking position
#2753
License
MIT
Updated
10/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills