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

    Posted Mon June 05, 2023 03:45 AM

    Hi Peter,

    Sorry the blog post on this topic has been a long standing item on my TODO list that i haven't been able to find time to action.

    As Glenn says below, the reason you get a different output each time you encrypt the same plaintext password is because each time we use a random IV when encrypting the plaintext.

    I can't go into too much detail as I'm still awaiting approval on how much we can share in a public space but i will say that everything that MQ needs to be able to decrypt a password later is included with the MQ installation and encryption string. 

    If you take that string and use it in another installation then it should be compatible so long as you aren't using it with a different "component" and you have ensured you're passing in the same initial key. By component i mean the passwords encrypted with runmqicred cannot be used with AMS, for those you should use runamscred.

    In the future this could change and a later version of MQ may not be able to use an older encrypted password. In those cases we would let everyone know and the procedure would be to re-encrypt your passwords. But for now, the encrypted passwords should be useable between platforms, versions and installations.



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



  • 10.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Mon June 05, 2023 06:21 AM

    Hi Rob,

    I'm glad this topic has been started - I've been trying to automate the creation and storing of the TLS truststore password that MQ explorer uses - is that possible?? I've got plenty of ways to create the passwd (this being another) but no way to store the password in the MQExplorer config that I'm aware of - any clues? 

    thanks

    John.



    ------------------------------
    John Hawkins
    Integration Consultant
    ------------------------------



  • 11.  RE: Protecting IBM MQ key repositories

    IBM Champion
    Posted Tue August 23, 2022 05:09 AM
    I always thought having a stash file on midrange was not a good way of doing it - but hard to think of a better solution.  As well as making it secure you need to consider your corporate backup strategy may well be making a copy of your key related files, and people in the corporate backup team may be able to access your files.

    I use a USB Hardware Security Module (HSM) from Nitrokey (there are others).  Search for COLINPAICE HSM for example of using it with MQ.

    When I went to visit a "secure" site in the the US, the staff used their badge for door access, and laid it on a badge reader besides their computer to give them access to their screen.  If they moved away from their desk the screen locked up. 
    I believe it also had a keystore on it.  This may be a bit extreme(too secure) for you. Depends if you want to secure the terminal or person.

    You also need to consider your DR/fallback site.  You lose your main site, how do you get your keys back when you move to the alternate site.
    With the HSM,its contents can be encrypted, and backed up, so when you get to your DR site, you download your HSM, and have one or more people enter their parts of the decryption key (a one of operation) to become operational.

    With any solution where you download a file ( stash key) from a remote server, you have a similar problem.   You can download it over a TLS channel, but how do you authenticate with the remote server ?  if you use certificate authentication - your keystore has a stash file. (chicken/egg problem)  If you just have a userid and password - this is not as secure, as your password can be compromised.  Do you want people to enter their password every time they start a connection?  How about applications that run without a human?

    ------------------------------
    Colin Paice
    ------------------------------



  • 12.  RE: Protecting IBM MQ key repositories

    Posted Mon June 05, 2023 02:02 AM

    Colin wrote:

    "I always thought having a stash file on midrange was not a good way of doing it - but hard to think of a better solution. "

    Indeed, credential storage is a difficult problem in general.  Access to the MQ SSLKEYR files can be locked down, and excluded from backups. In some ways, this is better than the password existing elsewhere (eg. stored & supplied by an application) that is beyond control of the queue manager. This increases exposure and attack vectors.



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