1 00:00:00,700 --> 00:00:02,300 Okay, hi there everyone, thanks for coming along. 2 00:00:02,980 --> 00:00:04,620 This talk's called MQ Jumping. 3 00:00:05,820 --> 00:00:07,540 For those of you who are not aware of what it's about, 4 00:00:07,680 --> 00:00:10,800 I'm going to be talking about IBM's WebSphere MQ software. 5 00:00:18,640 --> 00:00:20,440 Now, for those people who were at DEF CON last year, 6 00:00:20,540 --> 00:00:24,240 they'll know that I talked about some crazy IBM networking attacks, 7 00:00:24,500 --> 00:00:26,360 looking at some old-fashioned protocols. 8 00:00:27,760 --> 00:00:30,560 I was intending to actually continue looking at them, 9 00:00:30,660 --> 00:00:32,900 but as any pen-testers out there will know, 10 00:00:33,080 --> 00:00:35,240 a client comes along with a request to look at some software, 11 00:00:35,400 --> 00:00:38,340 and you kind of get sidetracked from what you originally thought you were going to be doing. 12 00:00:39,440 --> 00:00:43,080 And it just so happened that the client actually asked me to look at WebSphere MQ. 13 00:00:45,060 --> 00:00:48,340 So, it wasn't like I actually picked some of their IBM products and said, 14 00:00:48,360 --> 00:00:49,380 right, I'm going to have a go at that. 15 00:00:50,040 --> 00:00:53,580 It's more a reflection of the fact that the businesses we work for out there 16 00:00:53,580 --> 00:00:55,960 are running IBM technology, and they asked me to look at it. 17 00:01:01,680 --> 00:01:04,440 So, for those of you who don't know who I am, my name is Martin Rooks. 18 00:01:04,520 --> 00:01:07,120 I work for MWR Info Security over in the UK. 19 00:01:08,680 --> 00:01:11,540 And I don't have a background in IBM computing at all. 20 00:01:11,640 --> 00:01:15,620 I've approached this subject purely as a pen-tester and a security consultant. 21 00:01:16,220 --> 00:01:18,400 I got asked by a client to look at some software, 22 00:01:19,000 --> 00:01:23,660 and then just started taking it apart the same way that I'm sure many of you guys out there would do. 23 00:01:25,940 --> 00:01:26,340 So, I'm going to talk about IBM. 24 00:01:26,360 --> 00:01:29,000 And just so I can try and understand what kind of audience we've got here, 25 00:01:29,060 --> 00:01:34,560 can I get a show of hands as to who here has MQ on their network, admins it, runs it? 26 00:01:36,020 --> 00:01:36,740 Okay, cool. 27 00:01:37,160 --> 00:01:40,760 How many of you have had a pen-test of your MQ environment? 28 00:01:44,120 --> 00:01:44,480 Okay. 29 00:01:45,400 --> 00:01:49,080 Did any of you guys get a clean bill of health, or do you think that your systems are all okay? 30 00:01:50,300 --> 00:01:50,660 Okay. 31 00:01:54,720 --> 00:01:55,680 So, okay, cool. 32 00:01:56,520 --> 00:01:59,840 What I'm going to do today is I'm going to talk through some of the background to MQ for you, 33 00:01:59,860 --> 00:02:02,080 for those guys that don't know about the technology. 34 00:02:03,260 --> 00:02:06,720 Talk through some of the features that it has with regard to security, 35 00:02:06,940 --> 00:02:11,360 and then talk about a few little issues I've discovered that may well put your installation at risk. 36 00:02:15,060 --> 00:02:17,780 So, I'm going to try and cater to a few different audiences today. 37 00:02:18,620 --> 00:02:20,640 Try and keep some of the stuff on the table. 38 00:02:20,640 --> 00:02:22,800 High level for security management out there. 39 00:02:23,180 --> 00:02:29,400 Also try and talk to a sufficiently techie level for anyone out there who's a pen-tester or security consultant. 40 00:02:29,860 --> 00:02:32,380 And also anybody that's developing applications for MQ. 41 00:02:32,640 --> 00:02:34,140 Hopefully you'll get something out of this as well. 42 00:02:37,580 --> 00:02:41,320 Now, anybody that knows MQ will know it's an absolutely massive piece of software. 43 00:02:41,460 --> 00:02:44,340 It can be configured in a whole lot of different ways in a whole lot of different environments. 44 00:02:45,160 --> 00:02:48,360 And I've not got time to go through every single aspect of security here. 45 00:02:49,300 --> 00:02:50,620 What I am going to focus on... 46 00:02:50,640 --> 00:02:54,820 ...is MQ from a network perspective in a TCP IP environment. 47 00:02:55,980 --> 00:03:00,600 And most of the research I've done has actually been against Windows and UNIX systems. 48 00:03:00,980 --> 00:03:04,820 In the last couple of weeks I was actually fortunate enough to look at this running on an i-Series system. 49 00:03:05,380 --> 00:03:08,860 And most of the code that I've written works actually straight out of the box on that as well. 50 00:03:14,580 --> 00:03:16,820 So why did I actually decide to look at MQ? 51 00:03:18,880 --> 00:03:19,320 Well... 52 00:03:20,640 --> 00:03:23,260 ...the reason why I did that is because the clients that are running it... 53 00:03:24,340 --> 00:03:27,320 ...and the way they're using it is actually mission critical. 54 00:03:28,180 --> 00:03:35,440 People are using this to pass their trade data, their share dealings, their retail transactions, healthcare information... 55 00:03:36,720 --> 00:03:39,800 ...using it to pass that around the business between various applications. 56 00:03:43,140 --> 00:03:47,360 When I started looking at this there were also no tools out there for me to really kind of get stuck into... 57 00:03:47,360 --> 00:03:49,840 ...to enable me to test an installation and say to the client... 58 00:03:49,840 --> 00:03:51,300 ...yes you're secure, no you're not. 59 00:03:54,180 --> 00:03:57,620 And what I've found generally is that when there aren't such tools out there... 60 00:03:57,620 --> 00:04:01,000 ...people often have installations that are not properly secured... 61 00:04:01,360 --> 00:04:03,900 ...because people don't know how to test them or to evaluate them. 62 00:04:05,880 --> 00:04:08,980 And generally with any application if you actually own the middleware... 63 00:04:08,980 --> 00:04:10,540 ...you normally own that business process. 64 00:04:18,560 --> 00:04:23,640 So a quick history lesson as I've managed to find out what the history of this thing is. 65 00:04:25,140 --> 00:04:29,460 MQ started back in 1993 as a kind of collaboration between SSI Systems and IBM. 66 00:04:30,120 --> 00:04:35,180 And over time IBM has kind of gradually adopted the code and taken it on themselves. 67 00:04:36,840 --> 00:04:39,800 Produced a set of versions for their core operating systems... 68 00:04:39,800 --> 00:04:41,480 ...as they were AIX, OS2 and AS400. 69 00:04:41,840 --> 00:04:45,680 And then used them as a kind of template to then portal their code to other platforms. 70 00:04:48,720 --> 00:04:52,420 The kind of latest version of the software that I've seen our clients running is version 6. 71 00:04:54,920 --> 00:04:58,640 And people tend to have been running that for either the last year, year and a half. 72 00:04:59,080 --> 00:05:04,160 Although some people are still at start there running anything from 5.1 up to 5.3. 73 00:05:05,040 --> 00:05:08,960 I've never found anyone running anything before that but that's not to say they aren't out there. 74 00:05:11,860 --> 00:05:14,780 So if you're a business why have you actually put MQ into your environment? 75 00:05:16,180 --> 00:05:20,580 Well normally you need some component there that's going to manage all your messaging. 76 00:05:20,680 --> 00:05:26,940 That can pass information accurately and reliably from one part of your infrastructure and your environment to another. 77 00:05:29,340 --> 00:05:32,420 People choose MQ because it's pretty stable enterprise technology. 78 00:05:32,820 --> 00:05:36,720 I hear clients that are passing millions of messages through their systems every minute. 79 00:05:37,640 --> 00:05:39,560 They need something that's going to be reliable... 80 00:05:39,560 --> 00:05:40,820 ...and not start dropping messages. 81 00:05:41,140 --> 00:05:42,620 They need something that's going to be scalable. 82 00:05:44,240 --> 00:05:47,220 They need something that's going to be able to run on a whole lot of different technologies. 83 00:05:47,720 --> 00:05:50,880 And MQ will run on Windows, Unix, it will run on mainframes. 84 00:05:52,660 --> 00:05:57,380 And that gives an enterprise an awful lot of functionality in how it actually uses its MQ installations. 85 00:05:59,260 --> 00:06:03,520 When you couple with that the whole lot of APIs that IBM have produced to help you build applications... 86 00:06:04,000 --> 00:06:07,180 ...that gives you an awful lot of power in interfacing with these systems. 87 00:06:09,600 --> 00:06:14,000 The various other bits of enterprise functionality in there make this a very attractive piece of software... 88 00:06:14,000 --> 00:06:15,220 ...for an awful lot of companies out there. 89 00:06:17,060 --> 00:06:20,020 I've already mentioned the type of data that goes across these systems. 90 00:06:20,280 --> 00:06:22,460 It's the stuff that's really core to people's businesses. 91 00:06:27,700 --> 00:06:30,680 So a really bad diagram for you to have a look at. 92 00:06:31,400 --> 00:06:35,020 If you're not sure of what MQ looks like and how it's actually set up... 93 00:06:35,020 --> 00:06:38,080 ...this is a reasonable attempt to describe that. 94 00:06:38,080 --> 00:06:45,800 What we can see is we essentially have two sets of queues on different machines... 95 00:06:45,800 --> 00:06:49,540 ...which is essentially a way of packaging up the data and keeping them in a nice tidy format. 96 00:06:50,100 --> 00:06:53,060 We then have the ability to transfer that data across a network. 97 00:06:53,580 --> 00:06:55,680 And we have these entities called queue managers... 98 00:06:55,680 --> 00:06:59,820 ...which are then responsible for managing this information and making sure it gets to where it needs to go to. 99 00:07:06,440 --> 00:07:08,060 There's a bit of terminology involved in this. 100 00:07:08,080 --> 00:07:10,560 We're involved in the MQ world and we'll talk about some of this today. 101 00:07:10,780 --> 00:07:11,960 I've already mentioned a queue manager. 102 00:07:12,200 --> 00:07:14,660 We also have different concepts like channels, queues. 103 00:07:15,020 --> 00:07:17,260 We have things like triggers and monitors. 104 00:07:18,220 --> 00:07:20,640 As I said, we'll run into these over the course of the presentation. 105 00:07:23,120 --> 00:07:24,180 So what's a queue manager? 106 00:07:24,660 --> 00:07:28,460 Essentially it's an application that's responsible for managing all the queues within which the data sits. 107 00:07:29,980 --> 00:07:32,460 As far as I'm aware, and please correct me if I'm wrong... 108 00:07:32,460 --> 00:07:35,220 ...you can only have one queue manager that listens on one TCP port. 109 00:07:37,140 --> 00:07:41,560 Each queue manager itself is an independent entity that has access to its own queues. 110 00:07:42,320 --> 00:07:45,840 But you can set up an environment where these queue managers can talk to each other... 111 00:07:45,840 --> 00:07:47,520 ...and therefore exchange data across a network. 112 00:07:49,260 --> 00:07:53,880 In the environments I've been working in, we often find multiple queue managers on a single system. 113 00:07:55,880 --> 00:08:04,660 So someone will be running a production MQ server on the same box as a development MQ installation... 114 00:08:05,220 --> 00:08:09,140 ...and because they manage separate queues, they think that's a suitable way of running things. 115 00:08:09,560 --> 00:08:13,060 As we'll find out a bit later on, there's reasons why that might not be such a good idea. 116 00:08:16,560 --> 00:08:18,020 Channels. I mentioned them briefly. 117 00:08:18,480 --> 00:08:24,000 The best way to think of a channel is some kind of conduit or pipe that enables you to get to the queues themselves. 118 00:08:25,640 --> 00:08:32,520 You can then apply various controls to that channel that restrict how access is actually gained to those queues themselves. 119 00:08:33,280 --> 00:08:35,200 So different people can access the queues themselves. 120 00:08:35,220 --> 00:08:36,100 You can apply queues down different channels. 121 00:08:37,260 --> 00:08:40,100 And you can apply different security features to each one of those channels. 122 00:08:43,120 --> 00:08:44,880 There are various different types of channel. 123 00:08:45,360 --> 00:08:47,980 But again, this is something we've really not got time to get into today. 124 00:08:51,540 --> 00:08:52,560 And then we have a queue. 125 00:08:53,580 --> 00:08:55,620 A queue is essentially what it sounds like. 126 00:08:56,100 --> 00:08:57,880 It's a container where your data goes. 127 00:08:59,280 --> 00:09:04,000 MQ is really designed to operate on a queue basis where everything works with queues. 128 00:09:05,300 --> 00:09:07,700 There are first in, first out structure generally. 129 00:09:08,000 --> 00:09:11,620 The message you put onto the queue first is the one you're going to recover off there first. 130 00:09:12,060 --> 00:09:13,580 There are some exceptions to that. 131 00:09:13,620 --> 00:09:17,100 You can use priorities in order to pull off urgent messages first. 132 00:09:17,600 --> 00:09:22,860 Again, these are some of the bits of functionality that make it so attractive to the enterprise market. 133 00:09:25,520 --> 00:09:30,580 Now the real elegance with MQ is that everything is really a get or a put. 134 00:09:30,660 --> 00:09:34,060 You're either getting data from a queue or you're putting data onto that queue. 135 00:09:36,500 --> 00:09:39,180 There's obviously some more complexity to the way the software works. 136 00:09:39,540 --> 00:09:44,220 But the real essence of what I'm going to show you today revolves around those two operations. 137 00:09:49,220 --> 00:09:50,780 So let's talk about the MQ protocol. 138 00:09:52,320 --> 00:09:56,040 As far as I'm aware, there's no actual official public disclosure of the protocol. 139 00:09:56,240 --> 00:10:02,840 But if you look in E3 or Wireshark, you will actually find some dissectors in there that enable you to get a pretty good understanding of what the protocol is doing. 140 00:10:03,700 --> 00:10:12,220 And when you look at the protocol, you'll see there's a series of different sections in each packet that depend on what purpose that packet is actually for. 141 00:10:13,380 --> 00:10:20,900 So a packet that is getting data will have sections like the get message options and the message descriptors that are not necessarily in other types of packet. 142 00:10:23,640 --> 00:10:26,120 All packets will have a transmission segment header. 143 00:10:26,640 --> 00:10:32,420 And if you see the letters TSH at the top of your packet, you're pretty certain that you're actually dealing with MQ. 144 00:10:36,600 --> 00:10:41,400 So you might not be able to see that diagram particularly well, but that's essentially what a packet looks like in Ethereal. 145 00:10:42,780 --> 00:10:49,220 At the top of the packet here, we can see the letters TSH, which is where this transmission segment header actually begins. 146 00:10:49,820 --> 00:10:54,220 This type of packet is actually a reply from a get request. 147 00:10:54,580 --> 00:11:00,160 So we've requested to get data from a queue, and this is the reply that's come back to us. 148 00:11:01,220 --> 00:11:02,820 So we can see some of the various differences. 149 00:11:02,840 --> 00:11:04,700 We've got different sections that are included in the packet. 150 00:11:05,440 --> 00:11:09,460 And down the bottom here, we have something that's known as PCF, programmable command formats, 151 00:11:09,980 --> 00:11:15,340 which is essentially a type of administrative packet, and we'll come on and talk about that in a little bit. 152 00:11:21,980 --> 00:11:23,220 So what is PCF? 153 00:11:23,300 --> 00:11:25,260 As I've said, it's essentially admin packets. 154 00:11:25,560 --> 00:11:27,880 It's a way you can actually manage the queue manager itself. 155 00:11:29,720 --> 00:11:32,760 And the way we use these is we actually, 156 00:11:32,840 --> 00:11:37,660 we put a particular data structure into either a get or a put message, 157 00:11:37,820 --> 00:11:40,480 and we put them on specific queues on the queue manager, 158 00:11:41,200 --> 00:11:43,360 and then we can read data back from other queues. 159 00:11:45,200 --> 00:11:47,580 Now the PCF data structure is well documented. 160 00:11:47,840 --> 00:11:52,380 There are some IBM guidelines out there about exactly what this data looks like, what format it's in, 161 00:11:53,000 --> 00:11:56,360 and that's what I've been able to use to put together some of the tools I've been writing. 162 00:12:00,480 --> 00:12:02,820 So one of the things we're going to talk about a bit later on, 163 00:12:02,840 --> 00:12:06,880 is how we actually execute a PCF command and how we can use that for our own purposes. 164 00:12:08,320 --> 00:12:12,120 And if we're going to issue a PCF command, essentially what we need to do are the following steps. 165 00:12:12,840 --> 00:12:16,020 First of all, we need to establish a connection to the queue manager. 166 00:12:16,820 --> 00:12:21,120 And if we're running on a TCP IP network, that's essentially a TCP connection that needs to be opened. 167 00:12:21,520 --> 00:12:25,640 And then a number of different handshakes need to occur to actually connect to the queue manager. 168 00:12:27,680 --> 00:12:30,020 We then need to open what's known as the admin queue 169 00:12:30,020 --> 00:12:34,300 on the software. 170 00:12:34,700 --> 00:12:37,320 And that is essentially a queue where we're going to put our data. 171 00:12:39,140 --> 00:12:41,480 Now as I said, everything on MQ works on queues. 172 00:12:41,680 --> 00:12:44,780 So if we're issuing a command, we put data onto a queue, 173 00:12:45,300 --> 00:12:47,500 and it gives us the reply back on another queue. 174 00:12:49,340 --> 00:12:54,500 And what we actually need is another queue for us to put the reply to that first query onto. 175 00:12:54,680 --> 00:12:57,340 So we open what's known as a dynamic, or a model queue. 176 00:12:58,500 --> 00:13:00,000 That essentially generates... 177 00:13:00,020 --> 00:13:03,540 a new dynamic queue for us that we can then use to put the data back onto. 178 00:13:05,200 --> 00:13:09,040 So the sequence events is we put our PCF data onto the admin queue. 179 00:13:09,200 --> 00:13:11,460 We then read our response back off the dynamic queue. 180 00:13:15,920 --> 00:13:17,860 So what security features does MQ have? 181 00:13:18,600 --> 00:13:21,100 Well essentially there are three types of security feature. 182 00:13:21,300 --> 00:13:23,180 And I'm going to talk through each one of these in turn. 183 00:13:24,580 --> 00:13:29,200 We have an MCA user, which is essentially a user ID on a particular channel. 184 00:13:29,200 --> 00:13:34,480 We have a security exit, which is an external program that can be called to enforce authentication. 185 00:13:35,240 --> 00:13:40,840 And we have SSL and TLS support, including the use of client certificates 186 00:13:40,840 --> 00:13:44,200 and some basic user filtering from that as well. 187 00:13:47,680 --> 00:13:53,360 So we start with MCA user, and this is not a particularly simple concept to get your head around. 188 00:13:53,460 --> 00:13:56,340 And I haven't got time to go into all the complexities of how it works. 189 00:13:58,160 --> 00:13:59,060 Essentially though, 190 00:13:59,200 --> 00:14:03,700 it's a tag in the packet that says which user has this data come from. 191 00:14:04,880 --> 00:14:09,980 And a lot of the API calls you'll find there actually read the user name of the logged on user on their machine 192 00:14:09,980 --> 00:14:11,700 and put that value into the packet. 193 00:14:13,540 --> 00:14:18,940 There's an awful lot of confusion out there about exactly what that means in terms of a security feature. 194 00:14:19,600 --> 00:14:23,360 I'm sure anybody here is aware that if you're reading the local user off a machine, 195 00:14:24,020 --> 00:14:25,680 then that's not really a security control. 196 00:14:27,740 --> 00:14:29,180 We can also apply an MCA 197 00:14:29,200 --> 00:14:30,460 user to a particular channel. 198 00:14:31,560 --> 00:14:35,160 And in the simplest form, that is essentially the user that that channel 199 00:14:35,160 --> 00:14:39,040 and those communications are going to run under if no other user is specified. 200 00:14:40,260 --> 00:14:42,480 As I say, there's a lot more complexity to that. 201 00:14:42,620 --> 00:14:46,680 We'll talk about some of the real showstoppers when we're actually talking about MCA users. 202 00:14:50,080 --> 00:14:51,600 So the limitations of this. 203 00:14:51,740 --> 00:14:56,860 And the first thing that anybody who has come across Web3MQ security will know 204 00:14:56,860 --> 00:14:58,240 is that by default, 205 00:14:58,240 --> 00:15:02,560 there will be a blank MCA user on all your channels when you take this thing out of the box. 206 00:15:03,460 --> 00:15:07,140 And a blank MCA user means everybody has access to that channel. 207 00:15:07,540 --> 00:15:08,520 So by default, 208 00:15:08,680 --> 00:15:12,920 if you've installed Web3MQ and you've not set the MCA user, 209 00:15:13,140 --> 00:15:14,580 your system is wide open. 210 00:15:17,440 --> 00:15:22,760 I've already mentioned that the MCA user is essentially a client-side parameter that is being passed from the client. 211 00:15:22,980 --> 00:15:24,600 If we can construct our own packets, 212 00:15:24,700 --> 00:15:27,860 we can construct a packet with any MCA user we wish in there. 213 00:15:30,960 --> 00:15:33,600 If you look at the newsgroups and people talking about MQ security, 214 00:15:33,920 --> 00:15:38,140 you'll see that there's a lot of people that really don't understand what this control actually means. 215 00:15:40,820 --> 00:15:44,100 And one lesson that you should take away from today's presentation, 216 00:15:44,320 --> 00:15:44,820 as we'll see, 217 00:15:44,900 --> 00:15:48,100 is you should never rely on an MCA user as your sole security measure. 218 00:15:48,580 --> 00:15:50,960 And we'll see a really good reason for that a bit later on. 219 00:15:54,640 --> 00:15:56,260 So we move on to a security exit. 220 00:15:56,560 --> 00:15:57,960 And a security exit is essentially, 221 00:15:58,240 --> 00:16:00,300 an external program that MQ can call, 222 00:16:00,420 --> 00:16:03,040 and that can do authentication for you. 223 00:16:03,920 --> 00:16:06,980 Now there are a number of commercial security exits out there. 224 00:16:08,060 --> 00:16:10,920 The other clients of ours actually write their own. 225 00:16:12,120 --> 00:16:16,940 And usually what you do is you get that security exit to check a username and password that has been submitted from the user. 226 00:16:17,260 --> 00:16:19,380 And if the username and password is correct, 227 00:16:19,460 --> 00:16:21,280 you send back the right return code to MQ, 228 00:16:21,300 --> 00:16:22,880 and that says, yeah, this guy's authenticated. 229 00:16:24,280 --> 00:16:27,360 There's lots more you can actually do with that security exit. 230 00:16:28,300 --> 00:16:30,160 You can enforce IP address restrictions. 231 00:16:30,380 --> 00:16:31,840 You can, in theory, do anything you want to. 232 00:16:33,760 --> 00:16:37,800 But essentially the lesson of a security exit is that it's enforcing access control for you. 233 00:16:40,140 --> 00:16:41,660 Now what are the limitations on it? 234 00:16:43,340 --> 00:16:46,900 Again, with any protocol, if you're sending that username and password over a clear text channel, 235 00:16:47,460 --> 00:16:50,620 that's just the same as using Telnet, FTP, any of those other protocols. 236 00:16:52,260 --> 00:16:55,860 If you write your own security exit or buy one that's written insecurely, 237 00:16:55,880 --> 00:16:58,220 that code is essentially now the front door to MQ. 238 00:16:58,240 --> 00:16:58,740 It's the front door to your system. 239 00:17:01,060 --> 00:17:03,640 If that code is insecure, you could get your system owned, 240 00:17:04,900 --> 00:17:08,760 and therefore it's very important to actually look at what code you're using for that security exit. 241 00:17:10,980 --> 00:17:13,660 Another limitation, and this might not be an obvious one, 242 00:17:13,720 --> 00:17:16,500 is that MQ actually has to make sure that that exit is called for you. 243 00:17:17,760 --> 00:17:21,020 You literally kind of tick a box on MQ and say, yeah, use this exit. 244 00:17:22,580 --> 00:17:25,960 But you have to then have trust that MQ is actually going to call your exit for you. 245 00:17:29,780 --> 00:17:31,500 So what about transport security? 246 00:17:32,060 --> 00:17:35,140 Well, MQ has good support for SSL and TLS. 247 00:17:38,220 --> 00:17:42,180 Unusually, MQ will actually accept an SSL handshake on the same port 248 00:17:42,180 --> 00:17:45,180 as it will accept a standard MQ clear text handshake. 249 00:17:47,420 --> 00:17:50,660 Unlike a web server where you can negotiate a cipher suite to use, 250 00:17:50,920 --> 00:17:56,340 a particular channel will be set with one cipher, one SSL version. 251 00:17:57,040 --> 00:17:58,140 There's no negotiation. 252 00:17:58,140 --> 00:17:59,420 There's no negotiation actually permitted on that. 253 00:18:00,940 --> 00:18:02,800 If you're thinking about building your own tools, 254 00:18:03,740 --> 00:18:08,800 OpenSSL has had good support for the majority of the ciphers that MQ supports for quite a while now. 255 00:18:11,160 --> 00:18:16,200 Something in the UK we don't really have much call for is FIPS compliance, 256 00:18:16,480 --> 00:18:22,520 and I believe that MQ can actually be set up to be FIPS compliant if that's what you actually require. 257 00:18:22,760 --> 00:18:26,480 You can do that in the software or through additional hardware accelerators. 258 00:18:30,540 --> 00:18:32,220 So what are the limitations of SSL? 259 00:18:33,140 --> 00:18:37,380 Well, if you think that by putting a particular cipher on a particular channel 260 00:18:37,380 --> 00:18:38,960 that's going to stop someone talking to you, 261 00:18:39,740 --> 00:18:41,320 again, that's a false assumption. 262 00:18:41,400 --> 00:18:44,700 We can just cycle through all the ciphers and see which one we get a proper handshake from. 263 00:18:46,400 --> 00:18:50,100 By default, if you put SSL on a channel, you're not going to get any authentication control. 264 00:18:50,780 --> 00:18:54,120 Hopefully everyone here is completely aware of that one. 265 00:18:57,300 --> 00:18:58,040 Limitation again. 266 00:18:58,140 --> 00:19:02,260 If you think that just because we're using SSL it's going to be difficult for guys to write tools, 267 00:19:04,820 --> 00:19:07,460 using Python, which I've used to write most of my tools, 268 00:19:07,660 --> 00:19:10,100 it's just a couple of lines extra to do that SSL handshake. 269 00:19:12,880 --> 00:19:16,680 Also, you have to be aware that if you're using SSL, 270 00:19:16,740 --> 00:19:20,660 there's obviously a certain amount of trust with regard to who you're actually talking to. 271 00:19:21,040 --> 00:19:25,980 That's based on the certificate authorities that are actually in the key repository on either end of the communication. 272 00:19:26,920 --> 00:19:28,120 You need to be very careful. 273 00:19:28,140 --> 00:19:29,100 You need to be very careful about how you set that up. 274 00:19:32,180 --> 00:19:34,960 I also mentioned we can do client authentication using MQ. 275 00:19:36,800 --> 00:19:40,220 We can actually set it so that MQ only accepts communications 276 00:19:40,220 --> 00:19:43,780 from someone who is using a certificate issued by our trusted CA. 277 00:19:44,900 --> 00:19:48,060 We can also filter users based on the values in that certificate. 278 00:19:51,580 --> 00:19:55,480 And if we lock down our repositories on either end so that only trusted CA's are in there, 279 00:19:55,480 --> 00:19:59,680 then we can actually make sure that only the right people are connecting. 280 00:20:03,100 --> 00:20:07,700 The problem is by default there's a whole load of trusted CA's in those key repositories when you create them. 281 00:20:07,860 --> 00:20:12,800 If you don't actively remove them, that means that someone with a key from a trusted CA, 282 00:20:13,040 --> 00:20:15,240 for example from VeriSign or Thought, 283 00:20:16,060 --> 00:20:18,940 they will also be able to gain access to your queue manager. 284 00:20:21,800 --> 00:20:25,460 Again, it's really easy to add support for a certificate in using Python. 285 00:20:25,480 --> 00:20:26,760 It's a couple of lines of code. 286 00:20:28,680 --> 00:20:33,740 Another limitation with the actual filtering within MQ's client authentication controls 287 00:20:33,740 --> 00:20:37,880 is that it only works from the start of the pattern match. 288 00:20:38,100 --> 00:20:41,580 So if I have a pattern match that I'm matching CN equals admin, 289 00:20:41,820 --> 00:20:46,400 then CN equaling admin1, admin2, administrator are all going to be allowed. 290 00:20:46,620 --> 00:20:50,660 We don't have to actually specify a trailing kind of wildcard on the end of that filter. 291 00:20:51,400 --> 00:20:53,260 That is there by default and implied. 292 00:20:54,660 --> 00:20:57,240 So if we're not careful about who we're issuing certificates to 293 00:20:57,240 --> 00:20:59,020 and what the names are in those certificates, 294 00:20:59,260 --> 00:21:00,600 we could find ourselves in trouble again. 295 00:21:05,320 --> 00:21:07,620 So now let's move on to talk about actually testing MQ. 296 00:21:11,000 --> 00:21:14,080 If we want to connect to MQ, we need to know a number of things 297 00:21:14,080 --> 00:21:17,680 and the success of our connection is essentially going to rely on a number of things. 298 00:21:18,000 --> 00:21:20,060 It's going to rely on us knowing the right port to connect to. 299 00:21:23,260 --> 00:21:24,840 There's no reason why we can't change that. 300 00:21:24,960 --> 00:21:26,060 So we have to find it. 301 00:21:27,100 --> 00:21:29,220 We then have to know a channel to communicate with. 302 00:21:30,140 --> 00:21:32,220 Thankfully, from our perspective, if we're an attacker, 303 00:21:32,300 --> 00:21:35,140 there are some default channels that we can find. 304 00:21:35,580 --> 00:21:40,540 In other circumstances, people will publish the names of their channel on a wiki or on the internet. 305 00:21:40,920 --> 00:21:43,640 If they're using clear text communication, we can sniff these values. 306 00:21:47,760 --> 00:21:50,980 The success of our connection will also depend on what's known as the MCA user. 307 00:21:51,960 --> 00:21:56,600 Most of the guidebooks out there tell us that we set an invalid user as the MCA user 308 00:21:56,600 --> 00:21:58,580 and that essentially locks people out of that channel. 309 00:21:59,660 --> 00:22:02,640 We'll come on to see why that might not be such a good control. 310 00:22:05,140 --> 00:22:08,380 It also depends on whether we've got a security exit defined. 311 00:22:08,760 --> 00:22:11,760 But again, as we'll come on to see, that might not necessarily save us. 312 00:22:13,300 --> 00:22:17,300 And again, if SSL is being used, we need to know which ciphers to use 313 00:22:17,300 --> 00:22:20,160 and whether particular certificates are trusted or not. 314 00:22:20,560 --> 00:22:20,960 Thank you. 315 00:22:24,240 --> 00:22:26,680 So the first one of those challenges is to actually find MQ. 316 00:22:27,920 --> 00:22:31,380 Easiest way of finding it is to just attempt an MQ initial data handshake 317 00:22:31,380 --> 00:22:33,880 on each port on the system that we think might be MQ. 318 00:22:34,780 --> 00:22:38,560 If we get it right, we're probably going to get the queue manager name coming back in our packet. 319 00:22:39,200 --> 00:22:40,280 Well, not necessarily. 320 00:22:42,320 --> 00:22:46,460 In most client instances I see, we actually get some kind of data back 321 00:22:46,460 --> 00:22:49,140 that we can use to actually identify that MQ is on that port. 322 00:22:52,080 --> 00:22:55,720 And we'll see a demo of running that against an installation a bit later on. 323 00:22:58,220 --> 00:23:05,860 So the pattern of connection is essentially we can actually do an initial data handshake 324 00:23:05,860 --> 00:23:09,340 where we agree to various parameters that are going to be used by MQ. 325 00:23:10,500 --> 00:23:13,660 We then actually send a username and password packet. 326 00:23:14,580 --> 00:23:17,280 If no username and password is set up, we still send that packet, 327 00:23:17,280 --> 00:23:19,860 but we actually send it without any values in there. 328 00:23:20,800 --> 00:23:24,460 If no security exit is defined, then we can just go ahead and try to connect. 329 00:23:24,640 --> 00:23:26,800 We get a connection response back if we're successful. 330 00:23:27,280 --> 00:23:30,980 And then we can try opening queues and accessing data and doing all the things we might want to. 331 00:23:35,200 --> 00:23:38,240 So one thing that I've noticed that I've never actually seen anyone use 332 00:23:38,240 --> 00:23:40,620 but looks like it's quite an interesting feature 333 00:23:41,240 --> 00:23:43,740 is that you can actually set up channel auto-definition, 334 00:23:43,820 --> 00:23:45,600 whereby connecting to a channel that doesn't exist, 335 00:23:45,600 --> 00:23:48,640 MQ will quite happily set up a new channel for you 336 00:23:48,640 --> 00:23:50,480 based on a particular template that you've defined. 337 00:23:52,620 --> 00:23:55,420 I'm sure you can imagine that connecting with lots of different 338 00:23:55,420 --> 00:23:58,180 invalid channel names could cause a few issues 339 00:23:58,180 --> 00:24:00,380 if we're able to actually talk to the MQ port itself. 340 00:24:02,300 --> 00:24:06,440 If someone has actually set that up and used an administrative template 341 00:24:06,440 --> 00:24:10,260 as the channel definition we might find ourselves gaining access straight away. 342 00:24:15,060 --> 00:24:15,580 Previewing code 343 00:24:15,580 --> 00:24:19,540 actually connected, what do we actually want to do? Well, there are a number of things we can 344 00:24:19,540 --> 00:24:23,520 do. We can issue these PCF commands. We could administer the queue manager 345 00:24:23,520 --> 00:24:27,500 itself. We can open and actually look at the 346 00:24:27,500 --> 00:24:31,660 queues themselves, look at the information on them. We can pull data off those queues, maybe. 347 00:24:32,040 --> 00:24:35,540 Put more data on them. Also, 348 00:24:35,680 --> 00:24:39,540 we can execute operating system commands if the conditions are right. 349 00:24:42,660 --> 00:24:43,660 So what PCF 350 00:24:43,660 --> 00:24:47,560 commands might be useful to us? Well, there are some 351 00:24:47,560 --> 00:24:51,680 that enable us to enumerate the version of MQ. Some allow us to dump out a list 352 00:24:51,680 --> 00:24:55,180 of all the channels on the system, a list of all the queues and how they're configured. 353 00:24:56,060 --> 00:24:59,500 There's also a queue there that contains the information regarding 354 00:24:59,500 --> 00:25:01,380 the MCA users of particular channels. 355 00:25:07,540 --> 00:25:08,380 So if an attacker 356 00:25:08,380 --> 00:25:12,740 actually isn't interested in your queue data and wants to start executing commands, what do they need to do? 357 00:25:14,640 --> 00:25:18,500 Well, from version 6 onwards, MQ supports something called 358 00:25:18,500 --> 00:25:22,520 services. This is essentially a way of defining an external program 359 00:25:22,520 --> 00:25:26,520 that can be run through the execution of PCF. 360 00:25:28,520 --> 00:25:30,140 So if we're able to gain access 361 00:25:31,720 --> 00:25:34,300 with enough ability to execute PCF commands, 362 00:25:34,500 --> 00:25:38,460 we can define ourselves a new service, which is essentially an application to run 363 00:25:38,460 --> 00:25:39,460 and start that running. 364 00:25:45,540 --> 00:25:48,360 Another method, and this method works before version 6, 365 00:25:49,380 --> 00:25:51,260 is on MQ you can setup triggers. 366 00:25:51,840 --> 00:25:54,560 This is essentially an application that will 367 00:25:54,560 --> 00:25:58,260 sit there and listen for data on a particular queue, when it receives it, it then 368 00:25:58,260 --> 00:25:59,000 executes a 369 00:25:59,000 --> 00:26:02,320 particular command for you. Administrators like to use this 370 00:26:02,320 --> 00:26:06,680 and say at particular, say at the end of day for 371 00:26:06,680 --> 00:26:12,040 a retail organization, a message gets sent to a queue to say all the tills have closed 372 00:26:12,040 --> 00:26:12,340 and 373 00:26:12,340 --> 00:26:15,220 and that actually then gets fired onto a queue, 374 00:26:15,340 --> 00:26:18,560 and a trigger fires to tell the administrator that all the queues have closed for the day. 375 00:26:19,340 --> 00:26:20,880 I mean, there are lots of things you can do with a trigger. 376 00:26:20,940 --> 00:26:26,360 That's just one kind of really made-up example. 377 00:26:29,080 --> 00:26:31,280 Now, if we want to execute commands using that trigger, 378 00:26:31,400 --> 00:26:32,840 there are a few different things we need to do. 379 00:26:34,280 --> 00:26:36,160 First of all, we need to define a new process. 380 00:26:36,320 --> 00:26:38,780 Now, the process is essentially the command that we're going to execute. 381 00:26:39,300 --> 00:26:43,300 We then need to change the queue definition to actually turn the trigger on 382 00:26:43,300 --> 00:26:46,600 and tell it to use that particular process when it fires. 383 00:26:47,040 --> 00:26:50,580 We then need to put a message onto the right queue so that our trigger fires, 384 00:26:51,140 --> 00:26:55,160 and the trigger monitor application actually reads that information and runs that command. 385 00:26:56,380 --> 00:26:59,960 Now, the one caveat to this is a trigger monitor needs to be running. 386 00:27:00,060 --> 00:27:04,780 So in this particular installation, we need to have that actual application running. 387 00:27:05,320 --> 00:27:08,540 Before version 6, I'm not aware of any way of actually starting that remotely. 388 00:27:12,960 --> 00:27:16,200 But that last method actually requires us to execute PCF commands. 389 00:27:16,380 --> 00:27:18,520 Now, if we don't have permission to execute PCF, 390 00:27:18,560 --> 00:27:21,220 then there is a slightly easier way for us to do it. 391 00:27:22,320 --> 00:27:26,880 Now, what happens when a trigger fires is essentially MQ puts a particular type of message 392 00:27:26,880 --> 00:27:30,700 onto what's known as an initiation queue, and that's what's read by the trigger. 393 00:27:31,660 --> 00:27:35,440 Now, rather than go through the hassle of defining a new process or to a queue definition, 394 00:27:35,740 --> 00:27:38,760 if we know the format of that message, we can just put that message in there. 395 00:27:38,760 --> 00:27:39,920 We can put that message directly onto that queue. 396 00:27:42,440 --> 00:27:46,420 Now, if we put a message onto an initiation queue and the trigger monitor isn't using, 397 00:27:46,560 --> 00:27:50,680 and our expiry time isn't set to a low value, that message will actually sit there. 398 00:27:50,840 --> 00:27:55,460 So the next time an administrator fires up a trigger on that queue, that will actually run. 399 00:27:55,980 --> 00:28:00,240 Now, you can imagine that as being almost a kind of very unstealthy backdoor, 400 00:28:00,380 --> 00:28:04,540 so that a particular person has gained access to an MQ installation, 401 00:28:04,780 --> 00:28:07,380 drops a particularly malicious message onto that queue, 402 00:28:07,500 --> 00:28:08,740 and then when an administrator decides... 403 00:28:08,760 --> 00:28:12,000 they're going to start running a trigger monitor, that fires. 404 00:28:12,380 --> 00:28:16,340 And if they're not particularly familiar with the use of a trigger, 405 00:28:16,440 --> 00:28:18,240 the actual message they get on their screen, 406 00:28:18,400 --> 00:28:20,360 they might not understand the actual importance of that 407 00:28:20,360 --> 00:28:22,580 and the fact that an attacker has just executed a command. 408 00:28:26,140 --> 00:28:28,940 So if you're familiar with MQ and all the features I've been talking about, 409 00:28:29,020 --> 00:28:31,960 then it's probably not much that you're too worried about so far. 410 00:28:32,980 --> 00:28:34,840 You've probably got all these things in place. 411 00:28:34,880 --> 00:28:36,960 You've probably got your whole system set up and secured. 412 00:28:40,880 --> 00:28:43,780 But when I actually started testing this software, 413 00:28:43,960 --> 00:28:47,500 I actually discovered two new vulnerabilities that actually exposed some pretty serious holes. 414 00:28:50,100 --> 00:28:53,560 Now, I went through the process of reporting these to IBM back in January 415 00:28:53,560 --> 00:28:54,980 and another one in May this year. 416 00:28:55,380 --> 00:28:58,440 I actually talked to the MQ Development guys in the UK 417 00:28:58,440 --> 00:29:03,040 and reported these issues through the Center for the Protection of National Infrastructure in the UK. 418 00:29:05,420 --> 00:29:07,920 And for various reasons, I'm not going to tell you exactly 419 00:29:07,920 --> 00:29:11,740 how to exploit these vulnerabilities today, but I'm going to tell you what they are, 420 00:29:11,800 --> 00:29:14,960 what they mean for your environment, and how you can protect against them. 421 00:29:16,380 --> 00:29:19,960 Once everyone's had a chance to digest that and actually protect their systems 422 00:29:19,960 --> 00:29:23,940 at the right time, then I'll actually release some more 423 00:29:23,940 --> 00:29:27,880 information about these. So what's the first one of these issues? 424 00:29:31,080 --> 00:29:31,880 I was actually 425 00:29:31,880 --> 00:29:35,840 testing an installation where their security measure was a security exit. They'd correctly protected 426 00:29:35,840 --> 00:29:39,800 texted channels. It was actually with a security 427 00:29:39,800 --> 00:29:43,700 exit that would take a username and password, check that against a database, and then 428 00:29:43,700 --> 00:29:47,720 if that was actually correct, it would log you in. I was able to actually 429 00:29:47,720 --> 00:29:51,620 bypass that completely, so that I managed to get MQ not to call that exit, 430 00:29:52,340 --> 00:29:55,780 meaning that MQ did not know to kick me off the software 431 00:29:55,780 --> 00:29:57,960 and I was able to gain access to that installation. 432 00:30:01,980 --> 00:30:03,520 The systems I tested were 433 00:30:03,520 --> 00:30:05,740 versions 5.1 to 5.3. 434 00:30:05,840 --> 00:30:08,520 I'm on a Solaris platform. Others may be vulnerable. 435 00:30:09,400 --> 00:30:13,800 I know that the version of MQ I have, which is version 6 on Windows, is not 436 00:30:13,800 --> 00:30:15,980 vulnerable to that issue, as far as I've been able to tell. 437 00:30:18,820 --> 00:30:21,580 I'm aware of rumors that say that this issue has been fixed 438 00:30:21,580 --> 00:30:25,740 somewhere down the line, but I'm not aware of any documentation, though I can't 439 00:30:25,740 --> 00:30:29,700 actually tell you at what point that got fixed or what patch you need to actually 440 00:30:29,700 --> 00:30:33,920 apply to essentially mitigate that. 441 00:30:36,600 --> 00:30:39,140 The next one is actually an invalid MCA user bypass. 442 00:30:39,740 --> 00:30:43,380 Now, a lot of the books out there on security and MQ will say, as soon as you get this thing out of the box, 443 00:30:43,460 --> 00:30:47,660 put an invalid user into the MCA user channel agent. 444 00:30:47,880 --> 00:30:50,620 That means anybody connecting to the box is going to get a 445 00:30:51,880 --> 00:30:54,100 reason code back saying you're not authorized to connect. 446 00:30:55,760 --> 00:30:58,860 I actually found a way of bypassing this, meaning that if you 447 00:30:59,380 --> 00:31:03,640 essentially have protected your administrative channels or any other channels by setting an invalid user, 448 00:31:03,840 --> 00:31:05,740 it is still possible to gain access to that. 449 00:31:05,840 --> 00:31:11,760 And every version I've tested so far has actually been vulnerable to this issue. 450 00:31:16,320 --> 00:31:19,040 So if our objective is to actually test the security of an installation, 451 00:31:19,320 --> 00:31:20,700 there are a number of tools we actually need. 452 00:31:21,860 --> 00:31:24,460 We need somewhere to find the MQ services on our network. 453 00:31:25,120 --> 00:31:28,580 We need a way of finding the channels on these systems so we can communicate with them. 454 00:31:30,880 --> 00:31:33,800 We need the ability to test what SSL settings are in place 455 00:31:33,800 --> 00:31:35,580 so we know how to communicate with those channels. 456 00:31:36,900 --> 00:31:40,460 It would also be good to recover information from the MQ manager that tells us things like 457 00:31:40,460 --> 00:31:45,260 operating system version, what processes are defined, and whether there are any triggers running. 458 00:31:50,440 --> 00:31:53,100 It would also be good to be able to test whether we can read data from a MQ, 459 00:31:53,320 --> 00:31:54,960 whether we can write data to a MQ. 460 00:31:56,260 --> 00:31:59,920 It would also be good to test whether we can actually execute operating system commands 461 00:31:59,920 --> 00:32:01,740 through both of the methods I've just talked about. 462 00:32:06,940 --> 00:32:10,600 So what I've actually done is written some tools that actually help us to perform these tasks. 463 00:32:11,900 --> 00:32:17,020 I've actually written them in a set of Python classes 464 00:32:17,020 --> 00:32:21,640 that enable you to then build packets up and fire these in whichever order you want. 465 00:32:23,000 --> 00:32:24,820 It's not a finished tool by any means. 466 00:32:25,000 --> 00:32:27,140 And what I'm actually releasing is some sample tools 467 00:32:27,140 --> 00:32:32,080 that enable you to do some of the enumeration of your systems for MQ. 468 00:32:33,180 --> 00:32:35,720 And actually enable you to dump out some information. 469 00:32:41,900 --> 00:32:45,420 I'm also in the process of putting together a white paper on MQ security. 470 00:32:46,040 --> 00:32:48,400 I've only been looking at this subject for about six months, 471 00:32:48,560 --> 00:32:50,280 so I don't know everything about this software yet. 472 00:32:52,580 --> 00:32:56,480 And what I'm trying to do is distill down what I've actually found from a security perspective 473 00:32:56,480 --> 00:33:03,680 into one document that enables people to look at their installations in a realistic manner. 474 00:33:07,040 --> 00:33:08,820 And I'm going to put lots of information in there. 475 00:33:09,060 --> 00:33:10,920 Today I've had to skip over an awful lot of stuff. 476 00:33:11,040 --> 00:33:12,360 I'm going to put some more information in there. 477 00:33:12,560 --> 00:33:15,560 That's going to be available through our company's website, hopefully in the next month or so. 478 00:33:19,080 --> 00:33:23,700 So now we're going to get to the fun bit and have a look at actually exploiting some of these vulnerabilities 479 00:33:23,700 --> 00:33:27,120 to look at how we can actually gain access to a system running MQ. 480 00:33:27,960 --> 00:33:29,520 And I've got a very basic setup here. 481 00:33:30,000 --> 00:33:31,860 I've got my laptop, and that's going to... 482 00:33:32,180 --> 00:33:35,820 It's essentially a VMware partition that's going to talk to an MQ server. 483 00:33:39,880 --> 00:33:41,020 Our objective's on the demo. 484 00:33:41,460 --> 00:33:44,640 We're going to scan a box, look for MQ services. 485 00:33:45,440 --> 00:33:48,780 We're going to try and work out what SSL support is on the channels on there. 486 00:33:49,340 --> 00:33:52,360 We're going to recover some information using some PCF commands. 487 00:33:52,900 --> 00:33:54,780 And I've also got Netcat on that system, 488 00:33:54,860 --> 00:33:56,980 and all I'm going to do is execute a command to start that running 489 00:33:56,980 --> 00:34:01,520 so we can actually see that we have an ability to actually execute a command. 490 00:34:02,160 --> 00:34:05,820 Obviously your kind of method of exploitation out there in the wild 491 00:34:05,820 --> 00:34:08,600 is going to be dependent on the architecture and the environment you find yourself in. 492 00:34:14,420 --> 00:34:16,440 So I'm going to flick over to the demo now. 493 00:34:16,520 --> 00:34:18,600 If you can't see anything, please give a shout. 494 00:34:18,840 --> 00:34:20,980 I've tried to use a reasonable font size. 495 00:34:24,140 --> 00:34:30,400 And what I'm going to do quickly is just show you a quick look at the actual MQ software itself 496 00:34:31,660 --> 00:34:34,820 set up in a configuration that we've actually seen out there 497 00:34:34,820 --> 00:34:36,500 that our customers are using. 498 00:34:42,700 --> 00:34:45,640 And for those people that haven't come across MQ before, 499 00:34:45,800 --> 00:34:47,440 this software is called MQ Explorer. 500 00:34:48,740 --> 00:34:52,400 It's essentially a GUI tool that enables you to manage your queue manager. 501 00:34:57,320 --> 00:35:00,320 And you can see here I have a number of channels actually set up. 502 00:35:01,460 --> 00:35:04,160 And the one I'm actually going to demonstrate attacking is, 503 00:35:04,160 --> 00:35:06,340 is this channel here called Defcon 15 admin. 504 00:35:06,820 --> 00:35:07,860 If we look at that, 505 00:35:13,800 --> 00:35:16,240 we can see we've got SSL set up on that channel. 506 00:35:16,640 --> 00:35:21,740 We've also got it set up to externally only accept certificates with this particular string 507 00:35:21,740 --> 00:35:23,400 in the distinguished name. 508 00:35:23,820 --> 00:35:27,920 And we're only going to accept connections from people with trusted certificates. 509 00:35:31,820 --> 00:35:33,560 We've also been paranoid on this channel 510 00:35:34,160 --> 00:35:35,280 because there's no valid MCA user on there. 511 00:35:35,460 --> 00:35:37,980 So technically no one should be able to gain access to that channel. 512 00:35:50,920 --> 00:35:52,600 Now I'm just going to show you quickly also 513 00:35:54,360 --> 00:35:58,380 why my certificate that I'm going to try and talk to the queue manager with actually works. 514 00:36:06,960 --> 00:36:11,560 And this is essentially the view you get from the key repository manager on MQ. 515 00:36:11,860 --> 00:36:18,060 And by default we have a whole load of certificate authorities that are in there by default. 516 00:36:18,180 --> 00:36:20,380 So if I've got a certificate that's signed by one of these CAs, 517 00:36:20,460 --> 00:36:22,280 because I haven't removed them from there, 518 00:36:22,340 --> 00:36:23,280 actively removed them, 519 00:36:23,340 --> 00:36:24,240 I'm going to be able to gain access. 520 00:36:31,920 --> 00:36:34,040 And the last thing just to show you quickly 521 00:36:34,040 --> 00:36:36,260 is that we've also got a trigger monitor running 522 00:36:36,260 --> 00:36:39,300 that we're going to use to demonstrate executing a command. 523 00:36:46,380 --> 00:36:48,400 So that's just our trigger monitor sat there waiting, 524 00:36:48,520 --> 00:36:51,340 listening on the default initiation queue, 525 00:36:51,420 --> 00:36:53,300 waiting for a message to come along. 526 00:36:53,300 --> 00:36:55,520 I'm logged onto this box as an administrator, 527 00:36:55,920 --> 00:36:58,660 so that trigger monitor is running as an administrator 528 00:36:58,660 --> 00:37:00,820 and we'll see why that's a really foolish idea. 529 00:37:41,600 --> 00:37:42,740 So the first thing I'm going to do now 530 00:37:42,740 --> 00:37:44,780 is just run a quick M-Map scan against that system 531 00:37:44,780 --> 00:37:46,700 to see what services are listening. 532 00:38:02,840 --> 00:38:04,380 Let me try and get that in the right place. 533 00:38:12,460 --> 00:38:13,680 And if we look down here at the bottom, 534 00:38:13,700 --> 00:38:15,300 we can see that our default port 1414 535 00:38:15,900 --> 00:38:17,740 is actually listening on this system. 536 00:38:20,060 --> 00:38:20,960 What we're actually going to do 537 00:38:20,960 --> 00:38:22,300 is run a quick tool against that system 538 00:38:22,300 --> 00:38:23,280 just to make sure that it is listening. 539 00:38:23,300 --> 00:38:23,800 That is actually MQ. 540 00:38:31,380 --> 00:38:33,260 I'm just going to try and resize this window a bit 541 00:38:33,260 --> 00:38:35,000 to let you be able to see the bottom of the screen 542 00:38:35,000 --> 00:38:35,540 a bit easier. 543 00:38:51,820 --> 00:38:54,540 Okay, so the next thing I'm going to run... 544 00:39:01,600 --> 00:39:04,720 This is essentially going to take my M-Map output 545 00:39:04,720 --> 00:39:05,580 in greppable format. 546 00:39:05,720 --> 00:39:06,980 It's just going to try doing a handshake 547 00:39:06,980 --> 00:39:08,680 against each one of those ports on that box. 548 00:39:09,500 --> 00:39:11,260 And that will take a little bit of time to go through. 549 00:39:11,480 --> 00:39:13,840 So essentially that's firing an initial data handshake 550 00:39:14,540 --> 00:39:15,680 at the box. 551 00:39:16,320 --> 00:39:18,680 All those ports, as we expect, are on MQ. 552 00:39:20,220 --> 00:39:24,680 And these ones eventually will get to port 1414. 553 00:39:29,820 --> 00:39:32,160 And we'll see that we've got a nice handshake back from there 554 00:39:32,160 --> 00:39:33,280 and that's actually given us the... 555 00:39:34,720 --> 00:39:36,720 the actual name of the queue manager for us. 556 00:39:45,580 --> 00:39:47,460 Next thing we're going to do now is actually... 557 00:39:47,460 --> 00:39:49,380 I've got a text file on the machine here 558 00:39:49,380 --> 00:39:50,380 with a number of default channels 559 00:39:50,380 --> 00:39:53,360 and also the channels that we saw in the actual MQ software. 560 00:39:55,180 --> 00:39:57,680 I'm going to run an SSL check against those. 561 00:39:57,780 --> 00:39:58,900 It's going to essentially check... 562 00:39:59,520 --> 00:40:01,280 It's going to run through a whole list of different ciphers 563 00:40:01,280 --> 00:40:03,860 to see which cipher suites are actually supported 564 00:40:03,860 --> 00:40:04,480 on those channels. 565 00:40:33,860 --> 00:40:35,500 So we can see our DEF CON 15 channel 566 00:40:35,500 --> 00:40:37,840 is SSL version 3 with a null char. 567 00:40:39,200 --> 00:40:42,480 We've then got some of the system channels 568 00:40:42,480 --> 00:40:45,000 and they've all been set up without any SSL protection on them. 569 00:40:45,520 --> 00:40:47,560 Now notice one thing that's actually missing from there 570 00:40:47,560 --> 00:40:49,540 is our DEF CON 15 admin channel. 571 00:40:49,820 --> 00:40:52,000 And that's because of a little bug in this tool at the moment. 572 00:40:52,480 --> 00:40:54,520 We need to rerun this in verbose mode. 573 00:40:59,400 --> 00:41:01,800 And we actually find that on a channel that has... 574 00:41:03,860 --> 00:41:06,080 SSL set up but actually requires a client certificate 575 00:41:06,080 --> 00:41:07,880 we get a slightly different error message back. 576 00:41:08,100 --> 00:41:10,180 You can see there for AES 256 577 00:41:10,180 --> 00:41:11,760 we've got a reply that says 578 00:41:11,760 --> 00:41:14,020 invalid client certificate rather than bad remote cipher. 579 00:41:18,100 --> 00:41:20,400 So we now know which ciphers we can actually use 580 00:41:20,400 --> 00:41:21,280 to talk to those channels. 581 00:41:33,060 --> 00:41:34,760 Next thing we're going to do now is actually 582 00:41:36,380 --> 00:41:39,920 just using one of these insecure default admin channels 583 00:41:39,920 --> 00:41:41,360 we're just actually going to dump out some information 584 00:41:41,360 --> 00:41:43,240 just to show you what kind of things we can get out of this. 585 00:41:58,200 --> 00:42:00,360 So if we work down we can see the various different packets 586 00:42:00,360 --> 00:42:02,580 that I'm actually sending and the responses we're getting back from them. 587 00:42:03,340 --> 00:42:05,040 So I complete a handshake, I connect, 588 00:42:05,320 --> 00:42:08,980 I open my admin queue, I open my model queue to get my data back. 589 00:42:10,340 --> 00:42:13,480 I then actually submit an inquire queue manager PCF command 590 00:42:13,480 --> 00:42:16,840 and that returns us a whole lot of information about that queue manager. 591 00:42:18,000 --> 00:42:19,880 Most of which we're probably not going to be interested in 592 00:42:19,880 --> 00:42:20,480 but there are some... 593 00:42:21,280 --> 00:42:23,080 some values in here of interest to us. 594 00:42:25,860 --> 00:42:26,920 We see there 595 00:42:29,460 --> 00:42:31,800 we're at Web3MQ version 6 596 00:42:31,800 --> 00:42:35,260 and a bit further down we can see 597 00:42:35,260 --> 00:42:37,120 that our operating system type is Windows. 598 00:42:37,720 --> 00:42:39,260 So we've already got a fairly good idea about 599 00:42:39,260 --> 00:42:40,400 what kind of system we're attacking 600 00:42:40,400 --> 00:42:42,360 and how we actually need to go about that. 601 00:42:54,240 --> 00:42:56,420 So now what we'll actually try doing is executing commands 602 00:42:56,420 --> 00:42:58,060 to start that Netcat that's listening on there. 603 00:43:00,880 --> 00:43:02,420 Just to show you that I'm not cheating. 604 00:43:04,340 --> 00:43:06,520 Hopefully that's not listening there at the moment. 605 00:43:08,840 --> 00:43:10,660 What we're going to do is we're going to create a service 606 00:43:10,660 --> 00:43:12,180 that actually is going to start Netcat 607 00:43:12,180 --> 00:43:13,320 then we're going to start that service running. 608 00:43:15,640 --> 00:43:18,260 As you can see we've specified which channel we're connecting to, 609 00:43:18,700 --> 00:43:20,100 what cipher we're going to be using, 610 00:43:20,200 --> 00:43:21,260 and we're also using a network. 611 00:43:21,280 --> 00:43:23,060 We're using our certificate 612 00:43:23,060 --> 00:43:24,680 that's been signed by our trusted CA. 613 00:43:27,120 --> 00:43:28,680 As you can see that's gone through all okay. 614 00:43:31,560 --> 00:43:33,140 And there we go, we've started Netcat running. 615 00:43:36,680 --> 00:43:38,200 In this case though, as you can see, 616 00:43:38,260 --> 00:43:42,120 we're only running as the restricted privileged MQ user 617 00:43:42,120 --> 00:43:43,440 so we've still got some work to do 618 00:43:43,440 --> 00:43:44,800 if we actually want to get admin on this box. 619 00:43:45,100 --> 00:43:47,880 But at least we've got a foothold onto that system now. 620 00:43:53,620 --> 00:43:54,800 Next thing we're going to look at now 621 00:43:54,800 --> 00:43:56,760 is actually executing a command using that trigger monitor 622 00:43:56,760 --> 00:43:57,760 that we saw previously. 623 00:44:09,360 --> 00:44:11,240 Now what this is going to do is it's going to execute the command 624 00:44:11,240 --> 00:44:12,720 you can see down the bottom of the screen there maybe, 625 00:44:12,760 --> 00:44:15,660 which is start Netcat listing on 6969 again. 626 00:44:16,940 --> 00:44:19,960 Let's just try telnetting to make sure that our service has died. 627 00:44:24,800 --> 00:44:26,240 And see an interesting thing here, 628 00:44:26,300 --> 00:44:28,000 we've got a response back from our queue manager saying 629 00:44:28,000 --> 00:44:28,720 we're not authorized. 630 00:44:29,520 --> 00:44:30,940 But let's see whether we are or not. 631 00:44:32,540 --> 00:44:32,940 Yep. 632 00:44:36,760 --> 00:44:39,320 This time, because we started our trigger monitor as administrator, 633 00:44:39,640 --> 00:44:40,800 we're now running as admin. 634 00:44:47,980 --> 00:44:49,820 So it all looks pretty bad at this point. 635 00:44:49,820 --> 00:44:52,880 Is there anything we can do to actually protect ourselves? 636 00:44:53,140 --> 00:44:53,900 Well the answer is yes. 637 00:45:02,540 --> 00:45:04,960 At a technical level there's a whole heap of things we can do. 638 00:45:08,560 --> 00:45:11,000 We need to make sure we protect all the default and admin channels, 639 00:45:11,160 --> 00:45:12,080 don't leave them wide open. 640 00:45:13,020 --> 00:45:14,860 We need to have a defense in depth approach 641 00:45:14,860 --> 00:45:17,160 that means we're not just relying on one security measure. 642 00:45:18,300 --> 00:45:20,600 If we actually combine some of these techniques 643 00:45:20,600 --> 00:45:23,200 of using SSL client certificates, 644 00:45:23,540 --> 00:45:25,680 we use security exits that have been properly audited, 645 00:45:26,880 --> 00:45:29,480 we can actually put together a much better security model 646 00:45:29,480 --> 00:45:30,580 for our installation. 647 00:45:32,340 --> 00:45:34,380 Now we've been able to execute PCF commands 648 00:45:34,380 --> 00:45:36,160 because something called the command server is running, 649 00:45:36,280 --> 00:45:38,260 which enables us to manage the command server remotely. 650 00:45:38,460 --> 00:45:39,640 We can turn that off. 651 00:45:39,800 --> 00:45:42,100 We can do all our admin on the console itself. 652 00:45:42,740 --> 00:45:44,440 So again, turning that on is going to, 653 00:45:44,460 --> 00:45:46,580 it's not going to stop an attacker gaining access 654 00:45:46,580 --> 00:45:47,460 to the message data, 655 00:45:47,600 --> 00:45:49,060 but it might stop them executing commands 656 00:45:49,060 --> 00:45:50,760 and actually altering your queue manager itself. 657 00:45:54,500 --> 00:45:56,900 Another recommendation, don't use channel auto-definition. 658 00:45:57,420 --> 00:46:00,440 I'm not sure in what circumstances people would use that. 659 00:46:02,100 --> 00:46:03,640 I've never actually seen that turned on. 660 00:46:06,040 --> 00:46:07,440 Make sure you're using SSL 661 00:46:07,440 --> 00:46:08,780 to protect your data over the network. 662 00:46:09,340 --> 00:46:11,220 Make sure you go through that key repository 663 00:46:11,220 --> 00:46:13,960 and remove all non-trusted CAs. 664 00:46:15,180 --> 00:46:17,780 Be very specific with your user filtering strings 665 00:46:17,780 --> 00:46:19,520 that you're using with your certificates. 666 00:46:21,140 --> 00:46:23,200 And make sure that the people that are issuing the certificates 667 00:46:23,200 --> 00:46:24,780 know what the limits are. 668 00:46:24,940 --> 00:46:27,960 So for example, if you need to grant the user admin access, 669 00:46:28,320 --> 00:46:30,160 make sure they're not then issuing a whole load 670 00:46:30,160 --> 00:46:31,500 of other admin-related certificates. 671 00:46:34,580 --> 00:46:35,920 If you're particularly paranoid, 672 00:46:36,220 --> 00:46:38,060 make sure you always clear the initiation queue 673 00:46:38,060 --> 00:46:39,560 before you start a trigger monitor running. 674 00:46:40,720 --> 00:46:42,200 And if you're using trigger monitors, 675 00:46:42,520 --> 00:46:43,940 make sure you run them with a lower standard. 676 00:46:43,960 --> 00:46:44,640 And make sure you have the lowest possible privileges. 677 00:46:49,960 --> 00:46:50,900 So at a high level, 678 00:46:51,880 --> 00:46:53,520 there's also a number of things we need to do. 679 00:46:53,900 --> 00:46:55,600 We need to make sure we look at the middleware. 680 00:46:55,960 --> 00:46:57,920 Make sure that the guys we're getting to test our systems 681 00:46:58,280 --> 00:47:00,280 don't just know about the web server and the database 682 00:47:00,280 --> 00:47:02,840 or the actual client application. 683 00:47:03,340 --> 00:47:05,380 Make sure that they can test this system properly. 684 00:47:06,760 --> 00:47:08,520 Make sure you use all the security features. 685 00:47:08,640 --> 00:47:09,940 Don't use one feature and say, 686 00:47:10,020 --> 00:47:11,340 okay, that's it, that's me protected. 687 00:47:13,360 --> 00:47:14,980 Use access control and encryption. 688 00:47:15,480 --> 00:47:18,000 And when there's security fixes out there, 689 00:47:18,060 --> 00:47:19,240 make sure you apply them. 690 00:47:23,560 --> 00:47:25,680 As I said, make sure the testing you have done is thorough. 691 00:47:25,760 --> 00:47:27,280 Make sure someone doesn't turn up with a scanner. 692 00:47:27,340 --> 00:47:29,360 Just scan your box and say, yep, that's okay. 693 00:47:30,960 --> 00:47:32,320 And look at the whole environment. 694 00:47:32,980 --> 00:47:35,200 A lot of clients of mine have different queue managers 695 00:47:35,200 --> 00:47:36,300 running on different systems. 696 00:47:36,620 --> 00:47:39,580 They'll have transmission queues and remote queues set up 697 00:47:39,580 --> 00:47:41,040 to allow different people access 698 00:47:41,340 --> 00:47:42,680 to queues on production systems 699 00:47:42,680 --> 00:47:44,360 because they have incompatible software 700 00:47:44,360 --> 00:47:46,260 or other bits and pieces like that. 701 00:47:46,460 --> 00:47:47,960 Make sure that when you're testing it, 702 00:47:47,980 --> 00:47:49,080 you're looking at the whole environment. 703 00:47:49,160 --> 00:47:51,500 There isn't some other route to get to your queue manager 704 00:47:51,500 --> 00:47:52,320 you've not looked at. 705 00:47:56,120 --> 00:47:58,040 Now I've talked about running a development 706 00:47:58,040 --> 00:47:59,960 and a production queue manager on the same system. 707 00:48:00,600 --> 00:48:01,860 The problem with that is 708 00:48:02,340 --> 00:48:04,200 if we're running them under the same user 709 00:48:04,980 --> 00:48:06,300 on the local system, 710 00:48:06,520 --> 00:48:07,960 if we manage to gain access 711 00:48:08,360 --> 00:48:09,540 to the operating system 712 00:48:10,020 --> 00:48:11,320 through our insecure data, 713 00:48:11,340 --> 00:48:11,940 through the development environment, 714 00:48:12,620 --> 00:48:14,140 we're then running with the privileges 715 00:48:14,140 --> 00:48:16,140 with which our production queue manager is running. 716 00:48:16,900 --> 00:48:19,040 So we might find that someone has circumvented 717 00:48:19,040 --> 00:48:20,940 all the controls on our production queue manager 718 00:48:20,940 --> 00:48:24,240 simply by using that development queue manager. 719 00:48:27,280 --> 00:48:29,020 There's also a whole other 720 00:48:29,020 --> 00:48:30,500 load of things I haven't talked about today. 721 00:48:30,640 --> 00:48:32,280 Cluster security and a whole load of other things. 722 00:48:32,880 --> 00:48:34,780 You need to make sure you look at those as well. 723 00:48:34,900 --> 00:48:36,880 That's something I haven't looked at in great detail 724 00:48:36,880 --> 00:48:38,760 thus far. It's probably something I'm going to move on 725 00:48:38,760 --> 00:48:39,300 to look at next. 726 00:48:43,740 --> 00:48:44,720 As I've just mentioned, 727 00:48:44,880 --> 00:48:45,700 are we safe now? 728 00:48:46,020 --> 00:48:47,660 Well, we can be reasonably safe 729 00:48:47,660 --> 00:48:49,360 if we put the right controls in place. 730 00:48:49,980 --> 00:48:51,340 There's still more to look at. 731 00:48:52,480 --> 00:48:53,580 It's a very complex 732 00:48:53,580 --> 00:48:54,800 state machine and protocol. 733 00:48:55,060 --> 00:48:57,140 Therefore, there's probably a whole load of 734 00:48:57,580 --> 00:48:59,500 bugs out there that we can find by fuzzing. 735 00:49:00,460 --> 00:49:01,960 We've done some limited fuzzing 736 00:49:01,960 --> 00:49:03,260 and we've found a couple of crashes. 737 00:49:03,520 --> 00:49:04,920 We've not had time to go and look at 738 00:49:04,920 --> 00:49:06,000 exactly what caused them. 739 00:49:06,380 --> 00:49:09,160 And if we do find that there's any issues with those 740 00:49:09,160 --> 00:49:10,480 we'll certainly be reporting those 741 00:49:12,940 --> 00:49:14,760 I haven't had a chance to look particularly 742 00:49:14,760 --> 00:49:17,080 at MQ on iSeries and ZEOS. 743 00:49:17,280 --> 00:49:19,020 They're two particularly interesting targets. 744 00:49:20,720 --> 00:49:22,920 We also get IBM recommending that we use Tivoli 745 00:49:22,920 --> 00:49:23,980 for all our remote administration. 746 00:49:24,340 --> 00:49:25,980 Maybe that's something we can have a look at. 747 00:49:27,400 --> 00:49:28,880 And how do other messaging solutions 748 00:49:28,880 --> 00:49:31,160 compare to WebSphere MQ? 749 00:49:33,480 --> 00:49:34,780 Are these issues in isolation 750 00:49:34,780 --> 00:49:36,820 or do we find the same kind of issues across different 751 00:49:36,820 --> 00:49:39,060 bits of software? That's something we really need to find out. 752 00:49:41,760 --> 00:49:42,760 So in a three line 753 00:49:43,240 --> 00:49:43,680 summary 754 00:49:46,120 --> 00:49:47,000 Do everything 755 00:49:47,000 --> 00:49:49,200 that it actually tells you to do with regard to security 756 00:49:49,200 --> 00:49:50,680 features. Don't just use a couple. 757 00:49:52,220 --> 00:49:53,060 As with anything 758 00:49:53,060 --> 00:49:54,940 new vulnerabilities can expose your environment 759 00:49:54,940 --> 00:49:56,060 can expose your software. 760 00:49:56,600 --> 00:49:58,400 And if you're using multiple layers of defense 761 00:49:58,400 --> 00:50:00,120 you're obviously going to be more protected. 762 00:50:03,960 --> 00:50:04,640 There's a few 763 00:50:05,120 --> 00:50:07,100 references in the back of this talk 764 00:50:07,100 --> 00:50:08,120 that you can have a quick look at. 765 00:50:09,160 --> 00:50:10,920 There's some excellent reading out there. 766 00:50:12,680 --> 00:50:14,020 And that's just about me done. 767 00:50:14,160 --> 00:50:16,140 I think we're going to go over to the QA room now. 768 00:50:16,280 --> 00:50:17,820 So if anyone's got any further questions 769 00:50:17,820 --> 00:50:19,680 follow me over there 770 00:50:19,680 --> 00:50:20,940 and we'll go through them there.