The vulnerability stems from the BSON parser's handling of code-with-scope objects (type 15) in the get_value function. The commit diff shows critical fixes to size validation logic:
- Added 'len' variable to track total expected size
- Introduced 'len < code_size' check to prevent integer underflow/overflow
- Combined scope_size validation with BSON_MIN_SIZE check
- Added length consistency checks between components
These changes address the core issue where crafted payloads could bypass size checks through:
- Invalid code_w_scope length calculations
- Mismatched scope_size validations
- Missing overflow protection
The PoC demonstrates exploitation by manipulating these size fields to trigger OOB reads through exception messages containing adjacent memory contents.