# Allocation of Resources Without Limits or Throttling (CWE-770) The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated. **Stack:** Python - Prevalence: 高 頻繁に悪用される - Impact: ミディアム レビュー推奨 - Prevention: 文書化済み 3 件の修正例 **OWASP:** Security Misconfiguration (A05:2021-Security Misconfiguration) - #5 ## Description Without limits on resource allocation, an attacker can consume all available resources, causing denial of service for legitimate users. ## Prevention 1 件の Shoulder 検出ルールに基づく Allocation Without Limits の予防策。 ### Python Add rate limiting to authentication and expensive API endpoints ## Warning Signs - [MEDIUM] API endpoint lacks rate limiting protection - [MEDIUM] API endpoints without rate limiting ## Consequences - DoS: リソース消費 - DoS: クラッシュ/終了/再起動 ## Mitigations - すべてのリソース割り当てにレート制限を実装する - リソースプールに最大値の上限を設定する - リソース使用状況を監視し、アラートを実装する ## Detection - Total rules: 3 - Languages: javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Missing API Rate Limiting** [MEDIUM]: Detects API endpoints without rate limiting. Unprotected endpoints are vulnerable to brute force attacks, credential stuffing, and denial of service. Always implement rate limiting on authentication, expensive operations, and public APIs. - Remediation: Add rate limiting decorator to authentication and expensive endpoints. ```python from flask_limiter import Limiter from flask_limiter.util import get_remote_address limiter = Limiter(app=app, key_func=get_remote_address) @app.route('/api/login', methods=['POST']) @limiter.limit("5 per minute") def login(): user = authenticate(request.json) return jsonify({'token': generate_token(user)}) ``` Learn more: https://shoulder.dev/learn/python/cwe-770/missing-rate-limiting