目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1000

100.0%

CWE-838 输出上下文语义编码不恰当 类漏洞列表 3

CWE-838 输出上下文语义编码不恰当 类弱点 3 条 CVE 漏洞汇总,含 AI 中文分析。

CWE-838属于输出编码不当漏洞,指产品生成输出时指定的编码与下游组件预期的编码不一致。攻击者利用此差异,诱导下游组件以错误方式解码数据,从而引发数据篡改、注入攻击或系统异常。开发者应避免此问题,需严格确保输出编码与接收方预期一致,并在传输前进行编码验证与标准化处理,以保障数据完整性与安全性。

MITRE CWE 官方描述
CWE:CWE-838 输出上下文中的不适当编码 英文:The product uses or specifies an encoding when generating output to a downstream component, but the specified encoding is not the same as the encoding that is expected by the downstream component. 译文:产品在向下游组件生成输出时使用或指定了一种编码,但指定的编码与下游组件预期的编码不一致。 这种弱点可能导致下游组件使用一种解码方法,从而产生与产品意图发送的数据不同的数据。当使用了错误的编码——即使是非常相近的编码——下游组件可能会错误地解码数据。当控制与数据之间的边界被无意破坏时,这可能会带来安全后果,因为生成的数据可能会引入产品未发送的控制字符或特殊元素。生成的数据随后可能被用于绕过输入验证等保护机制,并启用注入攻击。虽然使用输出编码对于确保组件之间的通信准确无误至关重要,但使用错误的编码——即使是非常相近的编码——可能导致下游组件误解输出。例如,HTML实体编码用于网页HTML主体中的元素。然而,程序员在生成用于HTML标签属性中的输出时可能会使用实体编码,这可能会包含不受HTML编码影响的JavaScript代码。虽然Web应用程序因这一问题受到了最多的关注,但这种弱点可能适用于任何使用支持多种编码的通信流的产品类型。
常见影响 (1)
Integrity, Confidentiality, AvailabilityModify Application Data, Execute Unauthorized Code or Commands
An attacker could modify the structure of the message or data being sent to the downstream component, possibly injecting commands.
缓解措施 (3)
ImplementationUse context-aware encoding. That is, understand which encoding is being used by the downstream component, and ensure that this encoding is used. If an encoding can be specified, do so, instead of assuming that the default encoding is the same as the default being assumed by the downstream component.
Architecture and DesignWhere possible, use communications protocols or data formats that provide strict boundaries between control and data. If this is not feasible, ensure that the protocols or formats allow the communicating components to explicitly state which encoding/decoding method is being used. Some template frameworks provide built-in support.
Architecture and DesignUse a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, consider using the ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help the programmer encode outputs in a manner less prone to error. Note that some template mechanisms provide built-in support for the approp…
代码示例 (1)
This code dynamically builds an HTML page using POST data:
$username = $_POST['username']; $picSource = $_POST['picsource']; $picAltText = $_POST['picalttext']; ... echo "<title>Welcome, " . htmlentities($username) ."</title>"; echo "<img src='". htmlentities($picSource) ." ' alt='". htmlentities($picAltText) . '" />'; ...
Bad · PHP
"altTextHere' onload='alert(document.cookie)"
Attack
CVE ID标题CVSS风险等级Published
CVE-2024-34006 Moodle 安全漏洞 3.5 -2024-05-31
CVE-2023-5770 Proofpoint Enterprise Protection 安全漏洞 — Proofpoint Enterprise Protection 5.3 Medium2024-01-09
CVE-2020-7292 McAfee Web Gateway 安全漏洞 — McAfee Web Gateway (MWG) 4.3 Medium2020-07-15

CWE-838(输出上下文语义编码不恰当) 是常见的弱点类别,本平台收录该类弱点关联的 3 条 CVE 漏洞。