envoy icon indicating copy to clipboard operation
envoy copied to clipboard

printing non-utf8 string from metadata crashes Envoy (when trace enabled)

Open stevenzzzz opened this issue 3 years ago • 2 comments

Title: printing non-utf8 string from metadata crashes Envoy (when trace enabled)

Description: envoy/http/metadata_interface.h seems assume that metadata K:V are in utf8 strings:

class MetadataMap : public UnorderedStringMap {
public:
  using UnorderedStringMap::UnorderedStringMap;

  friend std::ostream& operator<<(std::ostream& out, const MetadataMap& metadata_map) {
    out << "metadata map:";
    for (const auto& metadata : metadata_map) {
      out << "\nkey: " << metadata.first << ", value: " << metadata.second << std::endl;
    }
    return out;
  }
};

But seems no such constraint in spec for metadata.

We should at least eacape the K:V before passing them into spdglog which expects utf8 string. https://github.com/abseil/abseil-cpp/blob/master/absl/strings/escaping.h

Repro steps:

  1. Enable trace logging in Envoy,
  2. put some protobuf::serializeAsString() as stream metadata value.

Envoy will crash when the serializeAsString() contains invalid utf8 string, while spdlog tries to interpret the value as an utf8 string.

stevenzzzz avatar Aug 08 '22 16:08 stevenzzzz

assign to @yanavlasov for triaging. /assign @yanavlasov

stevenzzzz avatar Aug 08 '22 16:08 stevenzzzz

cc @adisuissa

stevenzzzz avatar Aug 08 '22 16:08 stevenzzzz

/assign stevenzzzz

stevenzzzz avatar Aug 15 '22 22:08 stevenzzzz

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 15 '22 00:09 github-actions[bot]

the fix is in.

stevenzzzz avatar Sep 15 '22 14:09 stevenzzzz