1 00:00:00,000 --> 00:00:11,500 Okay, so specifically what I'm going to be talking about is how an external attacker can gain access to the internal administrative interface of a lot of these standard consumer-grade home routers. 2 00:00:12,680 --> 00:00:16,400 First of all, though, my employer asked me to put this slide up. 3 00:00:17,000 --> 00:00:18,620 Basically, stop calling them. 4 00:00:18,800 --> 00:00:20,540 I did not do this work for them. 5 00:00:20,680 --> 00:00:23,420 I did this work, in fact, before I started working for them. 6 00:00:23,640 --> 00:00:25,520 So stop sending your death threats there. 7 00:00:25,640 --> 00:00:26,260 Send them to me. 8 00:00:26,260 --> 00:00:30,600 All right, so why did I choose home routers as a target? 9 00:00:30,800 --> 00:00:31,600 Well, they're easy. 10 00:00:31,880 --> 00:00:33,520 Their security is terrible. 11 00:00:35,100 --> 00:00:38,620 I had, like, 30 more screenshots I tried to fit on this slide. 12 00:00:38,760 --> 00:00:39,480 Just didn't work. 13 00:00:40,740 --> 00:00:48,620 And even if you figure, okay, my router doesn't have any bugs in it, which it probably does, most people just don't secure them very well. 14 00:00:48,900 --> 00:00:54,280 I mean, typically these are people who have no idea how to do anything related to networking or security. 15 00:00:54,600 --> 00:00:56,240 So the concept that they... 16 00:00:56,240 --> 00:00:59,720 They will securely configure a network device is just completely flawed. 17 00:01:01,760 --> 00:01:06,280 So how does an attacker gain access to the internal web interface of a router? 18 00:01:06,420 --> 00:01:07,400 Well, he's not on the LAN. 19 00:01:07,560 --> 00:01:10,220 So typically, it turns out, you can either do it one of two ways. 20 00:01:10,400 --> 00:01:12,940 Cross-site request forgery or DNS rebinding. 21 00:01:13,180 --> 00:01:17,360 Now, cross-site request forgery is really the most popular way because it's super simple. 22 00:01:17,520 --> 00:01:20,660 But it has a lot of drawbacks, especially when you're going after routers. 23 00:01:21,220 --> 00:01:26,060 First of all, there's typically no trust relationship between the client's browser and his router. 24 00:01:26,240 --> 00:01:28,000 Because they never log in to their routers. 25 00:01:28,380 --> 00:01:29,980 So you can't take advantage of that. 26 00:01:30,360 --> 00:01:35,500 Secondly, you can't fake a login if the router uses basic authentication. 27 00:01:36,180 --> 00:01:39,920 You know, everyone remember how you used to be able to do user, colon, password, at, and then URL? 28 00:01:40,340 --> 00:01:41,480 Yeah, that doesn't work anymore. 29 00:01:42,120 --> 00:01:46,780 IE doesn't even recognize that as a valid URL, and Firefox will pop a warning to the user. 30 00:01:47,700 --> 00:01:52,700 A lot of routers, well, not a lot of routers, some routers, such as this one that I'm going to be demoing later, 31 00:01:52,900 --> 00:01:56,160 actually have anti-cross-site request forgery mechanisms built in. 32 00:01:56,160 --> 00:01:59,300 So you can't do cross-site request forgery at all against those. 33 00:01:59,900 --> 00:02:04,780 And finally, of course, cross-site request forgery is limited by the same origin policy in the browser. 34 00:02:04,940 --> 00:02:06,620 That's always been its biggest limitation. 35 00:02:07,340 --> 00:02:11,500 And if you're not familiar with the same origin policy, basically, the browser says, 36 00:02:11,720 --> 00:02:16,140 okay, if you browse out to attacker.com and you load up some JavaScript from that site, 37 00:02:16,440 --> 00:02:19,700 that JavaScript can interact with any page on attacker.com, 38 00:02:19,860 --> 00:02:26,080 but it can't interact with google.com, or yahoo.com, or 192.168.1.1. 39 00:02:26,160 --> 00:02:30,240 And that's good because you don't want some random person's JavaScript interacting with your router, 40 00:02:30,360 --> 00:02:31,160 like we'll see later. 41 00:02:32,660 --> 00:02:34,440 So that's where DNS rebinding comes in. 42 00:02:34,660 --> 00:02:39,640 And DNS rebinding says, okay, if the browser is going to enforce security based on the domain name, 43 00:02:39,900 --> 00:02:42,580 let's just tell it that my domain's IP has changed. 44 00:02:43,160 --> 00:02:48,100 So the idea is you get someone to browse to your website, load up some JavaScript from attacker.com, 45 00:02:48,260 --> 00:02:53,580 and then say, oh, attacker.com's IP is now at 192.168.1.1. 46 00:02:53,720 --> 00:02:55,540 And the browser says, oh, okay, that's fine. 47 00:02:55,540 --> 00:02:57,960 And now that JavaScript can interact with the router. 48 00:02:58,820 --> 00:03:00,840 So this has been known for a really long time. 49 00:03:01,580 --> 00:03:03,980 DNS rebinding dates back to 1996. 50 00:03:04,860 --> 00:03:06,000 It's really old. 51 00:03:06,200 --> 00:03:12,360 And so browsers and plugins and everyone have put in these mitigations and band-aids to stop this. 52 00:03:12,660 --> 00:03:18,040 But they never really fixed the actual problem of DNS rebinding, which is a bad security model. 53 00:03:20,080 --> 00:03:24,380 And we also have services like OpenDNS, NoScript, and DNSWall. 54 00:03:24,380 --> 00:03:29,420 And basically all of these protections are designed to protect your internal network. 55 00:03:29,760 --> 00:03:33,700 And the way they do that is they say, okay, if you're an external domain, 56 00:03:33,980 --> 00:03:36,480 you shouldn't be resolving to an internal IP address. 57 00:03:36,780 --> 00:03:39,880 So they block anything that resolves to an internal IP. 58 00:03:42,000 --> 00:03:44,660 So there's a couple ways to do DNS rebinding. 59 00:03:45,100 --> 00:03:52,540 The method I'm going to present is my favorite because it's really the slickest of them all, I think. 60 00:03:53,060 --> 00:03:54,360 And it's better known as DNS rebinding. 61 00:03:54,380 --> 00:03:55,120 It's DNS load balancing. 62 00:03:55,260 --> 00:03:57,420 If you have any DNS admins in here, that's all it is. 63 00:03:58,520 --> 00:04:02,580 So if you do a DNS lookup on Google, you don't get one IP address back. 64 00:04:02,720 --> 00:04:03,260 You get five. 65 00:04:03,540 --> 00:04:09,440 And the reason that is is if you're going to Google on one IP and that IP suddenly goes down, 66 00:04:09,920 --> 00:04:12,640 your browser can automatically switch to the next IP address. 67 00:04:13,000 --> 00:04:14,500 And so it provides redundancy. 68 00:04:16,180 --> 00:04:19,340 But if we try to use this in a rebinding attack, 69 00:04:20,120 --> 00:04:24,060 we find that we can't actually use it to rebind to an internal IP address. 70 00:04:24,900 --> 00:04:28,320 So let's take a look at rebinding to a public IP first just to see how this works. 71 00:04:28,820 --> 00:04:33,580 All right, we have an attacker who has registered the domain name attacker.com. 72 00:04:33,720 --> 00:04:35,420 He legitimately owns that. 73 00:04:35,760 --> 00:04:41,300 And he has a server located out on the internet with an IP address of 1.4.1.4. 74 00:04:41,660 --> 00:04:47,900 Now, he wants to attack a public web server that has an IP address of 2.3.5.8. 75 00:04:47,940 --> 00:04:51,820 But he doesn't want to directly connect to that server. 76 00:04:51,940 --> 00:04:53,860 So he's going to proxy all of his requests. 77 00:04:54,380 --> 00:04:56,420 Through this random person's browser. 78 00:04:56,600 --> 00:05:00,340 And this person is sitting over here behind this firewall feeling very safe and secure. 79 00:05:00,800 --> 00:05:04,580 So what the attacker does is he has to get that browser to browse out to attacker.com. 80 00:05:04,800 --> 00:05:09,060 And the browser doesn't know where attacker.com is, so it does a DNS lookup. 81 00:05:09,660 --> 00:05:15,080 And the attacker's DNS server says, oh, yeah, I have two IP addresses, 1.4.1.4 and 2.3.5.8. 82 00:05:15,580 --> 00:05:18,120 Now, the browser has no way of verifying that. 83 00:05:18,280 --> 00:05:21,220 So it just trusts it and says, okay, you've got two IPs, that's fine. 84 00:05:21,720 --> 00:05:24,020 So the browser is going to try the first IP address first. 85 00:05:24,380 --> 00:05:26,260 Which is the attacker's legitimate IP. 86 00:05:27,060 --> 00:05:29,600 It's going to do a get request and the attacker will send back his JavaScript. 87 00:05:30,200 --> 00:05:34,940 Now, that JavaScript is going to immediately attempt a connection back to attacker.com. 88 00:05:35,300 --> 00:05:39,460 And the browser says, well, you came from attacker.com, you're going to attacker.com. 89 00:05:40,140 --> 00:05:42,200 My same origin policy is happy with that. 90 00:05:42,440 --> 00:05:46,640 But as soon as the browser attempts that connection back to the 1.4.1.4 server, 91 00:05:46,880 --> 00:05:49,520 that server responds with a TCP reset packet. 92 00:05:49,780 --> 00:05:52,880 So now the browser says, crap, that IP is down. 93 00:05:52,880 --> 00:05:54,780 Ah, but I have the second IP address. 94 00:05:55,060 --> 00:05:58,620 So it immediately switches over to the second IP, which is 2.3.5.8. 95 00:05:58,880 --> 00:06:00,000 Sends the request there. 96 00:06:00,320 --> 00:06:05,180 And as long as the 2.3.5.8 server doesn't care that the host header says attacker.com, 97 00:06:05,340 --> 00:06:10,500 which unless you're using virtual servers on your web browser, you probably don't. 98 00:06:11,440 --> 00:06:13,040 It'll just send back the HTML code. 99 00:06:13,220 --> 00:06:17,620 So now the attacker's JavaScript has full interactive access to this other website. 100 00:06:17,900 --> 00:06:22,540 And it can send requests and see the responses and parse them and send them back to the attacker if he wants to. 101 00:06:22,880 --> 00:06:24,620 And this has always worked. 102 00:06:25,520 --> 00:06:30,740 And, yeah, there are some security implications here for bypassing ACLs and that kind of thing. 103 00:06:31,160 --> 00:06:36,820 But the big problem has always been, okay, we don't want people interacting with stuff inside the network. 104 00:06:39,780 --> 00:06:43,700 So let's take a quick look at going after the internal IP. 105 00:06:44,000 --> 00:06:47,300 So I don't really care about that 2.3.5.8 server. That's not what I want. 106 00:06:47,440 --> 00:06:52,320 I want 192.168.1.1, which is the router. The client's router. 107 00:06:53,240 --> 00:06:58,040 Same scenario as before. Browser browsers out to attacker.com and has to do a DNS lookup. 108 00:06:59,200 --> 00:07:05,320 And now the DNS server says, oh, yeah, I have two IP addresses, 1414 and 192.168.1.1. 109 00:07:05,640 --> 00:07:12,340 The browser says, ah, you have two IP addresses but one of them is an RFC 1918 non-routable IP. 110 00:07:13,040 --> 00:07:19,240 So the browser will always try non-routable IPs first regardless of their order and the DNS response. 111 00:07:19,660 --> 00:07:22,860 So he's immediately going to just load up the router. 112 00:07:22,880 --> 00:07:24,900 And then he's going to load up the router's web page, which does the attacker no good. 113 00:07:25,100 --> 00:07:27,820 Because the attacker has zero presence in the browser now. 114 00:07:28,320 --> 00:07:31,100 Because the client never made a request out to his server. 115 00:07:32,280 --> 00:07:37,420 So you can basically rebind to any public IP you want but not to a private IP. 116 00:07:38,200 --> 00:07:44,080 But we can actually leverage this to attack the router because the routers have both a public and a private IP. 117 00:07:44,700 --> 00:07:50,000 And to understand how that we can actually accomplish that, let's take a look at how services get bound on the router. 118 00:07:50,280 --> 00:07:52,040 This is a screen. Well, yeah. 119 00:07:52,040 --> 00:07:56,440 A screenshot of a net set output from an open WRT router. 120 00:07:57,040 --> 00:08:00,500 Look at the interfaces. Look at how it's binding to interfaces. 121 00:08:00,780 --> 00:08:04,980 It binds to everything. All the services are bound to all interfaces. 122 00:08:05,700 --> 00:08:09,440 So these services are actually listening on your WAN interface. 123 00:08:11,040 --> 00:08:17,280 But what stops a random person out on the internet from connecting directly into them is your firewall rules. 124 00:08:17,580 --> 00:08:20,740 And these are very simplified, just what's pertinent to the talk, obviously. 125 00:08:20,740 --> 00:08:26,620 But basically this says, okay, my WAN interface is eth0. 126 00:08:27,440 --> 00:08:29,720 So I don't want people connecting in on eth0. 127 00:08:29,960 --> 00:08:32,660 So anything that comes in on eth0, drop it. 128 00:08:33,020 --> 00:08:36,680 And we'll accept everything else because everything else is an internal interface. 129 00:08:37,200 --> 00:08:39,800 And there's nothing really wrong with this. 130 00:08:40,280 --> 00:08:44,620 But you notice we're, again, applying security based on a name. 131 00:08:44,800 --> 00:08:47,500 The interface name. Not based on IP addresses. 132 00:08:47,880 --> 00:08:49,360 And where this comes back to bite us, 133 00:08:49,360 --> 00:08:54,640 is when you look at how the underlying operating system on the router handles IP packets. 134 00:08:55,160 --> 00:09:00,800 So RFC1122 defines two models for implementing an IP stack. 135 00:09:01,680 --> 00:09:03,420 The first is the strong model. 136 00:09:03,600 --> 00:09:05,300 And the second is the weak model. 137 00:09:06,000 --> 00:09:07,700 Which do you think is better? 138 00:09:09,940 --> 00:09:13,140 Well, actually, the weak model is the more prevalent of the two. 139 00:09:13,820 --> 00:09:17,160 It's used by Linux, BSD, and even previous to Windows. 140 00:09:17,460 --> 00:09:19,340 So if you take a look at this, 141 00:09:19,360 --> 00:09:20,480 if you take a look at how the weak model works, 142 00:09:20,660 --> 00:09:23,440 it says, okay, if I am any host, 143 00:09:23,540 --> 00:09:24,960 it doesn't matter if you're a router or anything, 144 00:09:25,120 --> 00:09:28,840 if you're a host and you have a packet come into you, 145 00:09:29,020 --> 00:09:30,340 you look at the destination IP, 146 00:09:30,640 --> 00:09:36,400 and if that destination IP matches any of your IP addresses on any of your interfaces, 147 00:09:36,920 --> 00:09:38,220 accept it and process it. 148 00:09:38,660 --> 00:09:41,520 So let's say I get a packet in on eth0, 149 00:09:42,220 --> 00:09:45,200 and the destination IP matches the IP on eth1, 150 00:09:45,440 --> 00:09:46,860 I'll still accept that packet. 151 00:09:47,080 --> 00:09:49,060 Because it's obviously intended for me. 152 00:09:49,360 --> 00:09:51,940 Even though it technically came in on the wrong interface. 153 00:09:53,200 --> 00:09:55,480 So let's look at all this in the context of the router. 154 00:09:56,000 --> 00:09:59,440 You've got a router with two interfaces, internal and external. 155 00:10:00,020 --> 00:10:03,880 The external interface is eth0 with an IP of 2358. 156 00:10:04,200 --> 00:10:08,740 So what happens when our internal client tries to browse to 2358? 157 00:10:09,220 --> 00:10:11,600 Well, he's going to send a TCP SYN packet to the router. 158 00:10:11,880 --> 00:10:13,620 Because the router is his default gateway. 159 00:10:14,300 --> 00:10:19,140 And the router is going to say, ah, well, this destination IP is one of my IP addresses. 160 00:10:19,360 --> 00:10:21,440 And it's going to port 80. 161 00:10:21,720 --> 00:10:24,140 And sure enough, I've got a service listening on port 80. 162 00:10:24,320 --> 00:10:26,680 Because remember, the services get bound to all interfaces. 163 00:10:27,140 --> 00:10:30,500 So there is in fact a service listening on 2358 port 80. 164 00:10:31,440 --> 00:10:33,200 And so it completes the three-way handshake, 165 00:10:33,280 --> 00:10:37,040 and now the browser has connected to the web server on the router, 166 00:10:37,120 --> 00:10:38,300 using the router's public IP. 167 00:10:39,160 --> 00:10:40,900 But we had that firewall rule, remember? 168 00:10:41,180 --> 00:10:43,960 The firewall rule that said block everything coming in on eth0? 169 00:10:44,180 --> 00:10:45,540 Why doesn't it block this connection? 170 00:10:46,560 --> 00:10:48,860 Well, if you look at the packet capture, 171 00:10:49,360 --> 00:10:51,860 the top window is eth0 and the bottom window is eth1. 172 00:10:52,480 --> 00:10:56,560 That router, that firewall rule that said block everything on eth0 173 00:10:56,560 --> 00:11:00,100 never got applied because there's never any traffic on eth0. 174 00:11:00,700 --> 00:11:05,240 The logic for the weak end system model occurs pre-routing. 175 00:11:05,420 --> 00:11:07,540 So nothing gets routed from eth1 to eth0. 176 00:11:07,800 --> 00:11:11,260 Everything gets accepted and processed on eth1, 177 00:11:11,440 --> 00:11:15,600 even though technically you're connecting to an IP address that's assigned to eth0. 178 00:11:16,260 --> 00:11:18,000 So ultimately what this means 179 00:11:18,000 --> 00:11:22,220 is an internal client can punch in the public IP of their router 180 00:11:22,220 --> 00:11:23,700 and get the internal interface. 181 00:11:24,300 --> 00:11:26,480 Okay, big deal. He's an internal client. 182 00:11:26,740 --> 00:11:28,600 He can access the internal interface anyway. 183 00:11:29,280 --> 00:11:33,260 But I as an external attacker can rebind an internal client 184 00:11:33,260 --> 00:11:37,640 to any public IP I want, including his router's public IP. 185 00:11:43,560 --> 00:11:45,880 So let's take a look at the same attack. 186 00:11:46,200 --> 00:11:47,340 But this time, 187 00:11:47,340 --> 00:11:50,200 instead of targeting 192.168.1.1, 188 00:11:50,280 --> 00:11:52,080 we target 2358. 189 00:11:52,760 --> 00:11:55,740 So again, internal client browses to attacker.com 190 00:11:55,740 --> 00:11:57,220 and has to do a DNS lookup. 191 00:11:58,760 --> 00:12:01,620 Now the DNS server sends back two IP addresses again. 192 00:12:02,180 --> 00:12:04,240 1414 and 2358. 193 00:12:05,880 --> 00:12:08,460 So browser tries 1414 first. 194 00:12:09,460 --> 00:12:10,860 Attacker sends back his JavaScript. 195 00:12:11,180 --> 00:12:13,600 That JavaScript tries to connect back to attacker.com 196 00:12:13,600 --> 00:12:17,060 and now the attacker's server sends back a TCP reset packet. 197 00:12:17,340 --> 00:12:20,260 Which forces the browser to switch to the 2358 IP, 198 00:12:20,540 --> 00:12:24,500 which the router accepts and sends back the HTML code 199 00:12:24,500 --> 00:12:25,780 for whatever the request is. 200 00:12:26,540 --> 00:12:30,640 So now an external attacker can provide an internal client 201 00:12:30,640 --> 00:12:33,180 with JavaScript that has full interactive access 202 00:12:33,860 --> 00:12:35,680 to the router's web interface. 203 00:12:35,940 --> 00:12:38,640 Even though that router has remote administration disabled. 204 00:12:40,760 --> 00:12:43,180 So this attack has a lot of advantages. 205 00:12:43,420 --> 00:12:46,300 First of all, the rebind is nearly instant. 206 00:12:46,300 --> 00:12:49,560 So if you're doing like an anti-DNS rebinding attack, 207 00:12:49,880 --> 00:12:51,400 you have to wait a certain period of time 208 00:12:51,400 --> 00:12:52,800 before you can actually do the rebind. 209 00:12:53,680 --> 00:12:55,820 I mean, as soon as the browser realizes, 210 00:12:56,020 --> 00:12:57,800 hey, I got a TCP reset packet, 211 00:12:58,380 --> 00:12:59,880 it switches over to the next IP. 212 00:13:00,640 --> 00:13:03,040 We also don't have to know the router's internal IP address. 213 00:13:03,280 --> 00:13:04,180 Which is really nice, 214 00:13:04,280 --> 00:13:07,280 because different vendors will have different default IPs 215 00:13:07,280 --> 00:13:09,860 and people can change their internal network 216 00:13:09,860 --> 00:13:11,080 and that kind of things. 217 00:13:11,240 --> 00:13:12,500 But we don't care about the internal IP 218 00:13:12,500 --> 00:13:14,040 because we're rebinding to the public IP. 219 00:13:14,300 --> 00:13:16,040 Which, by definition, is public. 220 00:13:16,300 --> 00:13:17,780 So we can get that pretty easily. 221 00:13:18,360 --> 00:13:20,800 And finally, this is just how browsers work. 222 00:13:21,880 --> 00:13:23,580 This works in all major browsers. 223 00:13:24,620 --> 00:13:25,880 But the downside is, 224 00:13:25,980 --> 00:13:28,740 we have some very specific requirements for the router. 225 00:13:29,120 --> 00:13:31,420 So the router basically has to have three requirements. 226 00:13:31,580 --> 00:13:34,340 It has to bind its web service to the WAN interface. 227 00:13:35,260 --> 00:13:38,200 The firewall rules have to be based on interface name 228 00:13:38,200 --> 00:13:39,400 or some other configuration 229 00:13:39,940 --> 00:13:41,720 that basically does the same thing. 230 00:13:42,520 --> 00:13:45,220 And it has to implement the weak end system model 231 00:13:45,220 --> 00:13:46,760 and its underlying IP stack. 232 00:13:47,420 --> 00:13:49,780 So not all routers are going to be vulnerable to this. 233 00:13:50,700 --> 00:13:53,980 I went ahead and tested 30 routers. 234 00:13:54,560 --> 00:13:56,200 It worked against 17 of them. 235 00:13:57,160 --> 00:14:01,020 And that includes stuff from Asus, Belkin, Dell, 236 00:14:01,240 --> 00:14:02,720 which I didn't know they made routers, 237 00:14:02,820 --> 00:14:03,580 but apparently they do. 238 00:14:04,680 --> 00:14:07,080 Thomson, which if anyone here is from the UK, 239 00:14:07,300 --> 00:14:08,560 these are pretty popular over there. 240 00:14:09,880 --> 00:14:12,100 I didn't get a chance to test the BT Home Hub, 241 00:14:12,220 --> 00:14:13,780 which is also really popular over there. 242 00:14:13,780 --> 00:14:15,580 But it's a rebranded Thomson, 243 00:14:15,680 --> 00:14:18,180 so there's a good possibility it'll work against that as well. 244 00:14:19,220 --> 00:14:20,260 Lots of Linksys. 245 00:14:20,660 --> 00:14:22,580 This works against a lot of Linksys devices. 246 00:14:23,060 --> 00:14:24,040 And I really like this slide 247 00:14:24,040 --> 00:14:25,300 because those bottom two routers, 248 00:14:25,400 --> 00:14:28,880 the 54GL and the WRT160N, 249 00:14:29,080 --> 00:14:33,000 are both on Amazon's top five most popular selling routers list. 250 00:14:34,280 --> 00:14:34,720 Awesome. 251 00:14:36,480 --> 00:14:38,200 So a lot of people put third party firmware 252 00:14:38,200 --> 00:14:40,400 on their Linksys routers, especially 54Gs. 253 00:14:40,620 --> 00:14:41,980 And it works against those too. 254 00:14:41,980 --> 00:14:45,600 Now, I will, in PFSense's defense, 255 00:14:45,960 --> 00:14:48,500 I will say they actually contacted me like a month ago 256 00:14:48,500 --> 00:14:51,680 when they saw this talk up on the Black Hat page 257 00:14:51,680 --> 00:14:52,480 and the DEF CON pages. 258 00:14:52,860 --> 00:14:55,180 And they actually have fixed this now. 259 00:14:55,360 --> 00:14:58,920 They have anti-DNS rebinding stuff in their beta release. 260 00:14:59,280 --> 00:15:00,480 So kudos to them for that. 261 00:15:06,960 --> 00:15:08,960 As far as I know, they're the only router 262 00:15:08,960 --> 00:15:11,200 that actually has any of that in it. 263 00:15:11,200 --> 00:15:12,520 So that was awesome. 264 00:15:12,700 --> 00:15:15,000 My favorite, though, are the action tech routers. 265 00:15:15,100 --> 00:15:17,480 Anyone here have Verizon, Fios, or DSL? 266 00:15:18,180 --> 00:15:19,840 That's it? Really? 267 00:15:20,720 --> 00:15:21,280 Okay. 268 00:15:21,340 --> 00:15:24,120 Well, everybody where I live has Verizon Fios. 269 00:15:24,300 --> 00:15:28,820 And I saw an article on some business site, 270 00:15:28,880 --> 00:15:30,820 I forget where it was now, just last week. 271 00:15:30,980 --> 00:15:35,640 And Verizon claims that they have 3.8 million Fios customers now. 272 00:15:35,840 --> 00:15:37,660 That's not DSL customers. 273 00:15:37,720 --> 00:15:40,500 That's just Fios customers. Internet customers. 274 00:15:41,860 --> 00:15:45,420 So I went ahead and I tested a lot of these action tech routers. 275 00:15:45,960 --> 00:15:50,280 The GT701 and 704 are both DSL routers. 276 00:15:50,400 --> 00:15:52,920 And those are distributed by Verizon and Quest. 277 00:15:54,200 --> 00:15:56,300 The MI424, there's two of them here. 278 00:15:56,620 --> 00:15:59,800 Revision C is on the bottom and Revision D is the one there on the right. 279 00:16:00,260 --> 00:16:02,320 Those are the Verizon Fios routers. 280 00:16:03,680 --> 00:16:06,900 And what's really interesting about the Fios routers, 281 00:16:07,000 --> 00:16:09,960 these action techs, MI424s, 282 00:16:11,200 --> 00:16:13,120 action tech doesn't actually make the firmware for them. 283 00:16:13,620 --> 00:16:18,020 They actually purchase third-party firmware called OpenRG, 284 00:16:18,140 --> 00:16:21,740 which is a Linux-based firmware, from a company called Jungo. 285 00:16:21,900 --> 00:16:25,980 And Jungo has partnerships with Linksys and U.S. Robotics 286 00:16:25,980 --> 00:16:28,620 and Belkin and obviously Action Tech and others. 287 00:16:28,840 --> 00:16:32,380 And they claim that this firmware is deployed 288 00:16:32,380 --> 00:16:34,000 in over 23 million households worldwide. 289 00:16:35,690 --> 00:16:36,380 Also awesome. 290 00:16:38,460 --> 00:16:39,120 So... 291 00:16:39,660 --> 00:16:43,720 We have a really big attack platform. 292 00:16:44,100 --> 00:16:46,360 There's a lot of people out there who are running routers 293 00:16:46,360 --> 00:16:48,460 that are potentially vulnerable to this. 294 00:16:49,080 --> 00:16:50,700 I mean, again, I only tested 30 routers. 295 00:16:50,720 --> 00:16:52,320 There's obviously more out there than that. 296 00:16:52,580 --> 00:16:54,160 But just based on the ones that I tested, 297 00:16:54,260 --> 00:16:56,800 there are millions of networks out there using these routers. 298 00:16:57,780 --> 00:16:59,800 So we have to take it a little step further. 299 00:16:59,900 --> 00:17:02,200 Now that we've proven the attack works, we have to make it practical. 300 00:17:02,580 --> 00:17:03,800 If you just go up to someone and say, 301 00:17:03,940 --> 00:17:06,440 oh, I can see your internal login for your router, 302 00:17:06,540 --> 00:17:07,180 they're like, who cares? 303 00:17:07,180 --> 00:17:10,980 So first of all, we have to make this an attack 304 00:17:10,980 --> 00:17:13,460 that the attacker can just, like, fire and forget. 305 00:17:13,640 --> 00:17:15,360 A complete drive-by attack. 306 00:17:17,260 --> 00:17:19,720 So we have to obtain the router's public IP 307 00:17:19,720 --> 00:17:22,480 before they ever do a DNS lookup on us. 308 00:17:23,580 --> 00:17:25,500 And that's actually fairly easy to do. 309 00:17:26,480 --> 00:17:29,400 But the bigger problem is we have to coordinate all our services. 310 00:17:29,520 --> 00:17:32,460 So the DNS server and the web server and the firewall 311 00:17:32,460 --> 00:17:36,820 all have to maintain the right state for each client that's browsing to you. 312 00:17:37,280 --> 00:17:39,100 And that requires a little custom code. 313 00:17:39,420 --> 00:17:41,740 And finally, we have to do something useful with it. 314 00:17:41,780 --> 00:17:43,220 Once we actually do the rebinding attack, 315 00:17:43,500 --> 00:17:45,080 we have to do something useful. 316 00:17:45,200 --> 00:17:47,660 Something that people will go, holy shit, that's bad. 317 00:17:49,620 --> 00:17:51,640 So I went ahead and wrote Rebind, 318 00:17:51,720 --> 00:17:54,120 which is probably the most cleverly named tool ever. 319 00:17:56,400 --> 00:17:59,580 So basically it does everything for you except register a domain name. 320 00:17:59,860 --> 00:18:02,200 It actually runs two web servers. 321 00:18:03,160 --> 00:18:04,480 It runs a DNS server. 322 00:18:04,660 --> 00:18:06,800 It interfaces with the IP tables firewall on Linux. 323 00:18:08,200 --> 00:18:11,940 It serves up JavaScript code to the client when they do the initial request. 324 00:18:12,320 --> 00:18:16,960 It also implements an HTTP proxy for the attacker to interface with the routers. 325 00:18:17,140 --> 00:18:20,280 And basically the HTTP proxy and the JavaScript code 326 00:18:20,280 --> 00:18:24,400 act together to forward requests from the attacker to the client. 327 00:18:24,520 --> 00:18:26,000 The client then sends it to the router. 328 00:18:27,340 --> 00:18:28,920 And the router sends it back to the client. 329 00:18:28,980 --> 00:18:30,000 And the client sends it back to the proxy. 330 00:18:30,080 --> 00:18:32,300 And the proxy sends it back to the attacker. 331 00:18:34,000 --> 00:18:34,440 So. 332 00:18:35,540 --> 00:18:37,160 I love the robot DevCon. 333 00:18:37,180 --> 00:18:37,600 He's incredible, by the way. 334 00:18:38,200 --> 00:18:38,880 He's awesome. 335 00:18:40,180 --> 00:18:42,980 So let's take a look at how this works when an attacker is running Rebind. 336 00:18:43,880 --> 00:18:45,140 Again, same scenario. 337 00:18:46,360 --> 00:18:51,480 But the attacker has now configured Rebind to run on his 1414 server. 338 00:18:52,200 --> 00:18:55,900 Now before the attacker can get someone to browse out to Rebind, 339 00:18:56,800 --> 00:18:58,760 he's got to configure his domain. 340 00:18:59,380 --> 00:19:01,300 So first of all, he has to register a name server. 341 00:19:01,660 --> 00:19:04,220 So if Rebind is going to be handling all your DNS lookups, 342 00:19:04,340 --> 00:19:05,980 you have to make sure all the DNS lookups 343 00:19:05,980 --> 00:19:09,840 come to the box that you're running Rebind from. 344 00:19:10,120 --> 00:19:14,240 So the attacker has to go into wherever he registered his domain, 345 00:19:14,440 --> 00:19:15,480 you know, GoDaddy or wherever, 346 00:19:15,680 --> 00:19:19,200 and has to register the 1414 IP as a name server. 347 00:19:19,440 --> 00:19:21,780 Just call it, you know, ns1.attacker.com. 348 00:19:22,080 --> 00:19:23,300 And then once that's done, 349 00:19:23,440 --> 00:19:27,060 it goes into his DNS configuration for the attacker.com domain 350 00:19:27,500 --> 00:19:31,700 and say, hey, my DNS server is ns1.attacker.com. 351 00:19:31,900 --> 00:19:35,020 So just make sure that all DNS lookups come to the box 352 00:19:35,020 --> 00:19:35,980 where Rebind's running. 353 00:19:36,200 --> 00:19:39,060 So Rebind can handle all the DNS lookups for your domain. 354 00:19:41,120 --> 00:19:46,700 So he gets the client to browse out to attacker.com slash init, I-N-I-T. 355 00:19:46,940 --> 00:19:49,780 So again, the client has to do a DNS lookup. 356 00:19:50,020 --> 00:19:54,500 But at this point, Rebind doesn't know the client's public IP 357 00:19:54,500 --> 00:19:58,400 because the source IP in your DNS packet that you receive 358 00:19:58,400 --> 00:19:59,820 is not going to be the client's. 359 00:19:59,840 --> 00:20:02,360 It's going to be some random DNS proxy or caching server. 360 00:20:03,240 --> 00:20:04,600 So Rebind's just going to say, 361 00:20:05,020 --> 00:20:06,940 I'm at 1414, gives it one IP address. 362 00:20:07,220 --> 00:20:07,840 That's it. 363 00:20:08,760 --> 00:20:11,480 But now the client says, okay, I know where you are 364 00:20:11,480 --> 00:20:15,900 and initiates ATSP connection to port 80 to do the get request. 365 00:20:16,400 --> 00:20:18,860 But now that he's connected directly to the Rebind server, 366 00:20:19,080 --> 00:20:21,740 Rebind server says, ah, now I have your public IP. 367 00:20:21,980 --> 00:20:23,640 Your public IP is 2358. 368 00:20:24,280 --> 00:20:28,140 So what the web server does is it generates a random subdomain 369 00:20:28,140 --> 00:20:32,940 of attacker.com and redirects the client to that subdomain. 370 00:20:33,960 --> 00:20:34,840 Now the client says, 371 00:20:35,020 --> 00:20:37,460 it's okay, this is an HTTP redirect, no problem. 372 00:20:38,040 --> 00:20:41,600 But it's a new subdomain, so I have to do a new DNS lookup. 373 00:20:42,320 --> 00:20:45,380 Now he does a DNS lookup on the new subdomain which... 374 00:20:45,380 --> 00:20:48,660 So by the way, Wacme was actually a randomly generated subdomain 375 00:20:48,660 --> 00:20:49,240 when I was testing. 376 00:20:50,100 --> 00:20:52,140 Yeah, I was like, oh, that's going in the slides for sure. 377 00:20:53,500 --> 00:20:57,760 So the client now has to do a DNS lookup for wacme.attacker.com. 378 00:20:58,840 --> 00:21:03,180 So the DNS server says, aha, I can't really see your... 379 00:21:03,180 --> 00:21:06,040 the actual client who's making this DNS lookup, 380 00:21:06,180 --> 00:21:10,840 but I know the web server just redirected 2358 to wacme.attacker.com. 381 00:21:11,060 --> 00:21:13,900 So if you're doing a DNS lookup for wacme.attacker.com, 382 00:21:14,080 --> 00:21:15,600 your IP must be 2358. 383 00:21:16,040 --> 00:21:18,440 So now he can send back the DNS response packet 384 00:21:18,440 --> 00:21:20,000 that has the two IP addresses in it. 385 00:21:21,220 --> 00:21:24,240 So again, as before, the browser tries the first one first 386 00:21:25,380 --> 00:21:27,380 and does the web request. 387 00:21:27,920 --> 00:21:30,420 And Rebind sends back its JavaScript code. 388 00:21:31,760 --> 00:21:33,160 Once the browser has it, 389 00:21:33,180 --> 00:21:33,840 Rebind tells that JavaScript code, 390 00:21:34,000 --> 00:21:36,140 Rebind tells the iptables firewall, 391 00:21:36,460 --> 00:21:39,680 block everything coming into port 80 from 2358 392 00:21:39,680 --> 00:21:41,560 with a TCP reset packet. 393 00:21:41,920 --> 00:21:44,240 So when the JavaScript attempts the connection back 394 00:21:44,240 --> 00:21:45,640 to the Rebind server, 395 00:21:46,340 --> 00:21:48,080 it gets a TCP reset packet. 396 00:21:48,300 --> 00:21:50,240 And now the browser is going to Rebind 397 00:21:50,240 --> 00:21:53,180 to the second IP address, which is the router's public IP. 398 00:21:53,520 --> 00:21:57,020 And so now the JavaScript has interactive access to the router. 399 00:21:58,020 --> 00:21:59,580 Now, once this happens, 400 00:22:00,800 --> 00:22:01,360 Rebind... 401 00:22:03,380 --> 00:22:05,960 Rebind queries back to port 81 on Rebind 402 00:22:05,960 --> 00:22:08,220 because it's still blocked on port 80, 403 00:22:08,320 --> 00:22:09,240 so it sends it to port 81. 404 00:22:09,680 --> 00:22:11,500 And basically, these are just pull requests saying, 405 00:22:11,580 --> 00:22:13,200 hey, what do you want me to do? 406 00:22:13,700 --> 00:22:16,260 And at this point, Rebind doesn't have anything for it to do, 407 00:22:16,300 --> 00:22:17,980 so it's not going to send back anything. 408 00:22:19,740 --> 00:22:22,000 But once these pull requests start coming back, 409 00:22:22,820 --> 00:22:26,440 the attacker sees the IP address pop up in the web interface. 410 00:22:27,840 --> 00:22:30,260 So all he has to do is click on that IP, 411 00:22:30,260 --> 00:22:33,940 and this request is going to go through the Rebind HTTP proxy. 412 00:22:34,460 --> 00:22:36,440 So Rebind says, okay, you want me to do a get request 413 00:22:36,440 --> 00:22:38,200 on the index page for 2358? 414 00:22:38,480 --> 00:22:39,100 No problem. 415 00:22:39,340 --> 00:22:42,000 So it holds the connection open to the attacker's browser, 416 00:22:42,960 --> 00:22:45,500 and when the next pull request comes back from the JavaScript, 417 00:22:45,840 --> 00:22:47,520 it says, yeah, I have something for you to do. 418 00:22:47,600 --> 00:22:48,380 Do a get request. 419 00:22:49,460 --> 00:22:51,160 And so the JavaScript does a get request, 420 00:22:51,640 --> 00:22:56,380 gets a response, sends the HTML code and the HTTP headers 421 00:22:56,380 --> 00:22:58,360 back to the Rebind server, 422 00:22:58,620 --> 00:23:00,240 which forwards it on to the attacker. 423 00:23:00,940 --> 00:23:04,420 And now the attacker sees the web page in his web browser. 424 00:23:04,620 --> 00:23:06,420 And he can click around and submit forms 425 00:23:06,420 --> 00:23:08,120 and pretty much do whatever he wants at that point. 426 00:23:09,360 --> 00:23:10,340 So, demo time. 427 00:23:11,620 --> 00:23:12,380 Now, it's... 428 00:23:20,260 --> 00:23:22,320 So the best way to find bugs in your code 429 00:23:22,320 --> 00:23:23,220 is to do a live demo. 430 00:23:25,480 --> 00:23:28,640 I found a really fun one in the middle of my Black Hat demo. 431 00:23:29,160 --> 00:23:30,240 So we'll see if it comes back. 432 00:23:30,240 --> 00:23:31,360 I think it crops up again here. 433 00:23:32,380 --> 00:23:36,460 So I've already had the Rebind server running on this box here. 434 00:23:37,360 --> 00:23:38,960 This other one is my internal client. 435 00:23:40,380 --> 00:23:42,480 This is the action tech Verizon Fios router. 436 00:23:44,120 --> 00:23:46,100 So as an attacker, all you have to do 437 00:23:46,100 --> 00:23:48,120 is once you've configured your browser to use Rebind 438 00:23:48,120 --> 00:23:50,920 as your HTTP proxy, just type in Rebind, 439 00:23:51,960 --> 00:23:52,980 and you get the web... 440 00:23:52,980 --> 00:23:54,160 Let me see if I can full screen for this 441 00:23:54,160 --> 00:23:55,100 so it looks a little better. 442 00:23:55,480 --> 00:23:57,360 Yeah, so you get the web interface there. 443 00:23:57,580 --> 00:23:59,480 So I'm going to get my client to browse out 444 00:23:59,480 --> 00:24:00,720 to the attacker.com domain. 445 00:24:00,860 --> 00:24:02,020 We should see him pop up over here. 446 00:24:08,420 --> 00:24:09,300 Hey, there he goes. 447 00:24:09,940 --> 00:24:12,260 All right, so now if I click on him, 448 00:24:12,300 --> 00:24:14,900 I should get the main page for the router. 449 00:24:15,400 --> 00:24:18,080 So that's the internal web interface for the router. 450 00:24:18,260 --> 00:24:20,080 Now, the action tech firmware, 451 00:24:20,320 --> 00:24:22,260 the firmware that runs here is actually kind of smart. 452 00:24:22,540 --> 00:24:24,740 It forces you to change the password, 453 00:24:25,480 --> 00:24:27,520 so trying to prevent, like, default passwords. 454 00:24:27,520 --> 00:24:30,200 But all of the Verizon techs change the password 455 00:24:30,200 --> 00:24:33,100 to password one, and no one ever changes that password. 456 00:24:44,360 --> 00:24:46,680 So we click OK, and we should get... 457 00:24:46,680 --> 00:24:47,520 Hey, we're in. 458 00:24:55,680 --> 00:24:57,400 So you only have this access 459 00:24:57,400 --> 00:24:58,980 for as long as the client's on your page. 460 00:24:59,220 --> 00:25:01,520 So it behooves you to go into the advanced settings 461 00:25:01,520 --> 00:25:02,700 and enable remote administration. 462 00:25:05,740 --> 00:25:07,880 And there are, like, seven pages you have to click through 463 00:25:07,880 --> 00:25:09,860 on this stupid firmware to do that, but that's OK. 464 00:25:12,580 --> 00:25:14,440 Yes, I want to proceed. Thank you. 465 00:25:15,980 --> 00:25:18,080 So I'm going to go ahead and enable remote telnet. 466 00:25:25,580 --> 00:25:26,520 There we go. 467 00:25:26,520 --> 00:25:28,040 OK, so the settings have been changed. 468 00:25:28,200 --> 00:25:28,680 We're done here. 469 00:25:29,180 --> 00:25:31,100 We've enabled remote telnet on that box. 470 00:25:40,380 --> 00:25:42,420 And the login's the same, admin password one. 471 00:25:43,920 --> 00:25:46,220 Now, this gives you this wireless broadband router shell. 472 00:25:46,600 --> 00:25:49,080 Just type in shell, and you get root. 473 00:25:57,440 --> 00:25:59,380 How am I doing on time, by the way? 474 00:26:00,740 --> 00:26:01,700 Where's my guy? 475 00:26:01,900 --> 00:26:02,540 How am I doing on time? 476 00:26:02,720 --> 00:26:03,040 How many? 477 00:26:03,760 --> 00:26:04,140 Awesome. 478 00:26:04,720 --> 00:26:06,740 OK, so I got time to do a little bit more with this. 479 00:26:07,040 --> 00:26:09,460 So these routers run Linux underneath, right? 480 00:26:09,780 --> 00:26:12,340 And they don't have a lot of really good tools on them, 481 00:26:12,400 --> 00:26:13,520 like netcat or wget. 482 00:26:14,040 --> 00:26:15,800 Some of them do, but this particular one doesn't. 483 00:26:16,520 --> 00:26:18,040 So I went ahead and cross-compiled 484 00:26:18,040 --> 00:26:20,320 a quick scanning slash TCP connect tool 485 00:26:20,320 --> 00:26:23,200 to run on the ARM-based processor that this thing has. 486 00:26:23,560 --> 00:26:25,920 And you don't really have a whole lot of networking tools, 487 00:26:25,920 --> 00:26:27,120 but you do have TFTP. 488 00:26:38,860 --> 00:26:39,680 Oh, yeah. 489 00:26:41,560 --> 00:26:44,600 So I just TFTP'd down the tools. 490 00:26:44,720 --> 00:26:45,760 I'll just mod it here real quick. 491 00:26:51,240 --> 00:26:53,600 All right, so now I can go ahead and scan IPs and ports 492 00:26:53,600 --> 00:26:55,840 on this internal network. 493 00:26:55,920 --> 00:26:58,860 And really, you can cross-compile anything you want 494 00:26:58,860 --> 00:26:59,680 and put it on here. 495 00:27:01,080 --> 00:27:03,560 The action tech guys actually do release 496 00:27:04,080 --> 00:27:07,240 some of their tool chain tools for doing that. 497 00:27:08,980 --> 00:27:10,820 So if you want to see a list of internal clients, 498 00:27:10,980 --> 00:27:12,100 of course, you can just do ARP. 499 00:27:12,500 --> 00:27:14,840 And there we see our one internal client, 500 00:27:14,960 --> 00:27:16,280 192.168.1.4. 501 00:27:17,100 --> 00:27:19,580 So we can do a quick scan on that one. 502 00:27:35,600 --> 00:27:37,200 All right, so here's port 80 open. 503 00:27:37,520 --> 00:27:40,100 So now you can just do a get request to port 80. 504 00:27:52,360 --> 00:27:54,840 Yeah, and you get whatever page is running on there. 505 00:27:54,840 --> 00:27:57,940 So you now have full access to the LAN. 506 00:27:58,080 --> 00:28:00,160 And all those cool LAN attacks that everyone's like, 507 00:28:00,240 --> 00:28:02,120 oh, that doesn't affect me because I have WPA2. 508 00:28:02,320 --> 00:28:03,460 Yeah, you can do those. 509 00:28:03,560 --> 00:28:03,880 It's fun. 510 00:28:10,320 --> 00:28:12,620 All right, but another important note 511 00:28:12,620 --> 00:28:14,420 is we're not really necessarily restricted 512 00:28:14,420 --> 00:28:16,320 to the main web interface. 513 00:28:16,900 --> 00:28:18,740 We can go after SOAP protocols, too. 514 00:28:18,940 --> 00:28:21,780 So universal plug and play, which how many people here 515 00:28:21,780 --> 00:28:24,620 have it enabled for their Xbox or their VoIP? 516 00:28:26,020 --> 00:28:28,460 Yeah, it doesn't require any authentication 517 00:28:28,840 --> 00:28:31,040 and lets me punch holes through your router all day long 518 00:28:31,040 --> 00:28:32,220 to internal clients. 519 00:28:32,660 --> 00:28:34,540 And we can interact with that using this attack. 520 00:28:34,860 --> 00:28:38,560 So even if you have a strong password on your web interface, 521 00:28:38,800 --> 00:28:40,120 you're still not necessarily secure. 522 00:28:41,760 --> 00:28:44,220 HNAP is another SOAP protocol you'll find on some routers. 523 00:28:44,340 --> 00:28:46,100 It's the Home Network Administration Protocol. 524 00:28:46,740 --> 00:28:49,720 I've only ever seen it on Linksys and D-Link routers. 525 00:28:49,780 --> 00:28:51,400 It's kind of a Cisco thing. 526 00:28:52,740 --> 00:28:54,300 But you can interface with that as well. 527 00:28:54,840 --> 00:28:59,700 It does require a login, but some implementations 528 00:28:59,700 --> 00:29:03,140 have been found to allow you to basically reconfigure 529 00:29:03,140 --> 00:29:04,200 the router without a login. 530 00:29:04,740 --> 00:29:06,560 So it's just another avenue of attack. 531 00:29:08,220 --> 00:29:11,080 We can also rebind, like I said, to any public IP. 532 00:29:11,280 --> 00:29:14,140 I mean, I'm obviously targeting routers because it's super fun. 533 00:29:14,400 --> 00:29:16,300 But we can rebind to anything. 534 00:29:16,560 --> 00:29:20,260 I can basically turn your browser into an on-demand botnet for me 535 00:29:20,260 --> 00:29:23,540 and proxy all of my web attacks through you. 536 00:29:23,540 --> 00:29:27,320 So guess whose IP address shows up in the server logs that I'm attacking? 537 00:29:27,580 --> 00:29:28,240 Not mine. 538 00:29:30,320 --> 00:29:31,640 So how do we protect ourselves? 539 00:29:37,320 --> 00:29:41,280 This way will work, but you're not going to have much fun on the internet. 540 00:29:42,220 --> 00:29:45,820 So first of all, you have to identify if you are vulnerable. 541 00:29:46,580 --> 00:29:48,980 Basically, if you can punch in the public IP of your router 542 00:29:48,980 --> 00:29:52,940 and you get the router login or the web interface, this attack will work. 543 00:29:52,940 --> 00:29:55,980 Because like I said, PFSense is the only router I know of 544 00:29:55,980 --> 00:30:01,180 that does any kind of validation of their HTTP host headers or anything like that. 545 00:30:02,460 --> 00:30:05,460 So let's say that you are vulnerable. This works. 546 00:30:06,600 --> 00:30:11,660 There are some very simple steps you can take to stop it as an end user. 547 00:30:12,600 --> 00:30:16,840 First of all, we can basically break any of those three requirements 548 00:30:16,840 --> 00:30:19,520 we have for the router, and if any of those are broken, 549 00:30:19,700 --> 00:30:20,740 the attack doesn't work. 550 00:30:22,940 --> 00:30:27,560 We can also reduce the impact of the attack just by basic security measures. 551 00:30:28,280 --> 00:30:30,940 So if you have sufficient access to your router, 552 00:30:31,020 --> 00:30:35,140 you may be able to change the services so that they only bind to the internal interface. 553 00:30:36,340 --> 00:30:39,700 A lot of these services, though, that are running on these are very, very simple. 554 00:30:39,820 --> 00:30:42,780 So even if you get command line access and you can reconfigure that, 555 00:30:43,680 --> 00:30:49,100 there's no guarantee that it will even allow you to tell it to only rebind to a single interface. 556 00:30:49,300 --> 00:30:51,540 A lot of them just bind to everything. 557 00:30:51,540 --> 00:30:54,040 All interfaces, and you can't control that. 558 00:30:55,300 --> 00:30:58,300 But if you can change that, that's a good way to stop the attack. 559 00:30:58,960 --> 00:31:00,860 You can also reconfigure your firewall rules. 560 00:31:01,220 --> 00:31:07,860 Basically anything coming from your internal interface that's going to your public IP, drop it. 561 00:31:08,640 --> 00:31:11,540 Now you notice I went ahead and I used the slash 16 562 00:31:11,540 --> 00:31:15,060 because as soon as your public IP changes, you'll have to update that rule. 563 00:31:15,400 --> 00:31:21,300 So go ahead and figure out the net block that your ISP uses to hand out as DHCP addresses. 564 00:31:21,540 --> 00:31:25,240 I just put that whole net block in and then you don't have to update the rule anymore. 565 00:31:27,460 --> 00:31:30,080 Disable HTTP and enable HTTPS. 566 00:31:30,360 --> 00:31:34,000 Now people here in this room, I hope that you know how to use SSH. 567 00:31:34,180 --> 00:31:36,160 If you can use SSH, please do. 568 00:31:36,360 --> 00:31:39,800 Again, a lot of consumer routers don't allow SSH, but that's fine. 569 00:31:40,800 --> 00:31:44,960 If you're enabling HTTPS, you have to disable HTTP. 570 00:31:45,900 --> 00:31:51,160 Just enabling HTTPS doesn't help you because that means I can still rebind to the HTTP interface. 571 00:31:51,160 --> 00:31:53,540 You have to make sure you also disable HTTP. 572 00:31:55,260 --> 00:31:57,120 Disable UPnP as well if you can. 573 00:31:57,320 --> 00:31:59,560 I know a lot of people rely on it, so that might be difficult. 574 00:32:01,480 --> 00:32:04,000 Some routers don't let you disable HTTP. 575 00:32:04,420 --> 00:32:06,500 There's just a checkbox to enable HTTPS. 576 00:32:06,940 --> 00:32:12,240 Some routers also bind the HTTP interface to multiple ports. 577 00:32:12,520 --> 00:32:15,680 So this one, for example, it runs on port 80 and port 8080. 578 00:32:15,900 --> 00:32:19,500 So when you disable HTTP, you have to make sure it disables all of that. 579 00:32:21,920 --> 00:32:25,260 Again, HNAP, that's a whole other talk in and of itself. 580 00:32:26,040 --> 00:32:28,280 But some routers don't let you disable that at all. 581 00:32:31,480 --> 00:32:34,740 If you don't have sufficient access to your router to do this, 582 00:32:34,880 --> 00:32:37,040 you can basically do the same thing on your host. 583 00:32:37,320 --> 00:32:39,760 Because I have to use the host to access the router. 584 00:32:39,860 --> 00:32:41,320 I'm proxying everything through your web browser. 585 00:32:41,820 --> 00:32:42,980 So basically do the same rule. 586 00:32:43,220 --> 00:32:45,820 Anything destined for your router's public IP, drop it. 587 00:32:45,960 --> 00:32:47,860 Or you can configure dummy routes. 588 00:32:48,080 --> 00:32:49,720 Anything going to your public IP, 589 00:32:49,720 --> 00:32:52,920 route it to your loopback address. 590 00:32:53,240 --> 00:32:56,420 The downside to this is you have to do it for every single device on your network 591 00:32:56,420 --> 00:32:59,760 and every single device that will ever connect to your network in the future. 592 00:33:00,040 --> 00:33:02,980 That includes your friend's iPad when he comes over. 593 00:33:05,180 --> 00:33:06,560 Basic security precautions. 594 00:33:08,340 --> 00:33:10,120 Change your default passwords, please. 595 00:33:10,500 --> 00:33:12,140 Just do it. It's a good idea. 596 00:33:12,780 --> 00:33:14,080 Keep your firmware up to date. 597 00:33:14,200 --> 00:33:16,620 Again, a lot of these routers have a lot of vulnerabilities in them. 598 00:33:16,980 --> 00:33:19,700 And if you're lucky, your vendor will actually pass 599 00:33:19,720 --> 00:33:20,080 them and patch them. 600 00:33:20,540 --> 00:33:21,760 So make sure you keep that up to date. 601 00:33:22,020 --> 00:33:23,900 And don't trust untrusted content. 602 00:33:24,200 --> 00:33:25,780 And yes, the Internet is untrusted. 603 00:33:28,960 --> 00:33:31,600 This is kind of a good suggestion. 604 00:33:31,900 --> 00:33:33,680 It's not really practical for most people. 605 00:33:33,780 --> 00:33:36,940 You can't tell them disable JavaScript or use NoScript. 606 00:33:37,160 --> 00:33:38,520 It's just too much of a hassle for them. 607 00:33:39,480 --> 00:33:41,320 But it's definitely something to be aware of. 608 00:33:42,440 --> 00:33:47,620 So for vendors, the problem is with the same origin policy in the browsers. 609 00:33:47,880 --> 00:33:49,040 I know I've seen people say, 610 00:33:49,040 --> 00:33:51,040 you can fix this in DNS. 611 00:33:51,340 --> 00:33:53,140 No, you can't fix this in DNS. 612 00:33:53,380 --> 00:33:54,680 It's not a DNS problem. 613 00:33:54,960 --> 00:33:58,040 And it's not really fair to blame DNS for this. 614 00:33:58,440 --> 00:34:00,840 Because the problem is that the same origin policy 615 00:34:00,840 --> 00:34:03,640 chose an insecure protocol that was DNS, 616 00:34:03,880 --> 00:34:05,180 which was never designed for security, 617 00:34:05,420 --> 00:34:07,800 and decided to base a security model on it. 618 00:34:08,140 --> 00:34:09,860 So it really needs to be fixed in the browsers. 619 00:34:11,260 --> 00:34:13,520 Implement the strong end system model on your routers, 620 00:34:13,580 --> 00:34:14,240 if you're a vendor. 621 00:34:15,360 --> 00:34:18,200 Also build DNS rebinding mitigations into the routers. 622 00:34:18,200 --> 00:34:20,580 That means checking your HTTP host setters, 623 00:34:20,680 --> 00:34:22,800 which is typically not terribly difficult. 624 00:34:24,740 --> 00:34:26,020 So, wrapping up. 625 00:34:26,140 --> 00:34:28,740 Yes, DNS rebinding does affect you. 626 00:34:28,820 --> 00:34:32,060 Yes, there are tools out there to attack your router, 627 00:34:32,180 --> 00:34:35,200 your internal resources with DNS rebinding. 628 00:34:35,560 --> 00:34:38,820 And ultimately, you are responsible for your network. 629 00:34:38,940 --> 00:34:40,600 You can't rely on vendors to fix this, 630 00:34:40,700 --> 00:34:42,880 because they'll either do it wrong or they won't do it at all. 631 00:34:43,060 --> 00:34:45,260 So make sure you go ahead and take mitigations yourself 632 00:34:45,260 --> 00:34:46,440 to fix your stuff. 633 00:34:47,520 --> 00:34:51,620 So with that said, the code for this should be on the DEF CON CDs. 634 00:34:53,000 --> 00:34:56,260 I'm also going to keep it updated on rebind.googlecode.com. 635 00:34:57,380 --> 00:35:00,700 Again, death threats, send them to my Gmail account, not to my work. 636 00:35:02,260 --> 00:35:04,780 And with that said, do we have time for Q&A or are we out? 637 00:35:06,820 --> 00:35:09,640 Okay, I'll be in room 113 if anyone has any questions. 638 00:35:10,100 --> 00:35:12,080 Also feel free to grab me if you see me walking around 639 00:35:12,080 --> 00:35:12,780 or send me an email. 640 00:35:16,440 --> 00:35:16,680 Thanks for watching.