printing non-utf8 string from metadata crashes Envoy (when trace enabled)
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:
- Enable trace logging in Envoy,
- 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.
assign to @yanavlasov for triaging. /assign @yanavlasov
cc @adisuissa
/assign 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.
the fix is in.