Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-57350

ShardKeyPattern::parseShardKeyPattern() - NaN representation is being cast to integer

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.4, 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v5.0
    • Execution Team 2021-06-14
    • 43

      On bsonelement.h an unsafe cast is being done that could end up in a situation where NaN (which representation according to the EcmaScript specification is 9007199254740990) is being casted to an integer, the following example can cause such situation:

      let st = new ShardingTest({mongos:1, shards:1});
      st.s.adminCommand({enableSharding: 'db'});
      st.s.adminCommand({shardCollection: 'db.test', key: { _id: NaN }});
      

      Here when passing the index we end up trying to get the number which does the cast. This causes failures on the fuzzer tests as can be seeing in the linked BF.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            marcos.grillo@mongodb.com Marcos José Grillo Ramirez
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: