resource-exhaustion-dos-ai-generated-code
БесплатноБез исполняемых скриптовНе проверенUnderstand resource exhaustion and denial of service vulnerabilities in AI code including unbounded loops, missing rate limits, and uncontrolled resource…
Об этом скилле
Resource Exhaustion and Denial of Service in AI-Generated Code
The Performance Security Nexus
Research from Databricks highlights:
"Vibe coding often produces functionally correct but resource-inefficient code that can be exploited for denial of service attacks."
The AI's focus on functionality over performance creates multiple attack vectors.
1.6.1 Uncontrolled Resource Consumption
The Problem
AI generates code that works perfectly for normal use but has no limits on resource consumption. This creates two major risks:
- Denial of Service (DoS): Attackers overwhelm server, making it unavailable
- Cost Explosion: Attackers abuse expensive operations (AI APIs, compute)
AI-Generated Vulnerable Code
// Prompt: "Create image processing endpoint"
app.post('/process-image', async (req, res) => {
const { imageUrl, operations } = req.body;
// ❌ VULNERABLE: No size or quantity limits
const imageBuffer = await downloadImage(imageUrl);
let processedImage = imageBuffer;
// ❌ VULNERABLE: Unbounded loop
for (const operation of operations) {
processedImage = await applyOperation(processedImage, operation);
}
res.send(processedImage);
});
// Attack: Send huge image or hundreds of operations
// Result: Server memory exhaustion and crash
Multiple Vulnerabilities in This Code
1. No Image Size Limit:
const imageBuffer = await downloadImage(imageUrl);
Attack:
- Upload 500MB image
- Server downloads entire image to memory
- Multiple concurrent requests
- Server runs out of memory → crash
2. No Operation Count Limit:
for (const operation of operations) {
processedImage = await applyOperation(processedImage, operation);
}
Attack:
- Send 1000 operations
- Each operation processes image
- Server CPU at 100% for minutes
- Legitimate requests time out
3. No Rate Limiting:
app.post('/process-image', async (req, res) => {
Attack:
- Send 10,000 requests simultaneously
- Server processes all (no queue)
- Server crashes or becomes unresponsive
4. No Timeout:
- Long-running operations never cancelled
- Malicious requests occupy resources forever
- Server capacity exhausted
5. No Validation:
- imageUrl could be anything
- Could point to 10GB file
- Could be internal URL (SSRF attack)
The $200,000 AI Cost Attack (Real Story)
One startup built a "summarize any article" AI feature without rate limiting:
Timeline:
- T+0: Feature launches (no rate limiting)
- T+10 min: Malicious user scripts 10,000 requests
- T+10 min: 10,000 OpenAI API calls made ($0.96 per call average)
- T+10 min: $9,600 in charges
- T+4 hours: Attack still running, unnoticed
- T+4 hours: Total cost exceeds $200,000
- T+5 hours: Startup notices, shuts down endpoint
- Outcome: Near bankruptcy, scramble for emergency funding
What went wrong:
- No rate limiting (unlimited requests)
- No request queuing (all processed immediately)
- No cost monitoring alerts
- No maximum spend limits on OpenAI API
Secure Implementation
const rateLimit = require('express-rate-limit');
const sharp = require('sharp');
// ✅ SECURE: Rate limiting
const imageLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 10, // 10 requests per window
message: 'Too many requests, please try again later',
standardHeaders: true,
legacyHeaders: false,
});
// ✅ SECURE: Request size limiting
app.use(express.json({ limit: '1mb' }));
// ✅ SECURE: Resource limits configuration
const LIMITS = {
MAX_IMAGE_SIZE: 10 * 1024 * 1024, // 10MB
MAX_IMAGE_DIMENSION: 4000, // pixels
MAX_OPERATIONS: 5,
DOWNLOAD_TIMEOUT: 5000, // 5 seconds
PROCESSING_TIMEOUT: 30000, // 30 seconds
MAX_CONCURRENT_JOBS: 3
};
// ✅ SECURE: Job queue for controlled concurrency
const Queue = require('bull');
const imageQueue = new Queue('image-processing', {
redis: {
port: 6379,
host: '127.0.0.1',
},
defaultJobOptions: {
timeout: LIMITS.PROCESSING_TIMEOUT,
attempts: 2,
removeOnComplete: true,
removeOnFail: true
}
});
// ✅ SECURE: Controlled image download
async function downloadImageSecure(url, limits) {
// Validate URL
const urlPattern = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b/;
if (!urlPattern.test(url)) {
throw new Error('Invalid URL');
}
// ✅ SECURE: Prevent SSRF by checking against internal IPs
const parsed = new URL(url);
if (isInternalIP(parsed.hostname)) {
throw new Error('Access to internal resources not allowed');
}
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), limits.DOWNLOAD_TIMEOUT);
try {
const response = await fetch(url, {
signal: controller.signal,
size: limits.MAX_IMA
Установить resource-exhaustion-dos-ai-generated-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл resource-exhaustion-dos-ai-generated-code?
Understand resource exhaustion and denial of service vulnerabilities in AI code including unbounded loops, missing rate limits, and uncontrolled resource consumption. Use this skill when you need to learn about DoS vulnerabilities in AI code, understand resource limits, recognize unbounded operations, or prevent resource exhaustion. Triggers include "resource exhaustion", "DoS vulnerabilities", "denial of service", "unbounded resources", "API cost protection", "memory exhaustion", "uncontrolled consumption", "rate limiting DoS".
Как установить скилл resource-exhaustion-dos-ai-generated-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл resource-exhaustion-dos-ai-generated-code запускает скрипты?
Нет, скилл состоит только из инструкций (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