Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-58103 Overview
Square Wire versions before 5.2.0 fail to enforce a recursion limit when parsing nested groups in Protocol Buffer messages. The flaw resides in ByteArrayProtoReader32.kt and ProtoReader.kt, which recursively invoke skipGroup() for each nested group without bounding call depth. A remote attacker can craft a malicious protobuf payload with deeply nested groups to exhaust the Java Virtual Machine (JVM) stack. This causes a StackOverflowError and denial of service in applications that deserialize untrusted protobuf data using Wire. The weakness is tracked as [CWE-674: Uncontrolled Recursion].
Critical Impact
Attackers can crash services parsing untrusted Protocol Buffer messages by sending payloads with excessive nested group depth, triggering unbounded recursion in the Wire runtime.
Affected Products
- Square Wire runtime versions prior to 5.2.0
- Applications using ByteArrayProtoReader32 for protobuf parsing
- Applications using ProtoReader for protobuf parsing
Discovery Timeline
- 2025-03-16 - CVE-2024-58103 published to the National Vulnerability Database (NVD)
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-58103
Vulnerability Analysis
Square Wire is a Protocol Buffers (protobuf) and gRPC implementation for Android, Kotlin, and Java. The parser traverses wire-format messages tag-by-tag and dispatches on the field encoding. When the parser encounters a STATE_START_GROUP tag, it calls skipGroup(tag) to consume the nested group's bytes. skipGroup itself invokes the main read loop, which recurses again whenever another STATE_START_GROUP tag appears inside the group.
Before version 5.2.0, no depth counter guarded this recursive descent. An attacker-supplied message with thousands of nested start-group tags causes recursion to continue until the JVM thread's stack is exhausted. The resulting StackOverflowError terminates the parsing thread and can bring down services that lack adequate error isolation.
Root Cause
The root cause is missing enforcement of a maximum recursion depth in two reader implementations: ByteArrayProtoReader32.kt and ProtoReader.kt. Protocol Buffer group encoding is deprecated but still accepted by Wire for backward compatibility, and the group-skipping path recursed without bound. Any method that invokes the reader on attacker-controlled bytes inherits the flaw.
Attack Vector
The attack is network-reachable and requires no authentication or user interaction. An adversary submits a crafted protobuf payload containing deeply nested start-group tags to any endpoint, queue consumer, or RPC handler that deserializes untrusted messages with a vulnerable Wire version. Parsing fails with a stack overflow, degrading availability.
// Patch: wire-runtime/src/commonMain/kotlin/com/squareup/wire/ByteArrayProtoReader32.kt
// and ProtoReader.kt — enforce recursion limit on nested groups
if (tagAndFieldEncoding == 0) throw ProtocolException("Unexpected tag 0")
val tag = tagAndFieldEncoding shr TAG_FIELD_ENCODING_BITS
when (val groupOrFieldEncoding = tagAndFieldEncoding and FIELD_ENCODING_MASK) {
- STATE_START_GROUP -> skipGroup(tag) // Nested group.
+ STATE_START_GROUP -> {
+ recursionDepth++
+ try {
+ if (recursionDepth > RECURSION_LIMIT) {
+ throw IOException("Wire recursion limit exceeded")
+ }
+ // Nested group.
+ skipGroup(tag)
+ } finally {
+ recursionDepth--
+ }
+ }
STATE_END_GROUP -> {
if (tag == expectedEndTag) return // Success!
throw ProtocolException("Unexpected end group")
Source: GitHub Commit b90e60c
Detection Methods for CVE-2024-58103
Indicators of Compromise
- StackOverflowError exceptions originating from com.squareup.wire.ProtoReader.skipGroup or ByteArrayProtoReader32.skipGroup in application logs
- Repeated parser crashes or thread terminations on endpoints that accept protobuf-encoded input from untrusted sources
- Abnormally large or structurally pathological protobuf payloads arriving at RPC, gRPC, or message-queue consumers
Detection Strategies
- Perform a software composition analysis (SCA) sweep for the com.squareup.wire:wire-runtime dependency and flag any version earlier than 5.2.0
- Instrument protobuf handlers to log and alert on uncaught StackOverflowError and ProtocolException events
- Add fuzz-test cases that submit nested-group payloads to parsing endpoints and observe for crashes
Monitoring Recommendations
- Monitor JVM crash counts, thread restarts, and service availability metrics on hosts that deserialize protobuf traffic
- Track inbound message size and parser latency distributions to surface anomalous payload structures
- Correlate parser exception spikes with source IPs or client identifiers to identify abusive callers
How to Mitigate CVE-2024-58103
Immediate Actions Required
- Upgrade com.squareup.wire:wire-runtime and related Wire artifacts to version 5.2.0 or later across all services
- Audit internal and third-party libraries that transitively depend on Square Wire and update them accordingly
- Wrap protobuf parsing calls in exception handlers that catch Error subtypes so a parser crash does not terminate the host service
Patch Information
The fix was committed in GitHub Commit b90e60c and shipped in Wire 5.2.0. The patch introduces a recursionDepth counter and a RECURSION_LIMIT check that throws IOException("Wire recursion limit exceeded") once the limit is exceeded. Review the full change set in the GitHub Version Comparison 5.1.0 to 5.2.0.
Workarounds
- Place a size limit on inbound protobuf payloads at the ingress layer to reduce the ceiling for nested-group abuse
- Reject or sanitize messages that use deprecated protobuf group encoding where the application protocol does not require it
- Isolate protobuf deserialization in bounded worker threads so a stack overflow in one thread does not cascade across the service
# Gradle: pin wire-runtime to the patched release
# build.gradle.kts
dependencies {
implementation("com.squareup.wire:wire-runtime:5.2.0")
}
# Maven
# <dependency>
# <groupId>com.squareup.wire</groupId>
# <artifactId>wire-runtime</artifactId>
# <version>5.2.0</version>
# </dependency>
# Verify no vulnerable transitive versions remain
./gradlew dependencies | grep wire-runtime
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

