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.
npx skills add 233i/agent-skills --skill security-and-hardeninggit clone --depth 1 https://github.com/233i/agent-skillsWrote 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.
[](https://agentmods.dev/skills/233i/agent-skills/security-and-hardening)<a href="https://agentmods.dev/skills/233i/agent-skills/security-and-hardening"><img src="https://agentmods.dev/badge/skills/233i/agent-skills/security-and-hardening/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/233i/agent-skills/security-and-hardening"><img src="https://agentmods.dev/badge/skills/233i/agent-skills/security-and-hardening.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00057 | $0.02886 |
| Opus 5 | $0.00028 | $0.01443 |
| Sonnet 5 | $0.00011 | $0.00577 |
| Haiku 4.5 | $0.00006 | $0.00289 |
Grade A, and why
security-and-hardening scanned grade A with 0 findings 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 11d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 347 lines — stays where its author put it; the contents beside it link to each section on GitHub.
安全与加固
概览
以安全为优先的 Web 应用开发实践。把每一个外部输入都视为潜在恶意,把每一个 secret 都视为不可泄露,把每一次授权检查都视为必须执行。安全不是某个单独阶段,而是所有涉及用户数据、认证和外部系统代码的共同约束。
何时使用
- 构建任何接收用户输入的功能
- 实现认证或授权
- 存储或传输敏感数据
- 集成外部 API 或服务
- 新增文件上传、webhook 或 callback
- 处理支付或 PII 数据
三层边界系统
始终要做(Always Do)
- 校验所有外部输入,在系统边界处完成,例如 API route、表单处理器
- 所有数据库查询都参数化,绝不把用户输入拼进 SQL
- 输出做编码,防止 XSS,优先依赖框架自动转义,不要绕过
- 所有外部通信都使用 HTTPS
- 密码必须哈希存储,使用 bcrypt / scrypt / argon2,绝不能明文
- 设置安全头,例如 CSP、HSTS、X-Frame-Options、X-Content-Type-Options
- 会话 cookie 使用
httpOnly、secure、sameSite - 每次发布前运行
npm audit或等价工具
先询问(Ask First)
- 新增认证流程或修改现有 auth 逻辑
- 存储新的敏感数据类别,例如 PII 或支付信息
- 新增外部服务集成
- 修改 CORS 配置
- 增加文件上传处理器
- 调整限流或节流策略
- 授予更高权限或角色
绝不要做(Never Do)
- 绝不要把 secrets 提交进版本控制,例如 API key、密码、token
- 绝不要记录敏感数据,例如密码、token、完整信用卡号
- 绝不要把前端校验当作安全边界
- 绝不要为了方便关闭安全头
- 绝不要在用户提供的数据上使用
eval()或innerHTML - 绝不要把会话存进客户端可读存储,例如 localStorage 中保存 auth token
- 绝不要把堆栈或内部错误细节直接暴露给用户
OWASP Top 10 预防
1. 注入(SQL、NoSQL、OS Command)
// BAD: SQL injection via string concatenation
const query = `SELECT * FROM users WHERE id = '${userId}'`;
// GOOD: Parameterized query
const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
// GOOD: ORM with parameterized input
const user = await prisma.user.findUnique({ where: { id: userId } });
2. 认证失效
// Password hashing
import { hash, compare } from 'bcrypt';
const SALT_ROUNDS = 12;
const hashedPassword = await hash(plaintext, SALT_ROUNDS);
const isValid = await compare(plaintext, hashedPassword);
// Session management
app.use(session({
secret: process.env.SESSION_SECRET, // From environment, not code
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true, // Not accessible via JavaScript
secure: true, // HTTPS only
sameSite: 'lax', // CSRF protection
maxAge: 24 * 60 * 60 * 1000, // 24 hours
},
}));
3. 跨站脚本(XSS)
// BAD: Rendering user input as HTML
element.innerHTML = userInput;
// GOOD: Use framework auto-escaping (React does this by default)
return <div>{userInput}</div>;
// If you MUST render HTML, sanitize first
import DOMPurify from 'dompurify';
const clean = DOMPurify.sanitize(userInput);
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.
- 11d ago First seen · 347 lines · 57 tokens per session scan A 48476563f3b3
security-and-hardening is a skill published in the GitHub repository 233i/agent-skills (6 stars, last pushed 5mo ago), licensed MIT. It adds 57 tokens to every session and 2,886 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
insight-error-page
Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…
next-cache-components-optimizer
Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…
next-partial-prefetching-adoption
Turn on Partial Prefetching in a Next.js app and work through the insights it surfaces. Use when the user wants to enable or adopt Partial Prefetching, flip the partialPrefetching flag, opt routes in with export const prefetch = 'partial', audit Link prefetch={true} behavior, preserve existing prefetched UI with…