# Null Byte Interaction Error (Poison Null Byte) (CWE-626) The product does not properly handle null bytes or NUL characters when passing data to other components. - Prevalence: Medium 1 language covered - Impact: High 1 high-severity rules - Prevention: Documented 1 fix examples **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Null byte injection can be used to truncate strings and bypass security checks. For example, a filename check might be bypassed by appending a null byte followed by a different extension. ## Prevention ### Python Remove null bytes and use secure_filename() for user-provided filenames ## Warning Signs - [HIGH] file operations that may be vulnerable to null byte injection ## Consequences - Bypass Protection Mechanism - Execute Unauthorized Code ## Mitigations - Remove or reject null bytes from input - Use functions that handle null bytes properly - Validate input after null byte removal ## Detection - Total rules: 1 - Languages: python ## Rules by Language ### Python (1 rules) - **Null Byte Injection** [HIGH]: Detects file operations that may be vulnerable to null byte injection. - Remediation: Remove null bytes and use secure_filename() for user-provided filenames. ```python from werkzeug.utils import secure_filename safe_name = secure_filename(filename.replace('\x00', '')) ``` Learn more: https://shoulder.dev/learn/python/cwe-626/null-byte-injection