CWE一覧に戻る
CWE-158

ヌルバイトまたはNUL文字の不適切な中和

Improper Neutralization of Null Byte or NUL Character
脆弱性 作成中
JA

この製品は上流のコンポーネントから入力を受信するが、NUL文字またはNULLバイトが下流のコンポーネントに送信されるときに中和されないか、間違って中和される。

データが解析される際、注入されたNUL文字やヌル・バイトは、入力が実際よりも早く終了したと製品に思わせたり、入力を誤って解釈させたりする可能性がある。これを利用して、ヌル・バイトの後に発生する潜在的に危険な入力を注入したり、検証ルーチンやその他の保護メカニズムをバイパスしたりする可能性がある。

EN

The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes NUL characters or null bytes when they are sent to a downstream component.

As data is parsed, an injected NUL character or null byte may cause the product to believe the input is terminated earlier than it actually is, or otherwise cause the input to be misinterpreted. This could then be used to inject potentially dangerous input that occurs after the null byte or otherwise bypass validation routines and other protection mechanisms.

Scope: Integrity / Impact: Unexpected State
Developers should anticipate that null characters or null bytes will be injected/removed/manipulated in the input vectors of their product. Use an appropriate combination of denylists and allowlists to ensure only valid, expected and appropriate input is processed by the system.
Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.

When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."

Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
MITRE公式ページ — CWE-158