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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: 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
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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
              Reporter:
              Marcos José Grillo Ramirez
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: