MQ

 View Only
Expand all | Collapse all

Protecting IBM MQ key repositories

  • 1.  Protecting IBM MQ key repositories

    IBM Champion
    Posted Tue August 16, 2022 08:17 PM

    MQ Client 9.3 on Windows 10.  The keystore has a private key. A stash file is in use to avoid having to enter the password to the keystore dozens of times a day.

    How can we protect this better? No jokes about just avoid Windows, dealing with it is a fact of life in Corporate America.

    This link is "the" official info I suppose.
    Protecting IBM MQ key repositories - IBM Documentation
    Meh.

    Is there anyway to make the MQ Client work if the stash file is located in some other location? That would help a little as then both the keystore and the means to get into it are not co-located.
    If yes, then presumably the client could further say the remote location of the stash file could be a physical device plugged into a USB, making access to the keystore impossible without knowing the password or possessing the physical device that houses the stash file.

    Thinking out loud.....And/or a way to make that keystore/stash combo only viable if executing on the specific O/S instance that was used during the CSR when the key was created?

    Other than relying on folder permissions, what else can be done? I just look at that keystore and its stash file, ready to be scooped up by a bad guy to be used on another system to assert the identity tied to that private key/cert. And all that stands in the way is Windows permissions. 


    ------------------------------
    Peter Potkay
    ------------------------------


  • 2.  RE: Protecting IBM MQ key repositories

    Posted Wed August 17, 2022 04:17 AM

    Hi Peter,

    > Is there anyway to make the MQ Client work if the stash file is located in some other location?
    Unfortunately not, MQ is hardcoded to look for a stash file in the same location as the keystore and with the same name (just a .sth extension).

    > Thinking out loud.....And/or a way to make that keystore/stash combo only viable if executing on the specific O/S instance that was used during the CSR when the key was created?
    sorry, but again also not possible. The stash file provided by GSKit doesn't link with the OS/folder so as long as it's a stash file containing the obsfucated password then it can be used to open the keystore anywhere (as long as you're using GSKit's/MQ's tools).

    > Other than relying on folder permissions, what else can be done?
    Are you aware of the alternative to Stash files that was added in MQ 9.3? We added the ability to provide the keystore password either programmatically or encrypted using the IBM MQ password protection system. If you modified your application to provide it programmatically then you could do a lot of the things above you want to do, like storing it remotely or even requesting it from a store such as hashicorp vault. If you can't provide it programmatically then you could look into storing the password with the Password Protection system. You would still need to store the password (and the initial key that is used to encrypt the password) but these can be split apart away from the keystore and even if an attacker obtains the encrypted password and initial key they shouldn't be able to open your keystore without knowing how to go from initial key -> encryption key.
    This page talks about the password protection system: https://www.ibm.com/docs/en/ibm-mq/9.3?topic=securing-protecting-passwords-in-mq-component-configuration-files
    This page talks about supplying a keystore password: https://www.ibm.com/docs/en/ibm-mq/9.3?topic=wsalw-supplying-key-repository-password-mq-mqi-client-aix-linux-windows

    Let me know if this helps!



    ------------------------------
    Rob Parker
    Security Focal, IBM MQ
    IBM UK Ltd
    ------------------------------



  • 3.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Mon August 22, 2022 05:57 PM

    Hi Rob,
    Thanks for the info, I was not yet aware of this. So yes its a step in the right direction to allow this to work without a stash file. It looks like the stash file can be replaced with an encrypted password along with the key used to encrypt that password.  So we've traded a stash file that must not be compromised to the key used to encrypt/decrypt the password that must not be compromised. 

    Rob wrote>> "You would still need to store the password (and the initial key that is used to encrypt the password) but these can be split apart away from the keystore and even if an attacker obtains the encrypted password and initial key they shouldn't be able to open your keystore without knowing how to go from initial key -> encryption key."

    So the fact that the encrypt/decrypt key can live somewhere else is the improvement over the stash file that must be co located with the keystore. OK, that is a little better, a little more complicated for the bad actor. I did not understand this part: "....without knowing how to go from initial key -> encryption key."

    Isn't the initial key the same as the encryption key the same as the decryption key? I guess I don't understand the details about this key yet. What kind of key? This key file(?) must be available to runmqicred at set up time and the same file must be available to your MQ app at runtime to allow access your certificate keystore?

    I don't find documentation on the runmqicred command in the 9.3 Knowledge Center. I see multiple references to "the IBM MQ Password Protection System". Is there an article or presentation that describes this system?



    ------------------------------
    Peter Potkay
    ------------------------------



  • 4.  RE: Protecting IBM MQ key repositories

    Posted Tue August 23, 2022 05:26 AM
    Hi Peter,

    I'm planning on writing a blogpost on the topic of the MQ Password protection system and how it works along with improving the MQ Documentation on this area. For the time being this IBM Doc page tries to provide some information on the password protection system as a whole: https://www.ibm.com/docs/en/ibm-mq/9.2?topic=securing-protecting-passwords-in-mq-component-configuration-files

    It describes the initial key as "The encryption key you provide for use in the encryption process. " but this isn't entirely accurate. We do take and use that key but it's an input for creating the key needed for the encryption algorithm (as you can technically supply an initial key that is 1 character long, although obviously not recommended).

    I'll try and get the Doc page and/or blog post on how the password protection system works written up soon. It's a topic that i imagine will be of some interest to people given there have recently been a number of questions on "How is the GSKit stash file actually protecting the keystore password".

    ------------------------------
    Rob Parker
    Security Architect, IBM MQ Distributed
    IBM UK Ltd
    ------------------------------



  • 5.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Wed August 24, 2022 11:06 AM
    Thanks Rob, I'm looking forward to additional info in this space.

    Right now I think the way this works (not sure) is we provide a character string of our choice for MQ (runmqicred) to use as the key or seed for some internal encryption algorithim shipped with MQ. That along with our plain text password as input reults in output that is the encrypted password.

    We supply the encrypted password to be used for access to our SSL Certificate KDB.

    Then at runtime (MQCONNX) the MQ libraries know to call that same internal encryption algorithim shipped with MQ to decrypt the supplied encrypted password. This is only possible if the runtime is directed to and has access to that same character string of our choice that was used as the key/seed for the initial encryption. Finally the now plain text password is used to access the KDB.

    Basically yes?

    And if yes, protecting access to that character string of our choice that was used as the key/seed for the initial encryption becomes funadmental to the security of the whole solution. But that key/seed can be housed "anywhere" (USB key, Password Vaults?) making it easier to secure than a stash file that has to live exactly next to the KDB its meant to protect?

    Seeing some end to end example scenarios would really help here. Perhaps also a flow chart showing the steps.


    ------------------------------
    Peter Potkay
    ------------------------------



  • 6.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Wed August 24, 2022 11:07 AM
    Thanks Rob, I'm looking forward to additional info in this space.

    Right now I think the way this works (not sure) is we provide a character string of our choice for MQ (runmqicred) to use as the key or seed for some internal encryption algorithim shipped with MQ. That along with our plain text password as input reults in output that is the encrypted password.

    We supply the encrypted password to be used for access to our SSL Certificate KDB.

    Then at runtime (MQCONNX) the MQ libraries know to call that same internal encryption algorithim shipped with MQ to decrypt the supplied encrypted password. This is only possible if the runtime is directed to and has access to that same character string of our choice that was used as the key/seed for the initial encryption. Finally the now plain text password is used to access the KDB.

    Basically yes?

    And if yes, protecting access to that character string of our choice that was used as the key/seed for the initial encryption becomes funadmental to the security of the whole solution. But that key/seed can be housed "anywhere" (USB key, Password Vaults?) making it easier to secure than a stash file that has to live exactly next to the KDB its meant to protect?

    Seeing some end to end example scenarios would really help here. Perhaps also a flow chart showing the steps.

    ------------------------------
    Peter Potkay
    ------------------------------



  • 7.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Fri June 02, 2023 03:56 PM

    Rob,

    You mentioned you were going to write a blogpost on this topic. Is there any more info to share?

    I'm playing around with this. Running the same password into runmqicred on the same MQ Client install gives a different encrypted result each time. This was surprising to me - I assumed same input would produce the same output each time. Using any one of those multiple encrypted outputs (again, all for the same exact input password) worked. Altering even one character in any of them caused it to fail, as expected. I assume the MQ Client install is keeping some internal list of results for every invocation of runmqicred? Where? I assume/hope securely.  In a Redistributable MQ Client install, what happens the next "upgrade" where we delete the entire folder structure of the old version and drop the new version - I'm guessing we have to go thru the runmqicred exercise again for each keystore referenced by that install? Does redoing the runmqicred need to occur anytime any type of MQ upgrade occurs, even the in place upgrades?



    ------------------------------
    Peter Potkay
    ------------------------------



  • 8.  RE: Protecting IBM MQ key repositories

    Posted Mon June 05, 2023 01:55 AM

    "Running the same password into runmqicred on the same MQ Client install gives a different encrypted result each time."

    It probably appends/prepends a random IV to the password before encrypting it.  On decryption, the IV is ignored. 

    It probably also uses a hash/MAC in the encrypted data, to check that a decryption is correct.

    Cheers,



    ------------------------------
    Glenn Baddeley
    Senior Middleware Software Engineer
    Coles Supermarkets Australia Pty Ltd
    ------------------------------



  • 9.  RE: Protecting IBM MQ key repositories