Skip to content
OpenAdvisories

Weakness (CWE)

CWE-116: Improper Encoding or Escaping of Output

Class Draft

The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.

How to prevent it (7 mitigations)
  1. Architecture and Design

    Use 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.

    Alternately, use built-in functions, but consider using wrappers in case those functions are discovered to have a vulnerability.

  2. Architecture and Design

    If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.

    For example, stored procedures can enforce database query structure and reduce the likelihood of SQL injection.

  3. Architecture and Design, Implementation

    Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies.

  4. Architecture and Design

    In some cases, input validation may be an important strategy when output encoding is not a complete solution. For example, you may be providing the same output that will be processed by multiple consumers that use different encodings or representations. In other cases, you may be required to allow user-supplied input to contain control information, such as limited HTML tags that support formatting in a wiki or bulletin board. When this type of requirement must be met, use an extremely strict allowlist to limit which control sequences can be used. Verify that the resulting syntactic structure is what you expect. Use your normal encoding methods for the remainder of the input.

  5. Architecture and Design

    Use input validation as a defense-in-depth measure to reduce the likelihood of output encoding errors (see CWE-20).

  6. Requirements

    Fully specify which encodings are required by components that will be communicating with each other.

  7. Implementation

    When exchanging data between components, ensure that both components are using the same character encoding. Ensure that the proper encoding is applied at each interface. Explicitly set the encoding you are using whenever the protocol allows you to do so.

Source: MITRE CWE-116

6 results · Clear filters · Feed

  • Medium 5.3
    CVE-2026-94545 Public exploit

    Satori-generated SVG has improper escaping

    Satori is a library to convert HTML and CSS to SVG. Starting in version 0.0.27 and prior to version 0.33.5, Satori does not properly escape certain values before including them in generated SVG output. This can allow crafted values to be interpreted as SVG ma…

  • Medium 6.3
    CVE-2026-49844 Public exploit

    Apache Log4j API: Improper serialization of non-finite floating-point values in MapMessage.asJson()

    Improper encoding of non-finite floating-point values during MapMessage JSON serialization in Apache Log4j API produces output that is not valid JSON. This issue affects Apache Log4j API versions 2.13.1 through 2.25.4 and version 2.26.0. The fix for CVE-2026-…

  • Medium 4.6
    CVE-2026-33657 Public exploit

    EspoCRM: Stored HTML injection in email notifications about stream notes via unescaped post field

    EspoCRM is an open source customer relationship management application. Versions 9.3.3 and below have a stored HTML injection vulnerability that allows any authenticated user with standard (non-administrative) privileges to inject arbitrary HTML into system-g…

  • Medium 5.3
    CVE-2024-50629 Public exploit EPSS 35%

    Improper encoding or escaping of output vulnerability in the webapi component in Synology BeeStation OS (BSM) before 1.…

  • Medium 5.4
    CVE-2024-39929 Public exploit EPSS 41%

    Exim through 4.97.1 misparses a multiline RFC 2231 header filename, and thus remote attackers can bypass a $mime_filena…

  • Medium 4.9
    CVE-2023-5968 Public exploit

    Password hash in response body after username update

    Mattermost fails to properly sanitize the user object when updating the username, resulting in the password hash being included in the response body.