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

Improper Authentication

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

Improper Authentication

When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.

Authentication is the process of determining if a claimed identity is correct. When authentication is insufficient or incorrect, attackers can assume the identity of legitimate users.

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

이 취약점을 수정하는 방법

2개의 Shoulder 탐지 규칙을 기반으로 한 Improper Authentication 예방 전략.

JWT Decode Used for User Identity (Authentication Bypass) CRITICAL

Use jwt.verify() instead of jwt.decode() when assigning user identity

+3 -1 javascript
- const decoded = jwt.decode(token);
+ const decoded = jwt.verify(token, process.env.JWT_SECRET, {
+   algorithms: ['HS256']
+ });
  req.user = decoded;
  
Authentication Bypass Vulnerability CRITICAL

Use early returns for authentication failures and constant-time comparison

+8 -7 python
  from flask import request, jsonify
- 
- @app.route('/login', methods=['POST'])
- def login():
-     user = User.query.filter_by(username=request.json['username']).first()
-     if user and user.password == request.json['password']:
-         return jsonify({'token': generate_token(user)})
-     return jsonify({'error': 'Invalid'}), 401
+ from werkzeug.security import check_password_hash
+ 
+ @app.route('/login', methods=['POST'])
+ def login():
+     user = User.query.filter_by(username=request.json['username']).first()
+     if not user or not check_password_hash(user.password_hash, request.json['password']):
+         return jsonify({'error': 'Invalid credentials'}), 401
+     return jsonify({'token': generate_token(user)})
  
4 경고 신호
4 경고 신호

코드 리뷰에서 주의할 점

이 패턴은 잠재적인 Improper Authentication 취약점을 나타냅니다. 코드 리뷰와 보안 감사 중에 찾아보세요.

🔴
authentication checks that can be bypassed due to missing return statements or weak boolean logic python-authentication-bypass
🔍

코드베이스를 스캔하세요: Improper Authentication

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