avoid-eval
できること
このスキルは、evalやテキストをコードとして実行する他の方法の使用を、コードの中で確認します。よくあり深刻なタイプのWeb攻撃を防ぎたい開発者向けです。
使う場面
- ✓コードにevalやnew Functionがあるとき。
- ✓タイマーに、実行するテキスト文字列を渡しているとき。
- ✓利用者からのデータを扱うコードをレビューしているとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/avoid-eval/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のプロジェクトでevalの呼び出しを検索し、より安全なコードに置き換えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、evalやnew Function、テキスト文字列を渡すタイマーをコードから探し、JSONの解析、オブジェクトの参照、関数の参照に置き換えます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
evalは、なぜ危険ですか?
利用者の入力がevalに届くと、攻撃者が他の訪問者のブラウザでJavaScriptを実行できると、このスキルは説明しています。
コンテンツセキュリティポリシーでこれを防げますか?
CSPはevalを防ぐがnew Functionは防がないため、両方をコードから取り除く必要があると、このスキルは説明しています。
JSONの解析には何を使うべきですか?
evalの代わりに推奨されている、JSON.parseです。
詳細
作者による元の説明
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.
人気
- GitHubのスター
- 75k
- ランキング
- #2753
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。