Weak Password Recovery Mechanism for Forgotten Password
The product contains a mechanism for users to recover or change their passwords without knowing the original password, but the mechanism is weak.
Weak password recovery mechanisms can be exploited to take over user accounts. Common issues include predictable reset tokens, security questions with easily guessable answers, or lack of verification.
इस भेद्यता को कैसे ठीक करें
3 Shoulder डिटेक्शन नियमों पर आधारित Weak Password Recovery के लिए रोकथाम रणनीतियाँ।
Use crypto/rand with 32+ bytes of entropy for password reset tokens
- func generateResetToken() string { - return fmt.Sprintf("%d", time.Now().Unix()) + import ( + "crypto/rand" + "encoding/hex" + ) + + func generateResetToken() (string, error) { + b := make([]byte, 32) + if _, err := rand.Read(b); err != nil { + return "", err + } + return hex.EncodeToString(b), nil }
Use crypto.randomBytes() instead of Math.random() for security tokens
- user.resetToken = Math.random().toString(36); + const crypto = require('crypto'); + user.resetToken = crypto.randomBytes(32).toString('hex'); await user.save();
Use the secrets module for cryptographically secure token generation
- import random - - def create_reset_token(): - chars = 'abcdef0123456789' - reset_token = ''.join(random.choice(chars) for _ in range(32)) - return reset_token + import secrets + + def create_reset_token(): + return secrets.token_urlsafe(32)
अपने कोड में भेद्यताएँ खोजें
Weak Password Recovery Mechanism for Forgotten Password पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 3 नियम.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=640 # Or scan entire project npx @shoulderdev/cli trust .
पहचान नियम (3)
कोड समीक्षा में किन बातों पर ध्यान दें
ये पैटर्न संभावित Weak Password Recovery Mechanism for Forgotten Password भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।
अपने कोडबेस को इसके लिए स्कैन करें: Weak Password Recovery Mechanism for Forgotten Password
Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।