ai-code-security
БесплатноБез исполняемых скриптовНе проверенSecurity review of AI-generated code, and secure practices for working with coding assistants. USE WHEN: reviewing AI-generated code (GitHub Copilot, ChatGPT…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
AI-Generated Code Security Skill
USE WHEN: Reviewing AI-generated code (GitHub Copilot, ChatGPT, Claude, etc.) for security vulnerabilities, or establishing secure AI coding practices. DO NOT USE FOR: AI/ML model security, prompt injection attacks on AI systems, or general code review.
AI Code Security Risks (2024-2025 Research)
Key Statistics
- 45% of AI-generated code contains security vulnerabilities (Stanford/NYU study)
- 40% of Copilot suggestions include hardcoded credentials or insecure patterns
- Package hallucinations create supply chain risks (non-existent packages that could be typosquatted)
- Outdated patterns: AI trained on pre-2023 data may suggest deprecated/vulnerable APIs
Common AI-Generated Vulnerabilities
1. Hardcoded Credentials
// AI often generates this pattern
const API_KEY = 'sk-abc123...'; // Hardcoded!
const client = new ApiClient({ apiKey: API_KEY });
// Secure alternative
const client = new ApiClient({
apiKey: process.env.API_KEY ?? throwError('API_KEY required')
});
2. SQL Injection
// AI frequently suggests string interpolation
const query = `SELECT * FROM users WHERE id = ${userId}`;
// Secure alternative
const [rows] = await db.query('SELECT * FROM users WHERE id = ?', [userId]);
3. Weak Cryptography
// AI often suggests deprecated algorithms
const hash = crypto.createHash('md5').update(password).digest('hex');
// Secure alternative
import argon2 from 'argon2';
const hash = await argon2.hash(password, { type: argon2.argon2id });
4. Missing Input Validation
// AI-generated code often lacks validation
app.post('/users', (req, res) => {
const user = createUser(req.body); // No validation!
});
// Secure alternative
import { z } from 'zod';
const UserSchema = z.object({
email: z.string().email(),
name: z.string().min(1).max(100),
});
app.post('/users', (req, res) => {
const validated = UserSchema.parse(req.body);
const user = createUser(validated);
});
5. Insecure Randomness
// AI often suggests Math.random()
const token = Math.random().toString(36); // Predictable!
// Secure alternative
import { randomBytes } from 'crypto';
const token = randomBytes(32).toString('hex');
6. Path Traversal
// AI often misses path validation
const filePath = path.join(__dirname, 'uploads', req.params.filename);
fs.readFile(filePath); // ../../etc/passwd possible!
// Secure alternative
const safeName = path.basename(req.params.filename); // Strip directory components
if (safeName !== req.params.filename || safeName.includes('..')) {
throw new BadRequestError('Invalid filename');
}
const filePath = path.join(__dirname, 'uploads', safeName);
7. Package Hallucinations
// AI may suggest non-existent packages
import { validate } from 'json-validator-pro'; // May not exist!
// Before using ANY AI-suggested package:
// 1. Verify it exists: npm view json-validator-pro
// 2. Check download stats: npmjs.com/package/json-validator-pro
// 3. Check for typosquatting: lodash vs lodesh
AI Code Review Checklist
Pre-Integration Review
| Check | Description | Tool |
|---|---|---|
| Secrets scan | No hardcoded credentials | gitleaks, trufflehog |
| Dependency exists | All imports exist and are popular | npm view, pypi search |
| OWASP Top 10 | No injection, XSS, CSRF, etc. | semgrep, eslint-plugin-security |
| Crypto check | Modern algorithms only | custom rules |
| Input validation | All external inputs validated | zod, joi, manual review |
Package Verification Process
# Before adding AI-suggested packages:
# 1. Check if package exists
npm view <package-name>
# 2. Check popularity (downloads should be > 1000/week for production use)
npm info <package-name> downloads
# 3. Check for known vulnerabilities
npm audit <package-name>
# 4. Check repository activity
gh repo view <owner>/<repo> --web
# 5. Look for typosquatting variants
npm search <package-name>
Secure AI Coding Workflow
1. Context Priming
When using AI assistants, include security context:
Generate a user authentication endpoint for Express.js that:
- Uses parameterized queries (not string interpolation)
- Validates all inputs with Zod
- Uses Argon2id for password hashing
- Implements rate limiting
- Returns generic error messages (no information disclosure)
- Uses environment variables for secrets
2. Security-First Prompts
Review this code for security issues:
- Check for OWASP Top 10 vulnerabilities
- Verify all inputs are validated
- Confirm no hardcoded secrets
- Check for secure random generation
- Verify proper error handling
3. Post-Generation Review
# Run automated security checks on AI-generated code
npm run lint:security
npx semgrep --config=p/security-audit <file>
npx gitleaks detect --source .
Установить ai-code-security в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBashFAQ
Что делает скилл ai-code-security?
Security review of AI-generated code, and secure practices for working with coding assistants. USE WHEN: reviewing AI-generated code (GitHub Copilot, ChatGPT, Claude, etc.) for security vulnerabilities, or establishing secure AI coding practices DO NOT USE FOR: AI/ML model security, prompt injection attacks on AI systems, or general code review
Как установить скилл ai-code-security?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ai-code-security запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic