Produce messages of type v3 have offset deltas in each record along with a LastOffsetDelta for the topic/partition set. In investigating an issue with missing offsets, I found a bug in a producer library where it would send multiple records, but leave LastOffsetDelta at 0. This causes various problems including holes in the offsets fetched by the consumer.
As lastOffsetDelta can be computed by looking at the records, it seems like the broker should at least validate the LastOffsetDelta field against the contained records to stop this bad data getting in.
I've attached a decode v3 produce message that was causing the problems, and was accepted by the broker.
Here's a link to the issue in the kafka library we were using which has more context if you need it.