Skip to content

Commit 8c39d0c

Browse files
DHCP DOS Mitigation HLD in SONiC (#1651)
* DHCP Mitigation HLD * Images Added * MD Format Update * Updated Mitigation Strategy * Update DHCP Mitigation.md * Update DHCP Mitigation.md * Update DHCP Mitigation.md USE case * Reviewed * Updated Design as per COPP behavior * Changed Design image added * architecture added * Yang model range update * HLD Updated as per suggestions * added missing architecture image and sequence diagram
1 parent 2d85341 commit 8c39d0c

File tree

10 files changed

+296
-0
lines changed

10 files changed

+296
-0
lines changed

doc/DHCP Mitigation

Whitespace-only changes.
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
# DHCP DoS Mitigation in SONiC #
2+
3+
[© xFlow Research Inc](https://xflowresearch.com/)
4+
5+
## Revision History
6+
7+
|Revision No. | Change Description | Author | Date |
8+
|--------------|--------------------|-------------------------------|----------------|
9+
| 0.1 | Initial Version | Muhammad Ali Hussnain, Asad Raza | 11 April 2024 |
10+
11+
12+
## Table of Content
13+
14+
15+
- [Scope](#scope)
16+
- [Definitions/Abbreviations](#definitionsabbreviations)
17+
- [Introduction](#introduction)
18+
- [DHCP DoS Attack](##dhcp-dos-attack)
19+
- [DHCP Starvation Attack](##dhcp-starvation-attack)
20+
21+
- [Effects of DHCP DoS Attacks](#effects-of-dhcp-dos-attacks)
22+
- [Behavior of DHCP DoS Attack](#behavior-of-dhcp-dos-attack)
23+
- [DHCP DoS Mitigation](#dhcp-dos-mitigation)
24+
- [Current Behavior](#current-behavior)
25+
- [Proposed Behavior](#proposed-behavior)
26+
- [Design Changes](#design-changes)
27+
- [Requirements](#requirements)
28+
- [Architecture Design](#architecture-design)
29+
- [Sequence Diagram to Add Rate-limit](#sequence-diagram-to-add-rate-limit)
30+
- [Sequence Diagram to Delete Rate-limit](#sequence-diagram-to-del-rate-limit)
31+
- [SAI API](#sai-api)
32+
- [CLI/YANG model Enhancements](#cli/yang-model-enhancements)
33+
- [CLI Configuration Commands](#cli-configuration-commands)
34+
- [YANG Model](#yang-model)
35+
- [Testing Requirements](#testing-requirementsdesign)
36+
- [Unit Test Cases](#unit-test-cases)
37+
- [Warm Boot and Fastboot Design Impact](#warmboot-and-fastboot-design-impact)
38+
- [Future Work](#future-work)
39+
40+
41+
42+
### Scope
43+
44+
This high-level design document describes the implementation for mitigation of DHCP DoS attacks in SONiC
45+
46+
### Definitions/Abbreviations
47+
48+
| Sr No | Term | Definition |
49+
|-------|---------------|------------------------------------------------------------------------------------------------|
50+
| 1 | DHCP | Dynamic Host Configuration Protocol |
51+
| 2 | DoS | Denial of Service |
52+
| 3 | DORA | DISCOVER, OFFER, REQUEST, ACKNOWLEDGEMENT |
53+
| 4 | TC | Traffic Control |
54+
55+
### Introduction
56+
DHCP DoS attack mitigation aims to safeguard the network infrastructure by implementing a rate-limiting mechanism to mitigate the impact of DHCP Denial of Service (DoS) attacks.
57+
58+
There are two main types of DHCP attacks:
59+
- DHCP DoS (Denial of Service) - Focus of this HLD
60+
- DHCP Starvation
61+
62+
#### DHCP DoS (Denial of Service) Attack
63+
64+
In a DHCP DoS (Denial of Service) attack, an attacker floods the DHCP server with an overwhelming number of DHCP DISCOVER packets. This flood of DISCOVER packets consumes all available resources on the DHCP server, making it unable to respond to legitimate DHCP requests from other devices. This proposal focuses on DHCP DoS mitigation.
65+
66+
#### DHCP Starvation Attack
67+
68+
In a DHCP starvation attack, the attacker floods the DHCP server with a large number of DHCP request messages and accepts the DHCP server’s offers, exhausting the pool of available IP addresses that the DHCP server can assign. As a result, legitimate devices are unable to obtain IP addresses from the DHCP server, causing network connectivity issues for those devices. DHCP Starvation mitigation is out of scope of this HLD.
69+
70+
### Effects of DHCP DoS Attacks
71+
72+
73+
A switch forwards DHCP messages between clients and servers. A flood of DHCP DISCOVER packets affects the DHCP server. With a large number of DHCP DISCOVER packets the server becomes overwhelmed, leading to the following issues:
74+
75+
- #### Resource Exhaustion
76+
The DHCP server has finite resources such as CPU, memory, and network bandwidth. A flood of DHCP discover packets consumes these resources, causing the server to become overloaded and unable to process legitimate DHCP requests on the attacker VLAN effectively.
77+
78+
- #### Service Degradation
79+
The flood of DHCP discover packets causes service degradation for other clients served by the DHCP server. Legitimate DHCP requests experience delays or timeouts as the server struggles to handle the excessive volume of traffic on the attacker VLAN.
80+
81+
- #### Packet Loss
82+
The DHCP server experiences packet loss due to the overwhelming volume of DHCP DISCOVER packets. This can result in dropped DHCP requests from legitimate clients on the attacker VLAN, leading to connectivity issues and network downtime.
83+
84+
- #### Impact on Network Performance
85+
The flood of DHCP DISCOVER packets impacts the performance of the network infrastructure, including switches, routers, and other devices involved in forwarding DHCP traffic. Congestion caused by the flood can degrade overall network performance and affect the operation of other network services.
86+
87+
88+
### Behavior of DHCP DoS Attack
89+
90+
91+
<figure style="text-align:center;">
92+
<img src="../../images/dhcp_mitigation_hld/TOPOLOGY_DIA.drawio.png" width="60%" alt="DHCP DoS Attack Topology Diagram"/>
93+
<figcaption>Figure 1: DHCP DoS attack topology diagram</figcaption>
94+
</figure>
95+
96+
97+
98+
The above figure shows 2 different VLANs configured with 3 hosts and a DHCP server. Attacker and PC-1 are in Vlan-20 and DHCP-SERVER and PC-2 reside in Vlan-10.
99+
100+
As shown in the diagram, the attacker launches an attack on the DHCP server with a flood of DHCP DISCOVER packets. The attacker generates a large number of DHCP DISCOVER packets with spoofed MAC addresses and sends these packets to the switch. The switch forwards these packets to the DHCP server. The attack is shown in the following diagram .
101+
102+
103+
<figure style="text-align:center;">
104+
<img src="../../images/dhcp_mitigation_hld/Discover.png" width="80%" alt="Image captured from wireshark during instance of attack"/>
105+
<figcaption>Figure 2: Image captured from wireshark during instance of attack</figcaption>
106+
</figure>
107+
108+
109+
110+
Due to the huge number of DHCP DISCOVER packets, the server is busy processing the DHCP DISCOVER packets and is unable to respond to other clients on the same VLAN as the attacker. This demonstrates a successful DoS attack which overwhelms the DHCP server.
111+
112+
It can be seen in the screenshot below that a legitimate client (PC-1) is unable to be serviced by the DHCP server. After the continuous bombardment of DHCP DISCOVER packets, the DORA process fails to complete, indicating a potential Denial of Service (DoS) situation.
113+
114+
115+
<figure style="text-align:center;">
116+
<img src="../../images/dhcp_mitigation_hld/DORA.png" width="60%" alt="Incomplete DORA process during DoS attack"/>
117+
<figcaption>Figure 3: Incomplete DORA process during DoS attack</figcaption>
118+
</figure>
119+
120+
121+
### Current Behavior
122+
Currently in SONiC, a default system-wide DHCP rate limit of 300 packets per second is implemented through CoPP. Since this limit is system-wide, in the event of a DHCP DoS attack where the attacker sends packets at a rate greater than 300 packets per second, it will result in CoPP dropping most legal packets as there are a lot more illegal packets coming into the system.
123+
124+
### Proposed Behavior
125+
To ensure the availability of a DHCP server for legal clients across a network, rate-limiting must be implemented at a port level so the effects of an attacker stay limited to the port it is connected to.
126+
This can be achieved by removing the system-wide DHCP rate limit of 300 packets per second implemented through CoPP and replacing it with port-level rate limits implemented in the kernel via Linux Traffic Control (TC). This means CoPP won't restrict DHCP traffic anymore, allowing potentially harmful packets to reach the kernel where TC will be able to rate-limit ingress traffic according to rates defined for each port. This will effectively isolate the effects of a DHCP DoS attack to remain solely on the attacked port, successfully protecting clients connected to all other ports of the switch.
127+
128+
### Design Changes
129+
130+
To achieve this, a new entry “dhcp_rate_limit” will be added in the “PORT_TABLE” of config_db with a default value of 300 packets per second to ensure backward compatibility. CLI commands will be written to use this attribute in config_db. “Portmgrd” in the SwSS container will be modified to configure config_db rate-limits inside the kernel via TC commands.
131+
132+
Following are a few use cases of Traffic Control :
133+
- Filter packets on the basis of their properties (eg. IP protocols, source/destination ports and IP addresses, etc.) and drop them based on their behavior (ingress, egress, rate, etc.)
134+
- Change or modify the data if needed
135+
136+
Traffic control(TC) uses queuing disciplines (qdiscs) to help organize and manage the transmission of traffic through a network interface. A qdisc performs two main functions:
137+
- Enqueuing requests to place packets in a queue for later transmission
138+
- Dequeuing requests to select a packet from the queue for immediate transmission
139+
140+
When the user adds the "dhcp_rate_limit" entry in the “PORT_TABLE” of the config database, that limit is then enforced on the specified interface it corresponds to.
141+
DHCP traffic can be filtered and rate-limited by dropping all packets that exceed a user-defined rate, allowing legitimate clients to be serviced by a DHCP server despite an ongoing attack. This design provides a mechanism for DHCP rate-limiting on a specified port. Applying DHCP rate limit on a specific port requires two parameters:
142+
143+
- port
144+
The port on which the DHCP rate limit is to be applied.
145+
- rate
146+
(packets per second)An integer specifying a DHCP packet rate in packets per second.
147+
148+
Since traffic control(TC) only supports rates in the form of bytes per second, this value is multiplied by 406 (number of bytes that make up a DHCP discover packet).
149+
Upon running this command, an ingress queuing discipline is created on the specified port via traffic control(TC). Next, a traffic control(TC) filter is added to filter DHCP discover packets on protocol 17 (UDP) and destination port 67 (port used by DHCP) and a dropping action is applied to filtered incoming traffic. Incoming DHCP discover packets that exceed the rate are dropped to stop the attack from overwhelming the DHCP server.
150+
151+
A custom program (daemon) has been developed to monitor network traffic. This daemon continuously checks all network ports (tc qdisc) for signs of packet drops. If it detects increase in dropped packets on a specific port, it logs a message to a designated file. This log message serves as an alert for the user, notifying them about potential congestion and packet loss issues on the affected port.
152+
153+
### Requirements
154+
155+
- Support for Linux traffic control (tc) for implementing the rate-limiting mechanism
156+
- Support for CLI commands for configuring DHCP rate-limiting
157+
158+
### Architecture Design
159+
The overall SONiC architecture will remain the same. Changes are made only in the SONiC Utilities container, SwSS container, and Config_DB.
160+
161+
<figure style="text-align:center;">
162+
<img src="../../images/dhcp_mitigation_hld/DHCP_13May2.drawio.png" width="80%"/>
163+
<figcaption>Figure 4: Feature Design</figcaption>
164+
</figure>
165+
166+
### Sequence Diagram to add rate-limit
167+
168+
<figure style="text-align:center;">
169+
<img src="../../images/dhcp_mitigation_hld/sequence_diagram_add5.drawio (1).png" width="80%"/>
170+
<figcaption>Figure 5: Sequence diagram illustrating the process of deleting rate-limit for DHCP DoS mitigation</figcaption>
171+
</figure>
172+
173+
174+
### Sequence Diagram to Del rate-limit
175+
176+
<figure style="text-align:center;">
177+
<img src="../../images/dhcp_mitigation_hld/deleting_sequence.drawio.png" width="80%"/>
178+
<figcaption>Figure 6: Sequence diagram illustrating the process of deleting rate-limit for DHCP DoS mitigation</figcaption>
179+
</figure>
180+
181+
### Configuration & Management
182+
183+
#### CONFIG_DB Enhancements
184+
185+
New attribute “dhcp_rate_limit” will be added to “PORT_TABLE” to support DHCP mitigation rate.
186+
187+
"PORT":
188+
{
189+
"Ethernet0": {
190+
"admin_status": "up",
191+
"alias": "fortyGigE0/0",
192+
"index": "0",
193+
"lanes": "25,26,27,28",
194+
"mtu": "9100",
195+
"speed": "40000",
196+
"dhcp_rate_limit" : "300"
197+
}
198+
}
199+
200+
201+
202+
#### DB Migrator Enhancements
203+
204+
As there is a change in the schema for PORT in config DB. We have added a new "dhcp_rate_limit" field in db_migrator.py in order to support backward compatibility.
205+
206+
Existing Before Migration PORT TABLE Schema in Config_DB
207+
208+
"PORT":
209+
{
210+
"Ethernet0": {
211+
"admin_status": "up",
212+
"alias": "fortyGigE0/0",
213+
"index": "0",
214+
"lanes": "25,26,27,28",
215+
"mtu": "9100",
216+
"speed": "40000"
217+
}
218+
}
219+
220+
After Migration PORT TABLE Schema in Config_DB
221+
222+
223+
224+
"PORT":
225+
{
226+
"Ethernet0": {
227+
"admin_status": "up",
228+
"alias": "fortyGigE0/0",
229+
"index": "0",
230+
"lanes": "25,26,27,28",
231+
"mtu": "9100",
232+
"speed": "40000",
233+
"dhcp_rate_limit" : "300"
234+
}
235+
}
236+
237+
### SAI API
238+
239+
No SAI API change or addition is needed for this HLD.
240+
241+
242+
### CLI/YANG model Enhancements
243+
244+
##### CLI Configuration Commands
245+
246+
Proposed SONiC CLI commands (sonic-utilities)
247+
- config interface dhcp-mitigation-rate add [port] [packet-rate]
248+
- config interface dhcp-mitigation-rate delete [port] [packet-rate]
249+
- show interface dhcp-mitigation-rate
250+
251+
Background Linux TC commands
252+
- sudo tc qdisc add dev [interface] handle ffff: ingress
253+
- sudo tc filter add dev [interface] protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate [byte-rate] burst [byte-rate] conform-exceed drop
254+
- sudo tc -s qdisc show dev [port] handle ffff:
255+
256+
257+
##### YANG Model
258+
259+
New leaf “dhcp_rate_limit” will be added to support DHCP mitigation rate.
260+
261+
leaf dhcp_rate_limit {
262+
description: "dhcp rate limit ;
263+
type uint32 {
264+
range 0..8000;
265+
}
266+
}
267+
268+
269+
### Testing Requirements/Design
270+
271+
#### Unit Test cases
272+
273+
- Verify CLI to add DHCP rate on port
274+
- Verify CLI to delete DHCP rate on port
275+
- Verify CLI to display DHCP rates on all port
276+
- Verify CLI to check valid DHCP rate (rate must be greater than 0 packets per second)
277+
- Verify CLI to check validity of port/portchannel on add and delete commands
278+
- Verify CLI to restrict one DHCP rate per port
279+
*(previous rate must be removed before adding a new rate on an port)
280+
- Verify CLI to ensure rate limit exists on port before deleting
281+
282+
283+
#### Functional Test cases
284+
285+
- Verify DHCP rate has been said on interface
286+
- Simulate Excessive DHCP Traffic on interface
287+
- Verify DHCP packets has been dropped as per rate limit
288+
289+
290+
291+
### Warmboot and Fastboot Design Impact
292+
The existing warm boot/fast boot feature is not affected.
293+
294+
295+
### Future Work
296+
The scope of this HLD is limited to mitigating DHCP DoS attacks by rate-limiting the DHCP control packets. In the future, support for “DHCP Snooping” will also be provided to mitigate DHCP starvation attacks.
Loading

images/dhcp_mitigation_hld/DORA.png

17.7 KB
Loading
34.2 KB
Loading
369 KB
Loading
Loading
Loading
82.6 KB
Loading
Loading

0 commit comments

Comments
 (0)