code-injection-codegen

A security checker for code injection, where untrusted input becomes part of generated code or is evaluated as code.

In plain words
What is it for?
Use it to audit template engines, validators, expression evaluators, serializers, compilers, query builders, and other packages that generate or evaluate code.
Why use it?
It helps find cases where functions such as eval or new Function execute attacker-controlled content, which can let an attacker run unintended code.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/byamb4/find-cve-agent/code-injection-codegen
Any agent
npx skills add ByamB4/find-cve-agent --skill code-injection-codegen
Clone the repo
git clone --depth 1 https://github.com/ByamB4/find-cve-agent

Made for: Claude Code, Codex.

Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,239 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00032 $0.01239
Opus 5 $0.00016 $0.00620
Sonnet 5 $0.00006 $0.00248
Haiku 4.5 $0.00003 $0.00124

Measured 2d ago against content hash 76209f7d4635, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-injection-codegen scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

// Exploit: schema.type = '"; }); process.mainModule.require("child_process").execSync("id"); //'
skills/code-injection-codegen/SKILL.md · 166 lines

How it starts

The opening of the file, as written. The whole thing — 166 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Code Injection via Code Generation

When to Use

Audit any package that dynamically generates or evaluates code — schema validators, template engines, expression evaluators, serializers with code generation, JIT compilers, query builders that emit JavaScript.

This is the highest-yield vulnerability class for CVE hunting. ~90% acceptance rate when confirmed.

Key Insight

Code generation packages often interpolate user-controlled values directly into generated code strings. Unlike template injection (where user input goes INTO a template), here user input becomes PART of the generated code itself.

Process

Step 1: Find Code Evaluation Sinks

Search for all dynamic code execution:

# JavaScript/TypeScript
grep -rn "new Function\(" .
grep -rn "eval(" .
grep -rn "vm\.run" .
grep -rn "vm\.compileFunction" .
grep -rn "setTimeout(" . | grep -v "setTimeout(function"
grep -rn "setInterval(" . | grep -v "setInterval(function"
grep -rn "new AsyncFunction" .
grep -rn "script\.runIn" .

# Python
grep -rn "eval(" .
grep -rn "exec(" .
grep -rn "compile(" . | grep -v "re.compile"

# Ruby
grep -rn "\.eval\b" .
grep -rn "instance_eval" .
grep -rn "class_eval" .

# PHP
grep -rn "eval(" .
grep -rn "assert(" .
grep -rn "create_function" .
grep -rn "preg_replace.*\/e" .

Step 2: Trace Data Flow to Sink

For each sink found:

  1. Identify what string is being evaluated
  2. Trace backwards — is any part of that string derived from user input?
  3. Check for template literals: new Function(`return ${userInput}`)
  4. Check for string concatenation: new Function("return " + userInput)
  5. Check for variable interpolation in generated code

Step 3: Check for Block Comment Escape

JSON.stringify does NOT escape */. If generated code wraps values in block comments:

// VULNERABLE PATTERN:
let code = `/* ${JSON.stringify(userValue)} */ actual_code_here`;
// Attacker input: */ malicious_code /*
// Result: /* */ malicious_code /* */ actual_code_here

Search for this pattern:

grep -rn "\/\*.*JSON\.stringify" .
grep -rn "\/\*.*\$\{" .

Read the full file on GitHub · 166 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 166 lines · 32 tokens per session scan A 76209f7d4635

Subscribe to this mod's changes

code-injection-codegen is a skill published in the GitHub repository ByamB4/find-cve-agent (46 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 32 tokens to every session and 1,239 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories