MQ

 View Only

 Limit permissions from remote queue manager

Michał Czeraszkiewicz's profile image
Michał Czeraszkiewicz posted Tue February 18, 2025 02:47 AM

I have two queue managers Q2 (receiver) and Q3 (sender). I would like to limit Q3 to put messages only to specific queue on Q2.

On Q2 I specify the following objects

```

* create local queues
DEFINE QLOCAL(RECEIVER1.QUEUE) DESCR('Messages from QM1') REPLACE
SET AUTHREC PROFILE(RECEIVER1.QUEUE) PRINCIPAL('qm1') OBJTYPE(QUEUE) AUTHADD(PUT)
DEFINE QLOCAL(RECEIVER3.QUEUE) DESCR('Messages from QM3') REPLACE
SET AUTHREC PROFILE(RECEIVER3.QUEUE) PRINCIPAL('qm3') OBJTYPE(QUEUE) AUTHADD(PUT)
SET CHLAUTH(SENDER3.TO.RECEIVER2) TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(NOACCESS) +
DESCR('Default block all') WARN(NO) ACTION(REPLACE)
* map CN to user
SET CHLAUTH(SENDER3.TO.RECEIVER2) +
TYPE(SSLPEERMAP) SSLPEER('CN=mq-3.net.local') SSLCERTI('CN=net.local') +
DESCR('Map to user qm3 based on CN') +
USERSRC(MAP) MCAUSER('qm3') ACTION(REPLACE)
* create receiver channel SENDER3.TO.RECEIVER2
DEFINE CHANNEL(SENDER3.TO.RECEIVER2) CHLTYPE(RCVR) +
TRPTYPE(TCP) SSLCIPH(ANY_TLS13_OR_HIGHER) +
SSLCAUTH(REQUIRED) SSLPEER('CN=mq-3.net.local') +
MCAUSER('qm3') PUTAUT(CTX) +
REPLACE
STOP CHANNEL(SENDER3.TO.RECEIVER2)
START CHANNEL(SENDER3.TO.RECEIVER2)
```
On Q2 I specify the following objects
```
* sender transmission queue
DEFINE QLOCAL(SENDER.TQ) USAGE(XMITQ) +
DESCR('Sender transmission queue') +
TRIGGER TRIGTYPE(DEPTH) TRIGDPTH(2) +
TRIGDATA(SENDER3.TO.RECEIVER2) INITQ(SYSTEM.CHANNEL.INITQ) +
REPLACE

* sender remote queue
DEFINE QREMOTE(SENDER.QUEUE) RNAME(RECEIVER1.QUEUE) RQMNAME(QM2) XMITQ(SENDER.TQ) +
DESCR('Remote queue') +
REPLACE

* create sender channel
DEFINE CHANNEL(SENDER3.TO.RECEIVER2) CHLTYPE(SDR) CONNAME('mq-2.net.local(1414)') +
DESCR('Sender channel to QM2') +
SSLCIPH(ANY_TLS13_OR_HIGHER) SSLPEER('CN=mq-2.net.local') +
XMITQ(SENDER.TQ) TRPTYPE(TCP) REPLACE
```
Because on the configuration on QM2 I would expect Q3 to not be able to send messages to `RECEIVER1.QUEUE`.
When I create a message via the Web UI on Q3 (see screenshot) in `SENDER.QUEUE`, the message "lands" on `RECEIVER1.QUEUE` (Q2) with User ID set to unknown (see screenshot).
Please suggest changes.
Morag Hughson's profile image
Morag Hughson IBM Champion

Hi Michael,

What you describe does make it sound like the PUTAUT(CTX) setting has not been picked up by the channel. I am curious about the part of your script that does:-

STOP CHANNEL(SENDER3.TO.RECEIVER2)
START CHANNEL(SENDER3.TO.RECEIVER2)

I assume that perhaps you have a script that you have been gradually developing and that is why you have this - to stop the previously running channel and then restart it to allow it to get the new definition. I wonder if this might mean that the PUTAUT(CTX) setting has not been picked up because perhaps, because these two commands are so close together, that the channel might not have actually been stopped. 

If you issue a start channel too rapidly after a stop channel, if the channel has not yet stopped, it will just cancel the stop. This of course, is not what you want in your case.

Can I get you to try to manually stop the channel, and use channel status to make sure it has really stopped - i.e. no longer running at either end, and then start it up again and see if it still shows the same behaviour.

Cheers,
Morag

bruce2359's profile image
bruce2359

At the sender side qmgr, access to the transmission queue is through the QRemote definition.

Are you running your test (with the WebUI) as administrator?  If so, your admin userid has all admin authority to all local objects on the sender side qmgr - specifically the QREMOTE(SENDER.QUEUE) definition.  Try running a test with a non-admin userid.  Post your results here.

 “…message "lands" on `RECEIVER1.QUEUE` (Q2) with User ID set to unknown …”.  Please be precise. What do you mean by ‘unknown’?  Use amqsbcg or some other utility to post here the MQMD of the message. 

YVES MOYROUD's profile image
YVES MOYROUD

Hi Michal,
if you are on Linux or AIX, have SecurityPolicy=group, and if users qm1 and qm3 belong to the same primary group, then they share their authorities.
You might check with amqoamd or similar :
```
# authorities on RECEIVER1.QUEUE for all entities
amqoamd -m Q2 -n RECEIVER1.QUEUE -t queue
```

Neil Casey's profile image
Neil Casey

Hi Michal,

If you are trying to establish an effective solution to limiting access across a receiver channel, PUTAUT(CTX) is not secure in the general case. Anyone with sufficient access to the sender queue manager is able to override the UserIdentifier on the message as it's just part of context. They can then use that ability to attack your queue manager (for example by asserting mqm as their UserIdentifier on a Linux system).

A more secure technique is to secure the channel using PUTAUT(DEF) and ensure that the channel is dedicated to the sending queue manager and is authenticated securely (for example with mutual TLS). Access to queue on the receiver end is then granted to the MCAUSER on the channel (which has to be set to a user with low privileges, not 'mqm' or blank.

You've done all of these things from the channel perspective, but because you set PUTAUT(CTX) instead of PUTAUT(DEF) the security check for opening the queue for output on the receiver queue manager is NOT 'qm3'. It's whatever user was active (or asserted by the program if authorized) on the sending queue manager, as received by the receiving queue manager in the UserIdentifier field in the message context.

Although it is based on MQ 7.5 and so is now sadly out of date, the Redbook Secure Messaging Scenarios with WebSphere MQ (https://www.redbooks.ibm.com/abstracts/sg248069.html) describes the security exposure associated with PUTAUT(CTX) which still exists.

Regards,

Neil Casey

bruce2359's profile image
bruce2359

I'm a bit confused, Michal.  You say that the WebUI successfully created a message, that the message was forwarded from the originating qmgr across the SDR-RCVR channel, and that the message arrived in the named destination queue.  What results were you expecting?  Did you expect the WebUI would get a failed completion code or a not-authorized reason code?  Were you expecting something else?  Is your only complaint here that the message User ID set to unknown?