prevent-js-security-bugs

prevent-js-security-bugs is a skill for Claude Code, Codex from antgroup/adversarial-ai-coding-plugin. It costs 68 tokens per session (1,413 once invoked), scanned A, original, Apache-2.0.

A coding guide for writing and changing JavaScript or TypeScript with common security risks identified and addressed first.

In plain words
What is it for?
Use it when writing, refactoring, or modifying JavaScript or TypeScript, especially code that handles user input, files, web pages, commands, or database queries.
Why use it?
It helps prevent vulnerabilities such as code injection, cross-site scripting, prototype pollution, path traversal, and unsafe database queries during development.

Skill for Claude CodeCodex

Part of the adversarial-ai-coding plugin — 5 skills, 2 hooks shipped together

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/antgroup/adversarial-ai-coding-plugin/prevent-js-security-bugs
Any agent
npx skills add antgroup/adversarial-ai-coding-plugin --skill prevent-js-security-bugs
Clone the repo
git clone --depth 1 https://github.com/antgroup/adversarial-ai-coding-plugin

Made for: Claude Code, Codex.

Or install adversarial-ai-coding, the plugin that ships this one along with the rest of its 5 skills, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prevent-js-security-bugs

README.md
[![agentmods](https://agentmods.dev/badge/skills/antgroup/adversarial-ai-coding-plugin/prevent-js-security-bugs.svg)](https://agentmods.dev/skills/antgroup/adversarial-ai-coding-plugin/prevent-js-security-bugs)
Your own site
<a href="https://agentmods.dev/skills/antgroup/adversarial-ai-coding-plugin/prevent-js-security-bugs"><img src="https://agentmods.dev/badge/skills/antgroup/adversarial-ai-coding-plugin/prevent-js-security-bugs.svg" alt="Measured on agentmods" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,413 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.00068 $0.01413
Opus 5 $0.00034 $0.00707
Sonnet 5 $0.00014 $0.00283
Haiku 4.5 $0.00007 $0.00141

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

Security

Grade A, and why

prevent-js-security-bugs 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 4d 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.

| OS 命令注入 | 调用 `child_process.exec`、`execSync`、`spawn` 等执行系统命令时,命令字符串或参数包含用户输入 | `references/prevent-os-command-execution.md` |
plugin/skills/prevent-js-security-bugs/SKILL.md · 61 lines

How it starts

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

安全代码生成规范

技能概述

本技能的目标是:在代码生成阶段消除安全漏洞,而非依赖事后审查

当用户需要编写、重构或修改 JavaScript/TypeScript 代码时,必须先完成威胁识别和规范查阅,再生成代码。禁止跳过安全分析步骤。

触发条件

满足以下任意一条时,必须激活本技能:

  • 编写、重构或修改 JavaScript/TypeScript 代码。

工作流程

必须严格按顺序执行以下三步,不得跳过任何步骤。

第一步:识别安全风险

逐条分析用户需求,对照下表判断哪些风险类型适用于当前场景。每一个适用的风险类型都必须处理,不得遗漏。

风险类型 典型场景 对应参考文档
Query Language 注入 拼接 SQL/HQL/NoSQL 查询语句;使用用户输入构造查询条件 references/prevent-ql-injection.md
OS 命令注入 调用 child_process.execexecSyncspawn 等执行系统命令时,命令字符串或参数包含用户输入 references/prevent-os-command-execution.md
代码注入 使用 evalnew FunctionsetTimeout(string) 执行非字面量字符串;使用非字面量路径动态 require();可能导致 RCE 或任意文件读取 references/prevent-code-injection.md
原型链污染 对对象进行递归合并、深拷贝、属性赋值时,键名来自用户输入(如 __proto__constructorprototype references/prevent-prototype-pollution.md
XSS(跨站脚本) 将用户输入直接插入 DOM(innerHTMLdocument.writedangerouslySetInnerHTML);在服务端渲染时未转义输出到 HTML 模板 references/prevent-xss.md
路径遍历 文件读取/写入/下载,路径由用户输入拼接(如 path.join(baseDir, userInput)),可能跨越根目录访问任意文件 references/prevent-path-traversal.md
SSRF(服务端请求伪造) 服务端发起 HTTP 请求时,目标 URL 或主机名由用户输入控制,可能访问内网服务或云元数据接口 references/prevent-ssrf.md
不安全反序列化 使用 node-serializeserialize-javascript 等库反序列化用户提供的数据,可能导致任意代码执行 references/prevent-deserialization.md
弱随机数 使用 Math.random()crypto.pseudoRandomBytes() 生成 session ID、token、nonce、密钥等安全敏感值 references/prevent-weak-random.md
PostMessage Origin 校验缺失 使用 window.addEventListener('message', ...) 接收跨窗口消息时未校验 event.origin;发送消息时使用通配符 '*' references/prevent-postmessage-origin.md
时序攻击 使用 ===!== 比较 HMAC 签名、API Key、session token、密码重置 token 等安全敏感字符串 references/prevent-timing-attack.md
ReDoS(正则表达式拒绝服务) 使用 new RegExp(userInput) 构造动态正则;正则模式包含嵌套量词((a+)+)或重叠交替((a|aa)+),可导致灾难性回溯阻塞事件循环 references/prevent-redos.md
Buffer 安全问题 使用已废弃的 new Buffer(size)(内存未初始化);Buffer.allocUnsafe() 结果未立即填充;Buffer 读写方法传入 noAssert=true 跳过边界检查 references/prevent-buffer-issues.md
不安全传输 通过 HTTP(非 HTTPS)加载外部脚本/样式;服务端使用 http 模块请求外部 API;动态 URL 未校验协议 references/prevent-insecure-transport.md
硬编码凭证 API Key、密码、JWT 密钥、私钥等敏感信息直接写入源代码或被 Git 追踪的配置文件 references/prevent-hardcoded-secrets.md

Read the full file on GitHub · 61 lines

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. 4d ago First seen · 61 lines · 68 tokens per session scan A c8538063c681

Subscribe to this mod's changes

prevent-js-security-bugs is a skill published in the GitHub repository antgroup/adversarial-ai-coding-plugin (7 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 68 tokens to every session and 1,413 once invoked, about $0.0003 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-31.

Related

Other skills, from other repositories

better-auth

Skill for integrating Better Auth - comprehensive TypeScript authentication framework for Cloudflare D1, Next.js, Nuxt, and 15+ frameworks. Use when adding auth, encountering D1 adapter errors, or implementing OAuth/2FA/RBAC features.

secondsky/claude-skills · 53 tokens

bun-bundler

This skill should be used when the user asks about "bun build", "Bun.build", "bundling with Bun", "code splitting", "tree shaking", "minification", "sourcemaps", "bundle optimization", "esbuild alternative", "building for production", "bundling TypeScript", "bundling for browser", "bundling for Node", or…

secondsky/claude-skills · 90 tokens

bun-file-io

Use for Bun file I/O: Bun.file, Bun.write, streams, directories, glob patterns, metadata.

secondsky/claude-skills · 27 tokens

bun-hot-reloading

Use when implementing hot reloading with Bun (--hot, --watch), HMR, or automatic code reloading during development. Covers watch mode, hot mode, and HTTP server reload.

secondsky/claude-skills · 42 tokens

pulumi-best-practices

Load when the user is writing, reviewing, or debugging Pulumi TypeScript/Python programs; asks about Output or apply() usage; wants to create ComponentResource classes; needs to refactor resources without destroying them (aliases); is setting up secrets or config; or is configuring a pulumi preview/up CI workflow.…

pulumi/agent-skills · 92 tokens

tanstack-form-composition

Migrate a React @tanstack/react-form codebase from the prop-drilled useForm + erased-form-type pattern to the official createFormHook composition API (useAppForm / withForm / field.X). Use when a project threads a form object (often cast to an any-erased type like ReactFormExtendedApi ) through field-wrapper…

suxrobGM/jobpilot · 158 tokens