베타 Shoulder는 베타 버전입니다 — 결과가 가끔 잘못될 수 있습니다. 여러분의 피드백이 다음에 무엇을 고칠지 결정합니다. 피드백 공유
📈

Allocation of Resources Without Limits or Throttling

🛡️ 3 개의 규칙이 이를 탐지합니다

Allocation of Resources Without Limits or Throttling

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.

Without limits on resource allocation, an attacker can consume all available resources, causing denial of service for legitimate users.

보급률
높음
자주 악용됨
영향
보통
검토 권장
예방
문서화됨
3개의 수정 예시
2 예방
2 예방

이 취약점을 수정하는 방법

3개의 Shoulder 탐지 규칙을 기반으로 한 Allocation Without Limits 예방 전략.

Request Size Limits in Express.js MEDIUM

Set size limits on body parser middleware to prevent memory exhaustion

+2 -2 javascript
- app.use(express.json());
- app.use(express.urlencoded({ extended: true }));
+ app.use(express.json({ limit: '100kb' }));
+ app.use(express.urlencoded({ extended: true, limit: '100kb' }));
  
Prisma Unbounded Relation Loading MEDIUM

Add 'take' limits to all relation includes to prevent unbounded data loading and resource exhaustion

+9 -2 javascript
  import { PrismaClient } from '@prisma/client';
  const prisma = new PrismaClient();
  
  app.get('/api/users/:id', async (req, res) => {
    const user = await prisma.user.findUnique({
      where: { id: req.params.id },
      include: {
-       posts: true,         // Could be thousands of posts
-       comments: true,      // Could be tens of thousands
+       posts: {
+         take: 20,
+         orderBy: { createdAt: 'desc' },
+         select: { id: true, title: true, createdAt: true },
+       },
+       comments: {
+         take: 50,
+         orderBy: { createdAt: 'desc' },
+       },
      }
    });
    res.json(user);
  });
  
Missing API Rate Limiting MEDIUM

Add rate limiting to authentication and expensive API endpoints

+7 -2 python
  from flask import Flask, request, jsonify
- 
- @app.route('/api/login', methods=['POST'])
+ 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)})
  
3 탐지
3 탐지

코드에서 취약점 찾기

Shoulder를 사용하여 코드에서 Allocation of Resources Without Limits or Throttling 패턴을 스캔하세요. 3 규칙.

터미널
# Scan with Shoulder CLI
npx @shoulderdev/cli trust --cwe=770

# Or scan entire project
npx @shoulderdev/cli trust .

탐지 규칙 (3)

4 경고 신호
4 경고 신호

코드 리뷰에서 주의할 점

이 패턴은 잠재적인 Allocation of Resources Without Limits or Throttling 취약점을 나타냅니다. 코드 리뷰와 보안 감사 중에 찾아보세요.

🟡
Body parser without size limit: ... Without request size limits, attackers can send oversized payloads causing memory ex javascript-express-request-size-limits
🟡
missing or inadequate request size limits in Express javascript-express-request-size-limits
🟡
Relation '...' loaded without 'take' limit. This can cause resource exhaustion if users have many related records. prisma-unsafe-include
🟡
API endpoint lacks rate limiting protection python-missing-rate-limiting
🟡
API endpoints without rate limiting python-missing-rate-limiting
🔍

코드베이스를 스캔하세요: Allocation of Resources Without Limits or Throttling

Shoulder CLI는 전체 코드베이스에서 취약한 패턴을 찾아냅니다.