Saltar al contenido
Skillpedia
Seguridad75 mil · #2753

avoid-eval

Qué hace

Esta skill comprueba el código en busca de usos de eval y de otras formas de ejecutar texto como código. Es para desarrolladores que quieren prevenir un tipo habitual y grave de ataque a sitios web.

Cuándo usarla

  • ✓Cuando encuentras eval o new Function en tu código.
  • ✓Cuando a un temporizador se le pasa una cadena de texto para ejecutar.
  • ✓Cuando revisas código que maneja datos de usuarios.

Link de la skill

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

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/avoid-eval/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Busca llamadas a eval en mi proyecto y sustitúyelas por código más seguro.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Tu agente busca en el código eval, new Function y temporizadores con cadenas de texto, y los sustituye por análisis de JSON, búsquedas en objetos o referencias a funciones.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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

Preguntas frecuentes

¿Por qué es peligroso eval?

La skill indica que si la entrada de un usuario llega a eval, un atacante puede ejecutar JavaScript en el navegador de otros visitantes.

¿Una política de seguridad de contenido lo evita?

La skill indica que CSP bloquea eval pero no new Function, así que hay que eliminar ambos del código.

¿Qué debo usar para analizar JSON?

JSON.parse, que la skill recomienda en lugar de eval.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
75 mil
Posición en el ranking
#2753
Licencia
MIT
Actualizada
31/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas