The vulnerability exists in the MongoDB protocol parser of the OpenTelemetry eBPF instrumentation agent. The parser fails to properly validate the structure and length of incoming MongoDB wire messages before processing them. This allows a remote, unauthenticated attacker to send a specially crafted message that triggers an uncaught panic, leading to a process crash and a denial of service.
Three distinct vulnerable functions were identified:
parseOpMessage: This function was susceptible to a slice-out-of-bounds panic because it did not validate the buffer length before reading message flag bits. The fix involves adding a length check at the beginning of the function.
parseSections: Similarly, this function could panic with a slice-out-of-bounds error when parsing document sequences, as it didn't re-validate the buffer length before reading the sequence size. The fix adds the necessary length check.
parseFirstField: This function contained a fragile type assertion, assuming a BSON field's value was always a string. A malformed BSON document with a different type would cause a runtime panic. The fix for this, not present in the analyzed commit but in a later version, would involve safely checking the type before asserting it.
An attacker exploiting any of these flaws can terminate the telemetry agent, causing a loss of observability until the agent is manually restarted.