golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.64k stars 1.58k forks source link

protojson: vuln: malicious JSON can trivially induce stack overflow #1583

Closed jhump closed 6 months ago

jhump commented 6 months ago

The binary format has a default recursion depth of 10,000. And that depth is configurable via proto.UnmarshalOptions. But the protojson package has no such limit. So if a schema allows arbitrary depth (such as using a recursive/hierarchical type, mutually recursive types, or open-ended JSON types such as google.protobuf.Value), an attacker can easily trigger a stack overflow, which results in a process crashing. Since a stack overflow is a fatal error, not a panic, it cannot be handled via recover, which. makes this a serious DOS issue.