# Improper Handling of Unicode Encoding (CWE-176) The product does not properly handle when an input contains Unicode encoding. **Stack:** Python - Prevalence: Moyenne 3 langages couverts - Impact: Moyen Revue recommandée - Prevention: Documentée 3 exemples de correctifs **OWASP:** Injection (A03:2021-Injection) - #3 ## Description 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. ## Prevention Stratégies de prévention pour Improper Handling of Unicode basées sur 1 règles de détection Shoulder. ### Python Normalize Unicode strings with NFKC before comparison or security-critical operations ## Warning Signs - [MEDIUM] missing Unicode normalization leading to security bypasses ## Consequences - Contourner le mécanisme de protection - Exécuter du code non autorisé ## Mitigations - Normalisez les entrées Unicode en forme canonique avant traitement - Appliquez les contrôles de sécurité après la normalisation Unicode - Utilisez des fonctions de comparaison qui prennent en compte Unicode ## Detection - Total rules: 3 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Unicode Normalization Issues** [MEDIUM]: Detects missing Unicode normalization leading to security bypasses. - Remediation: Normalize Unicode strings before comparison using unicodedata.normalize(). ```python import unicodedata def normalize_username(username): return unicodedata.normalize('NFKC', username).lower() if normalize_username(input_name) == normalize_username(stored_name): grant_access() ``` Learn more: https://shoulder.dev/learn/python/cwe-176/unicode-normalization