Unchecked Error Condition
The product does not properly check when a function or operation returns a value that is associated with an error condition.
When error conditions are not checked, the application may continue with invalid or unexpected state, potentially leading to crashes, data corruption, or security vulnerabilities.
이 취약점을 수정하는 방법
3개의 Shoulder 탐지 규칙을 기반으로 한 Unchecked Error Condition 예방 전략.
Log or return errors instead of silently swallowing them
_, err := db.Exec("DELETE FROM sessions WHERE expired = true") if err != nil { + log.Printf("session cleanup failed: %v", err) + return err }
Always handle promise rejections with .catch() or try/catch in async functions
app.post('/create', async (req, res) => { - const user = await User.create(req.body); - res.json(user); + try { + const user = await User.create(req.body); + res.json(user); + } catch (error) { + logger.error('User creation failed:', error); + res.status(500).json({ error: 'Could not create user' }); + } });
Log exceptions or handle them explicitly instead of silently swallowing with pass
- def get_data(): - try: - data = fetch_sensitive_data() - return {'data': data} - except: - pass + import logging + + logger = logging.getLogger(__name__) + + def get_data(): + try: + data = fetch_sensitive_data() + return {'data': data} + except Exception as e: + logger.error(f"Failed to fetch data: {e}", exc_info=True) + return {'error': 'Data unavailable'}, 500
코드에서 취약점 찾기
Shoulder를 사용하여 코드에서 Unchecked Error Condition 패턴을 스캔하세요. 3 규칙.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=391 # Or scan entire project npx @shoulderdev/cli trust .
탐지 규칙 (3)
코드 리뷰에서 주의할 점
이 패턴은 잠재적인 Unchecked Error Condition 취약점을 나타냅니다. 코드 리뷰와 보안 감사 중에 찾아보세요.
코드베이스를 스캔하세요: Unchecked Error Condition
Shoulder CLI는 전체 코드베이스에서 취약한 패턴을 찾아냅니다.