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

데이터 쿼리 로직의 특수 요소에 대한 부적절한 무효화

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

데이터 쿼리 로직의 특수 요소에 대한 부적절한 무효화

제품이 데이터 저장소의 데이터에 접근하거나 조작하기 위한 쿼리를 생성하지만, 쿼리의 의도된 로직을 변경할 수 있는 특수 요소를 무효화하지 않거나 잘못 무효화합니다. 이는 전통적인 SQL 인젝션과는 다른 NoSQL 데이터베이스, ORM 프레임워크, 기타 데이터 쿼리 메커니즘에 대한 인젝션 공격을 포함합니다.

This covers injection attacks against NoSQL databases, ORM frameworks, and other data query mechanisms that differ from traditional SQL injection.

보급률
높음
자주 악용됨
영향
높음
3개의 높은 심각도 규칙
예방
문서화됨
3개의 수정 예시
2 예방
2 예방

이 취약점을 수정하는 방법

3개의 Shoulder 탐지 규칙을 기반으로 한 NoSQL Injection 예방 전략.

NoSQL 인젝션 HIGH

Use typed structs or explicit operators, validate all user input

+2 -1 go
  func findUser(w http.ResponseWriter, r *http.Request) {
      username := r.URL.Query().Get("username")
-     filter := bson.M{"username": username}
+     // Use explicit $eq to prevent operator injection
+     filter := bson.M{"username": bson.M{"$eq": username}}
      collection.FindOne(ctx, filter)
  }
  
MongoDB 쿼리를 통한 NoSQL 인젝션 HIGH

Validate input types and sanitize MongoDB operators

+5 -3 javascript
- app.post('/login', async (req, res) => {
-   const { username, password } = req.body;
-   // Vulnerable: user can send { "$gt": "" } as password
+ const mongoSanitize = require('mongo-sanitize');
+ 
+ app.post('/login', async (req, res) => {
+   const username = mongoSanitize(req.body.username);
+   const password = mongoSanitize(req.body.password);
    const user = await User.findOne({ username, password });
    if (user) {
      res.json({ success: true });
    }
  });
  
NoSQL 인젝션 HIGH

Validate input types and use ObjectId for ID fields

+7 -2 python
  from flask import request
  from pymongo import MongoClient
  
  db = MongoClient().mydb
  
  @app.route('/login', methods=['POST'])
  def login():
      data = request.get_json()
-     # Vulnerable: entire dict from user
-     user = db.users.find_one(data)
+     # Safe: only use specific string fields
+     username = str(data.get('username', ''))
+     password = str(data.get('password', ''))
+     user = db.users.find_one({
+         'username': username,
+         'password': password
+     })
      return {'success': bool(user)}
  
3 탐지
3 탐지

코드에서 취약점 찾기

Shoulder를 사용하여 코드에서 데이터 쿼리 로직의 특수 요소에 대한 부적절한 무효화 패턴을 스캔하세요. 3 규칙.

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

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

코드베이스를 스캔하세요: 데이터 쿼리 로직의 특수 요소에 대한 부적절한 무효화

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