Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco...

33
1 TF-CSIRT, 2002-Sep-21 © 2002, Cisco Systems, Inc. All rights reserved. Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT <[email protected]>

Transcript of Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco...

Page 1: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

1TF-CSIRT, 2002-Sep-21 © 2002, Cisco Systems, Inc. All rights reserved.

Black Hole RoutersDamir Rajnovic

Incident manager, Cisco PSIRT

<[email protected]>

Page 2: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 222TF-CSIRT, 2002-Sep-21

What will be covered

• Why?

• What?

• How?

Page 3: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 333TF-CSIRT, 2002-Sep-21

BHR – the Purpose

• To capture and characterize packets

• To assist mitigating DoS attacks

Page 4: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 444TF-CSIRT, 2002-Sep-21

Why routers?

• Capturing packets on a general purpose OS (e.g., Solaris, Linux) becomes questionable above certain speed limit

Page 5: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 555TF-CSIRT, 2002-Sep-21

Poor man comparison

50500500050000Pentium[1] (1.5GHz)

20200200020000R5000 (200MHz)

100ns1µs10µs100µstime between packets

107/

20Gbs

106/

2Gbs

105/

200Mbs

10000/

20.5Mbs

pps/

BW (256 bytes/packet)

[1]An estimate of 3 cycles/instruction

How fast packets are coming. Please note that this is only for the Illustration purposes and do not represent the real performance numbers.

Page 6: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 666TF-CSIRT, 2002-Sep-21

Why Not Use ACLs?

• The method is described at http://www.cisco.com/warp/public/707/22.html

access-list 169 permit icmp any any echo

access-list 169 permit icmp any any echo-reply

access-list 169 permit udp any any eq echo

access-list 169 permit udp any eq echo any

access-list 169 permit tcp any any established

access-list 169 permit tcp any any

access-list 169 permit ip any any

• The idea is to install it on the victim’s router

Page 7: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 777TF-CSIRT, 2002-Sep-21

Pitfals of Using ACLs?

• ACL will degrade a router’s performance

• Degradation severity will depend upon the following:

– ACL type

– ACL complexity

– Router type

– Network load

Page 8: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 888TF-CSIRT, 2002-Sep-21

BHR – What Is It?

• It is just another router!

• Dedicated for this purpose only

• Placed somewhere in your network

• No customers attached to it!

• Physically, it can be a small subnet with multiple router and workstation

Page 9: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 999TF-CSIRT, 2002-Sep-21

Characteristics of the BHR

• Router with quick packet dropping capability, e.g. Cisco 7200 with the fastest Network Processing Engine (NPE)

• iBGP peer in your network

Page 10: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 101010TF-CSIRT, 2002-Sep-21

Example of BHR In a Network

Peer B

Peer AIXP-W

IXP-E

Upstream A

Upstream A

Upstream A

Upstream A

Upstream B

Upstream B Upstream

BUpstream

B

POP

TargetTarget

NOC

Black Hole

Network

171.68.19.0/24

Page 11: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 111111TF-CSIRT, 2002-Sep-21

Preparing to Analyze an Attack

• Do not do it on the victim’s router

• Pull all the traffic to a BHR

• BHR should be able to withstand the attack (this is a hope!)

• Your links towards the BHR must be able to withstand the attack

Page 12: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 121212TF-CSIRT, 2002-Sep-21

Initial Stage of an Attack

Target of Attack

171.168.19.1 is attacked

171.168.19.0/24 – target’s network

Black Hole Network

* By NASA Hubble Space Telescope

*

Page 13: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 131313TF-CSIRT, 2002-Sep-21

Divert the Traffic From the Victim

Target of Attack

171.168.19.1 is attacked

171.168.19.0/24 – target’s network

Black Hole Network

Page 14: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 141414TF-CSIRT, 2002-Sep-21

Analyze the Attack

• The attack is pulled to BHR and from your aggregation router

• You can now classify the attack using ACL, Flow Analysis, Sniffer, etc.

• The objective is to minimize the risk to the network while investigating

Target of Attack

171.168.19.1 is attacked

171.168.19.0/24 – target’s network

Black Hole Network

Page 15: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 151515TF-CSIRT, 2002-Sep-21

What the Analysis Will Provide You

• What you will get:

–A packet type (UDP, TCP, ICMP, SYN, ACK,….) ⇒ ACL and rate limiting

–A volume (pps, Mbs) ⇒ Rate limiting

–An offending source IP addresses (dubious) ⇒ ACL and rate limiting

• What you will not get:

–Entry point(s) in your network

Page 16: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 161616TF-CSIRT, 2002-Sep-21

Possible Entry Points

Peer B

Peer AIXP-W

IXP-E

Upstream A

Upstream A

Upstream A

Upstream A

Upstream B

Upstream B Upstream

BUpstream

B

POP

TargetTarget

NOC

Black Hole

Network

171.68.19.0/24

?

??

?

?

Page 17: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 171717TF-CSIRT, 2002-Sep-21

Where To Apply Countermeasures

• By using BHR and Backscatter technique you can learn entry points of the offending traffic.

• Created by Chris Morrow and Brian Gemberling @ UUNET as a means of finding the entry point of a spoofed DOS/DDOS. http://www.secsup.org/Tracking/

Page 18: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 181818TF-CSIRT, 2002-Sep-21

Backscatter Concepts

• Drop the offending traffic at any entry router in the network

• Generate an ICMP destination unreachable for every dropped packet

• Collect some Unreachables from the spoofed sources at the BHR

• Read out which routers/interfaces are dropping the traffic

Page 19: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 191919TF-CSIRT, 2002-Sep-21

Backscatter - preparation

• Pick an unused IP address and route it to nowhere:

ip route 172.20.20.1 255.255.255.255 Null0

• Repeat this on every edge device

Page 20: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 202020TF-CSIRT, 2002-Sep-21

Where are edge routers?

Peer B

Peer AIXP-W

IXP-E

Upstream A

Upstream A

Upstream A

Upstream A

Upstream B

Upstream B Upstream

BUpstream

B

POP

TargetTarget

NOC

Black Hole

Network

171.68.19.0/24

Page 21: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 212121TF-CSIRT, 2002-Sep-21

Configuration of the BHR

• BHR advertising a large block of un-allocated address space with the BGP no-export community and BGP Egress route filters to keep the block inside. 96.0.0.0/3 is an example.

– Check with IANA for unallocated blocks: www.iana.org/assignments/ipv4-address-space

– BGP Egress filter should keep this advertisement inside your network.

– Use BGP no-export community to insure it stays inside your network.

Page 22: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 222222TF-CSIRT, 2002-Sep-21

BHR - preparation

Peer B

Peer AIXP-W

IXP-E

Upstream A

Upstream A

Upstream A

Upstream A

Upstream B

Upstream B Upstream

BUpstream

B

POP

TargetTarget

NOC

Black Hole

Network

171.68.19.0/24

BHR advertise 96.0.0.0/3

Page 23: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 232323TF-CSIRT, 2002-Sep-21

BHR configuration

router bgp 31337!redistribute static route-map static-to-bgp!! add a stanza to the route-map to set our special nexthop!route-map static-to-bgp permit 5match tag 666set ip next-hop 172.20.20.1set local-preference 50set origin igp

Page 24: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 242424TF-CSIRT, 2002-Sep-21

Backscatter Activation

• Only during attacks

• You must do the analysis first since the advertised block may need to be changed

• However, in most cases 96.0.0.0/3 should be fine since attackers are spoofing the whole IP range blindly

• The magic line is:ip route victimip 255.255.255.255 Null0 tag 666

Page 25: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 252525TF-CSIRT, 2002-Sep-21

Backscatter – Packet Exchange

Edge router BHRRemote router

victim_ip routed to Null0generate ICMP Unreachable

Type = TCP SYNSrc IP = valid_IPDst IP = victim_IP

Type = ICMP UnreachableSrc IP = edge_router_IPDst IP = valid_IP

Page 26: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 262626TF-CSIRT, 2002-Sep-21

Backscatter – Packet Exchange (Cont.)

Edge router BHRRemote router

victim_ip routed to Null0generate ICMP Unreachable

Type = TCP SYNSrc IP = 96.0.1.2Dst IP = victim_IP

Type = ICMP UnreachableSrc IP = edge_router_IPDst IP = 96.0.1.2

Page 27: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 272727TF-CSIRT, 2002-Sep-21

How To Display ICMPs

• The result is that you will start receiving ICMPs at the BHR

• Configure BHR with this ACLaccess-list 150 permit icmp any any unreachables log

access-list 150 permit ip any any

• And you will start seeing this….

Page 28: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 282828TF-CSIRT, 2002-Sep-21

Backscatter – the result

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.47.251.104 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.70.92.28 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.222.127.7 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.96.223.54 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.14.21.8 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.105.33.126 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.77.198.85 (3/1), 1 packet

SLOT 5:3w1d: %SEC-6-IPACCESSLOGDP: list 150 permitted icmp 171.68.66.18

-> 96.50.106.45 (3/1), 1 packet

Page 29: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 292929TF-CSIRT, 2002-Sep-21

Combating DoS

• When you managed to determine the entry point(s), you can apply ACL and/or rate limiting to them.

• Do not forget to withdraw the victim_IP route from the Null0!

Page 30: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 303030TF-CSIRT, 2002-Sep-21

Backscatter – Considerations

• You must have ICMP Unreachablesenabled on your edge routers.

• If ICMP Unreachables threaten to overload your edge device then rate limit them to some acceptable value (use ip icmp rate-limit unreachable command).

Page 31: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 313131TF-CSIRT, 2002-Sep-21

BHR configuration – Juniper example

#Setup the bgp protocol to export our special policy, like

# redistributing, NOTE: "XXX" is the IBGP bgp group... we don't

# want to send this to customers.

set protocols bgp group XXX export BlackHoleRoutes

#

# Set static route with right tag, set local-pref low, internal, no-export

# and set the nexthop to the magical next-hop.

#

set policy-statement BlackHoleRoutes term match-tag666 from protocol static tag 666

set policy-statement BlackHoleRoutes term match-tag666 then local-preference 50

set policy-statement BlackHoleRoutes term match-tag666 then origin igp

set policy-statement BlackHoleRoutes term match-tag666 then community add no-export

set policy-statement BlackHoleRoutes term match-tag666 then nexthop 172.20.20.1

set policy-statement BlackHoleRoutes term match-tag666 then accept

Page 32: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 323232TF-CSIRT, 2002-Sep-21

PSIRT contact details

• <[email protected]> for non-emergency <[email protected]> for emergencies

• +1 877 228 7302 (toll-free in North America)+1 408 525 6532 (elsewhere in the world)

• Contact TAC and ask for PSIRT

• http://www.cisco.com/go/psirt

Page 33: Black Hole Routers · 2003-03-13 · Black Hole Routers Damir Rajnovic Incident manager, Cisco PSIRT  ... Example of BHR In a Network Peer B Peer A IXP-W IXP-E

© 2002, Cisco Systems, Inc. All rights reserved. 333333TF-CSIRT, 24-Jan-2002