BETA Shoulder is in beta — Findings may sometimes be wrong. Your feedback shapes what we fix next. Share feedback

Description

Detects AI/LLM API calls that lack token limits, potentially enabling denial of service attacks. OWASP LLM04 - Model Denial of Service. DoS attacks against LLMs can: - Exhaust API quotas through unbounded token generation - Cause excessive costs via high token usage - Degrade service availability This rule detects: - Missing max_tokens limits on completions - Missing input length validation - Unbounded streaming responses NOTE: Rate limiting is covered separately by the Express rate-limiting rule. See: rules/javascript/projects/express/security/rate-limiting.yaml

What Shoulder detects

LLM API call lacks resource limits ({issue_type})

How to fix

Set max_tokens limits and validate input length before LLM calls.

```javascript
const response = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: message.substring(0, 2000) }],
  max_tokens: 500
});
```

Learn more: https://shoulder.dev/learn/javascript/cwe-400/llm-denial-of-service

Applies to

Frameworks

express fastify nodejs

References

Scan for this issue

Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=javascript-llm-denial-of-service .

Real-world examples

Known CVEs in the Resource Exhaustion vulnerability class that this rule helps detect.

Related rules