[SERVER-27426] validateBSON should assert that Array elements have indexes from 0...n Created: 14/Dec/16  Updated: 27/Jun/22  Resolved: 17/Mar/20

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Spencer Jackson Assignee: Spencer Jackson
Resolution: Won't Do Votes: 0
Labels: gm-ack, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by SERVER-12204 Buffer::readUTF8String in bson_valida... Closed
Sprint: Platforms 2017-12-18, Platforms 2018-01-01, Platforms 2018-01-15, Security 2020-02-10, Security 2020-02-24, Security 2020-03-09, Security 2020-03-23
Participants:

 Description   

According to the BSON spec, "The document for an array is a normal BSON document with integer values for the keys, starting with 0 and continuing sequentially". Currently, we validate BSON in validateBSON. validateBSON treats arrays exactly like nested BSON. We should add an additional check, which verifies that the first index is '0', and each subsequent key is sequential.



 Comments   
Comment by Spencer Jackson [ 17/Mar/20 ]

See SERVER-12204 for additional details about why adding this check, and changing what valid BSON is, is hard.

It is feasible to assert properties about Array elements during command parse. But it is not as feasible during BSON validation. As such, I will be closing this ticket.

Comment by Gregory McKeon (Inactive) [ 29/Jan/18 ]

Needs perf testing/additional time, so pushing back to a future sprint.

Generated at Thu Feb 08 04:15:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.