The main BGP/BGP4+ security hardening policies are as follows:
BGP/BGP4+ MD5 authentication
BGP/BGP4+ uses TCP as its transport layer protocol and considers a TCP packet valid as long as its source and destination IP addresses, source and destination port numbers, and TCP sequence number are correct. However, it is relatively easy for attackers to obtain most parameters in a TCP packet. To protect BGP/BGP4+ from attacks, you can configure TCP MD5 authentication for BGP/BGP4+ peers. For security purposes, you are advised to periodically change MD5 passwords configured for BGP/BGP4+ peers.
As MD5 is insecure, you are advised to use keychain authentication, which is more secure.
Keychain authentication
A keychain consists of multiple authentication keys, each of which contains an ID and a password. Each key in a keychain has a lifecycle, based on which keys are dynamically selected. After a keychain with the same rules is configured on the two ends of a BGP/BGP4+ session, authentication keys are dynamically selected to enhance BGP/BGP4+ attack defense.
CPCAR
For enabled services and protocols, a device can limit the rate at which packets are sent to the CPU. This helps protect the CPU from attacks and ensures the network operates as expected.
Route threshold-crossing control
In most cases, a BGP/BGP4+ routing table contains a large number of routes. However, excessive system resources may be consumed if a device receives many routes from a peer. To prevent this issue, you can set the maximum number of routes that the local BGP/BGP4+ device accepts from the peer.
You can also use the BGP/BGP4+ PAF file to limit the maximum number of routes that the device accepts from all BGP peers. This prevents the device from consuming excessive memory resources to process a large number of received routes, which would otherwise cause the device to restart.
Limitation on the number of AS numbers that can be contained in the AS_Path attribute
When a BGP/BGP4+ device receives a route, the device checks whether the number of AS numbers in the AS_Path attribute exceeds a specified threshold. If the number exceeds the threshold, the device discards the route. The device also performs this check before advertising a route, and does not advertise the route if the number exceeds the threshold. This prevents attacks initiated using maliciously constructed error messages with an extra-long AS_Path attribute.
Common attack methods are as follows:
Denial of service (DoS) attacks
To attack devices, attackers can send various types of packets. If the packets are anycast protocol packets or the destination IP address is the IP address of an interface (including a loopback interface) on a device, the device sends these packets to the CPU for processing. The processing consumes CPU and system resources, resulting in DoS. To address this problem, you can configure the whitelist function. When this function is enabled, the system delivers a whitelist after a BGP/BGP4+ session is created. For protocol packets that match the whitelist, the application-layer association module sends them to the CPU at a high bandwidth and rate; for those that do not match the whitelist, the module sends them to the CPU at the default bandwidth and rate. You can also limit the rate at which BGP/BGP4+ messages are sent to the CPU by configuring CPCAR for interfaces. This helps protect the CPU from attacks and ensures the network operates as expected.
Injection of numerous BGP/BGP4+ routes
BGP/BGP4+ runs on various types of devices, and the number of BGP/BGP4+ routes that a device supports depends on its CPU and memory resources. If a device receives more BGP/BGP4+ routes than it supports, the device will operate abnormally and fail to process services due to memory resource exhaustion. To prevent this issue, you can set a PAF-based route limit for the device or set the maximum number of BGP/BGP4+ routes that the device accepts from a single peer. With this configuration, the device discards routes that exceed the limit, preventing resource exhaustion if attackers inject large numbers of routes.
Construction of error BGP/BGP4+ messages
Attackers may initiate an attack on a device by constructing various types of error messages, such as messages with extra-long AS_Path attributes, with incorrect headers, with incorrect lengths, or with invalid next hops. To defend against such attacks, BGP/BGP4+ implements a policy of easy-in and difficult-out. This allows a device to discard error messages it receives without disconnecting peer relationships, ensuring service continuity. In addition, you can set the maximum number of AS numbers allowed in the AS_Path attribute of each message. This ensures that the device does not advertise or accept a route whose AS_Path attribute contains more than the maximum number of AS numbers, reducing the possibility of attacks.
Network packet attacks
It is relatively easy for attackers to obtain the majority of parameters in the 5-tuple of a packet. To protect BGP/BGP4+ from network packet attacks, take the following measures:
Use TCP MD5 authentication between BGP/BGP4+ peers to reduce the possibility of attacks.
Configure keychain authentication for BGP/BGP4+ sessions to enhance BGP/BGP4+ attack defense.
None
You can set an MD5 authentication password for a TCP connection so that TCP implements MD5 authentication for BGP/BGP4+. If authentication fails, no TCP connection can be established.
Run the display bgp peer [ { group-name | ipv4-address } log-info | [ ipv4-address ] verbose ] command to check BGP/BGP4+ peer authentication information.