CWE-147
Weakness AllowedImproper Neutralization of Input Terminators
Abstraction: Variant · Status: Draft
The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as input terminators when they are sent to a downstream component.
Technical nuance
For example, a "." in SMTP signifies the end of mail message data, whereas a null character can be used for the end of a string.
Mapping guidance
This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.
Modes of introduction
Content history
updated Potential_Mitigations, Time_of_Introduction
updated Relationships, Taxonomy_Mappings
updated Description
updated Description, Name
updated Potential_Mitigations
updated Description, Name
updated Potential_Mitigations
updated Common_Consequences
updated Common_Consequences
updated Related_Attack_Patterns, Relationships
updated Potential_Mitigations
updated Relationships, Taxonomy_Mappings
updated Potential_Mitigations
updated Applicable_Platforms
updated Potential_Mitigations, Relationships
updated Potential_Mitigations, Relationships
updated Description, Potential_Mitigations
updated Relationships
updated Mapping_Notes
updated Weakness_Ordinalities
updated Description, Technical_Nuance
11 vulnerabilities reference this CWE, most recent first.
GHSA-QC36-Q22Q-CJW3
Vulnerability from github – Published: 2021-07-12 17:03 – Updated: 2021-08-18 18:52Impact
Affected versions of lettre allowed SMTP command injection through an attacker's controlled message body. The module for escaping lines starting with a period wouldn't catch a period that was placed after a double CRLF sequence, allowing the attacker to end the current message and write arbitrary SMTP commands after it.
Fix
The flaw is fixed by correctly handling consecutive CRLF sequences.
References
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "lettre"
},
"ranges": [
{
"events": [
{
"introduced": "0.7.0"
},
{
"fixed": "0.9.6"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-38189"
],
"database_specific": {
"cwe_ids": [
"CWE-147"
],
"github_reviewed": true,
"github_reviewed_at": "2021-06-01T20:41:39Z",
"nvd_published_at": "2021-08-08T06:15:00Z",
"severity": "CRITICAL"
},
"details": "### Impact\n\nAffected versions of lettre allowed SMTP command injection through an attacker\u0027s controlled message body. The module for escaping lines starting with a period wouldn\u0027t catch a period that was placed after a double CRLF sequence, allowing the attacker to end the current message and write arbitrary SMTP commands after it.\n\n### Fix\n\nThe flaw is fixed by correctly handling consecutive CRLF sequences.\n\n### References\n\n* [RUSTSEC-2021-0069](https://rustsec.org/advisories/RUSTSEC-2021-0069.html)\n\n\n\n",
"id": "GHSA-qc36-q22q-cjw3",
"modified": "2021-08-18T18:52:26Z",
"published": "2021-07-12T17:03:27Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/lettre/lettre/security/advisories/GHSA-qc36-q22q-cjw3"
},
{
"type": "WEB",
"url": "https://github.com/lettre/lettre/pull/627/commits/93458d01fed0ec81c0e7b4e98e6f35961356fae2"
},
{
"type": "WEB",
"url": "https://github.com/lettre/lettre/commit/8bfc20506cc5e098fe6eb3d1cafe3bea791215ce"
},
{
"type": "PACKAGE",
"url": "https://github.com/lettre/lettre"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2021-0069.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "SMTP command injection in lettre"
}
Mitigation
Developers should anticipate that terminators 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.
Mitigation MIT-5
Strategy: Input Validation
- 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.
Mitigation MIT-28
Strategy: Output Encoding
While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
Mitigation MIT-20
Strategy: Input Validation
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.
CAPEC-460: HTTP Parameter Pollution (HPP)
An adversary adds duplicate HTTP GET/POST parameters by injecting query string delimiters. Via HPP it may be possible to override existing hardcoded HTTP parameters, modify the application behaviors, access and, potentially exploit, uncontrollable variables, and bypass input validation checkpoints and WAF rules.