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

OpMsgRequest::getDatabase() should check type of _msg.body["$db"] before calling valueStringData()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.7
    • Component/s: Networking
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      db.runCommand({$db: 127});
      

      Show
      db.runCommand({$db: 127});
    • Epic Link:
    • Sprint:
      Repl 2017-05-08
    • Linked BF Score:
      0

      Description

      It is possible that the user's request specifies a type other than a string as the $db parameter, so checking the type is necessary to avoid performing an invalid memory access when using the returned StringData later on.

      class OpMsgRequest final : public rpc::RequestInterface {
      public:
          explicit OpMsgRequest(OpMsg msg) : _msg(std::move(msg)) {}
          StringData getDatabase() const override {
              if (auto db = _msg.body["$db"]) {
                  return db.valueStringData();
              }
              return "admin";
          }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: