[SERVER-49334] IDL generated parsers do not validate that the input element is a BSON array for attributes of type array<type> Created: 07/Jul/20  Updated: 19/Oct/20  Resolved: 19/Oct/20

Status: Closed
Project: Core Server
Component/s: IDL
Affects Version/s: 4.5 Desired
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mindaugas Malinauskas Assignee: Garaudy Etienne
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:
  1. Define an attribute of an object in *.idl file like below.

     
    cursors:
        description: "An array of cursor IDs to be killed."
        type: array<cursorId>
        cpp_name: cursorIds
        optional: false
    

  2. Pass an array-like object as a value of the field:

    cursors:{
     '0': 10000,
     '1': 20000
    }
    

  3. The object is successfully parsed.
Participants:

 Description   

IDL generated parsers do not validate that the input element is a BSON array for attributes of type array<type>. The parsers do accept both - BSON arrays and objects with array layout (please see Steps To Reproduce for an example). Expected behavior is that only BSON arrays are accepted.



 Comments   
Comment by Garaudy Etienne [ 19/Oct/20 ]

mark.benvenuto Unless something bad happens here, we're not leaving this be.

Comment by Mark Benvenuto [ 14/Jul/20 ]

I am not aware of anything going wrong because we allow array-like objects as arrays.

Comment by Garaudy Etienne [ 14/Jul/20 ]

mark.benvenuto Did anything go wrong as a result of allowing array-like objects to pass as arrays? 

Comment by Mark Benvenuto [ 07/Jul/20 ]

This behavior is actually permitted by the IDL parser (https://github.com/mongodb/mongo/blob/09d7df7e8c53c593c254f589611931226a423ae9/src/mongo/idl/idl_test.cpp#L990-L1006). We will have to adjust the tests when the behavior is changed.

Generated at Thu Feb 08 05:19:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.