Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
Without strong password requirements, users often choose weak, easily guessable passwords. This makes brute-force and dictionary attacks more likely to succeed.
Como corrigir esta vulnerabilidade
Estratégias de prevenção para Weak Password Requirements baseadas em 2 regras de detecção do Shoulder.
Enforce minimum 12-character passwords with complexity requirements
func validatePassword(password string) error { - if len(password) < 6 { - return errors.New("too short") + if len(password) < 12 { + return errors.New("password must be at least 12 characters") + } + var hasUpper, hasLower, hasDigit, hasSpecial bool + for _, c := range password { + switch { + case unicode.IsUpper(c): hasUpper = true + case unicode.IsLower(c): hasLower = true + case unicode.IsDigit(c): hasDigit = true + case unicode.IsPunct(c) || unicode.IsSymbol(c): hasSpecial = true + } + } + if !hasUpper || !hasLower || !hasDigit || !hasSpecial { + return errors.New("password must include upper, lower, digit, and special char") } return nil }
Require minimum 12 characters with complexity checks or use a password strength library
- if (password.length < 6) { - throw new Error('Password too short'); + const zxcvbn = require('zxcvbn'); + + if (password.length < 12 || zxcvbn(password).score < 3) { + throw new Error('Password too weak'); }
Encontre vulnerabilidades no seu código
Use o Shoulder para escanear seu código em busca de padrões Weak Password Requirements. 2 regras.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=521 # Or scan entire project npx @shoulderdev/cli trust .
Regras de Detecção (2)
O que observar nas revisões de código
Estes padrões indicam vulnerabilidades potenciais de Weak Password Requirements. Procure-os durante revisões de código e auditorias de segurança.
Escaneie seu código para Weak Password Requirements
O Shoulder CLI encontra padrões vulneráveis em todo o seu código.