AI and data stack advisories

Severe, 6 weeks1496Projects326

1496 severe, 6 weeks · 326 projects

DatadogGHSA-rf3p-mg22-qv6w

Malformed unicode header values may throw uncaught exception

Datadog

CVE-2024-38525 · Published Jun 27, 2024

Medium6.2
Fix: upgrade to v0.2.2 or later
GitHub advisory

Summary

When the dd-trace-cpp library fails to extract trace context due to malformed unicode, the library attempts to log the list of audited headers and their values using the nlohmann JSON library. This attempted logging may throw an uncaught exception.

Details

The code that introduced this logging was added in pull request [#72](https://github.com/DataDog/dd-trace-cpp/pull/72) and has been present in versions [v0.1.12](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.1.12), [v0.2.0](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.0), and [v0.2.1](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.1).

For each key and value in the list of audited headers, a nlohmann::json instance is created as follows:

`

stream << nlohmann::json(it->first + ": " + it->second);

`

Here, it->first is the header name and it->second is the value. This code is problematic for several reasons:

  • An exception can be thrown by the JSON library while parsing the input.
  • An exception can be thrown by the implicit call to dump().

Impact

This impacts any downstream applications that rely on dd-trace-cpp for tracing.

Patches

This vulnerability has been patched in dd-trace-cpp version [v0.2.2](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.2) (#132)

Workarounds

  • Filter out header values that are not valid UTF-8 strings

Affected versions

PackageAffectedFixed in
dd-trace-cpp
Product
< v0.2.2v0.2.2
Details and references

### Summary When the `dd-trace-cpp` library fails to extract trace context due to malformed unicode, the library attempts to log the list of audited headers and their values using the `nlohmann` JSON library. This attempted logging may throw an uncaught exception. ### Details The code that introduced this logging was added in pull request [#72](https://github.com/DataDog/dd-trace-cpp/pull/72) and has been present in versions [v0.1.12](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.1.12), [v0.2.0](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.0), and [v0.2.1](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.1). For each key and value in the list of audited headers, a nlohmann::json instance is created as follows: ``` stream << nlohmann::json(it->first + ": " + it->second); ``` Here, `it->first` is the header name and `it->second` is the value. This code is problematic for several reasons: - An exception can be thrown by the JSON library while parsing the input. - An exception can be thrown by the implicit call to `dump()`. ### Impact This impacts any downstream applications that rely on `dd-trace-cpp` for tracing. ### Patches This vulnerability has been patched in `dd-trace-cpp` version [v0.2.2](https://github.com/DataDog/dd-trace-cpp/releases/tag/v0.2.2) (#132) ### Workarounds - Filter out header values that are not valid UTF-8 strings

CVSS 3.1
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Severity from
GitHub (reviewed advisory)

More Datadog advisories

All Datadog