Improper Handling of Unicode Encoding
The product does not properly handle when an input contains Unicode encoding.
Unicode characters can have multiple encodings or representations. If an application does not properly handle Unicode, attackers may be able to bypass security filters or cause unexpected behavior using alternate encodings.
Comment corriger cette vulnérabilité
Stratégies de prévention pour Improper Handling of Unicode basées sur 3 règles de détection Shoulder.
Normalize strings with NFKC before security-sensitive comparisons
- func handler(w http.ResponseWriter, r *http.Request) { - username := r.FormValue("username") - if username == "admin" { + import "golang.org/x/text/unicode/norm" + + func handler(w http.ResponseWriter, r *http.Request) { + username := r.FormValue("username") + normalized := norm.NFKC.String(strings.ToLower(username)) + if normalized == "admin" { grantAdminAccess() } }
Normalize Unicode strings with NFKC before security-sensitive comparisons
app.post('/login', (req, res) => { - if (req.body.username === 'admin') { + const username = req.body.username.normalize('NFKC').toLowerCase(); + if (username === 'admin') { return res.send('Admin access'); } });
Normalize Unicode strings with NFKC before comparison or security-critical operations
- def check_username(input_name, stored_name): - if input_name == stored_name: + import unicodedata + + def check_username(input_name, stored_name): + normalized_input = unicodedata.normalize('NFKC', input_name).lower() + normalized_stored = unicodedata.normalize('NFKC', stored_name).lower() + if normalized_input == normalized_stored: grant_access()
Trouvez les vulnérabilités dans votre code
Utilisez Shoulder pour scanner votre code à la recherche de patterns Improper Handling of Unicode Encoding. 3 règles.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=176 # Or scan entire project npx @shoulderdev/cli trust .
Règles de Détection (3)
Ce qu'il faut surveiller lors des revues de code
Ces patterns indiquent des vulnérabilités potentielles Improper Handling of Unicode Encoding. Recherchez-les lors des revues de code et des audits de sécurité.
Scannez votre base de code pour Improper Handling of Unicode Encoding
Shoulder CLI trouve les motifs vulnérables dans toute votre base de code.