BGP Flowspec
BGP Flowspec (Flow Specification) is a BGP extension that distributes traffic filtering rules between routers: which traffic to match and what to do with it — rate-limit, discard, redirect or mark it.
Definition
BGP Flowspec (Flow Specification) is an extension of the BGP protocol used to distribute traffic filtering rules. Instead of the information “where to send packets for a given prefix”, as in ordinary routing, Flowspec carries the information “which traffic to match and what to do with it”. A rule announced on one router travels over BGP sessions to many edge devices at once, which start applying it.
The current specification is RFC 8955 “Dissemination of Flow Specification Rules”, which replaced the earlier RFC 5575. The IPv6 variant is described in RFC 8956. Flowspec is one of operators’ basic tools for quickly limiting DDoS attacks: it stops traffic with specific characteristics at the network edge before it reaches the target.
The Polish Government Plenipotentiary for Cybersecurity’s recommendation on protecting internet service providers against DDoS mentions BGP Flowspec in point 4 as an example of automated mitigation: deploying mechanisms that rate-limit or discard traffic matching the characteristics of the observed attack.
How BGP Flowspec works
A Flowspec rule has two parts: match criteria and actions.
Match criteria
RFC 8955 defines the components used to describe a flow. The most important are:
- destination and source prefix — e.g. the attacked server address or a range of source addresses,
- IP protocol — e.g. UDP or TCP,
- ports — source, destination or any, e.g. the port from which responses of a service abused for amplification arrive,
- TCP flags — e.g. SYN packets without an established session,
- packet length — useful when an attack uses packets of a characteristic size,
- ICMP code, DSCP value and fragmentation.
The criteria are combined, so a rule can be very precise: “UDP traffic from source port 123 to address X longer than a given value”.
Actions
Actions are carried in BGP extended communities. RFC 8955 describes, among others:
- traffic-rate — a bandwidth limit for matched traffic; a value of 0 means discarding all traffic matching the rule,
- redirect — redirecting traffic to another routing instance (VRF), e.g. towards cleaning devices,
- traffic-marking — marking packets with a DSCP value so they are treated with lower priority further on.
BGP Flowspec in DDoS protection
Flowspec fills the gap between two extreme tools. RTBH drops all traffic to the attacked address — the attack stops, but the address also stops serving legitimate users. Diversion to a scrubbing center gives precise cleaning but requires a prepared agreement and infrastructure. Flowspec drops only traffic with the attack’s characteristics and lets the rest through.
Typical uses are:
- automated mitigation — an anomaly detection system analyses telemetry and announces a Flowspec rule itself when it detects an attack,
- protection against amplification — dropping or rate-limiting traffic from source ports of services abused in DRDoS attacks,
- fast manual response — the on-call engineer announces a rule from one place and it reaches all edge routers,
- mitigation at the upstream operator — some operators accept Flowspec rules from customers, so attack traffic is dropped before it reaches the customer’s link.
Point 4 of the recommendation also says what to do when Flowspec is not available: deploy stateless firewall filters and hardware bandwidth limiters (policers) on WAN interfaces.
Risks and limitations
Flowspec’s speed is also its biggest risk:
- A wrong rule spreads as fast as a correct one. A prefix that is too broad or a mistake in a port can cut off legitimate traffic across the whole network in a moment. Rules need validation before announcement and a procedure for withdrawing them quickly.
- Router hardware limits. The number of rules a router can program in hardware is limited; not every match component is supported by every platform.
- Trust between networks. An operator accepting rules from a customer must restrict them to that customer’s prefixes, otherwise the customer could filter someone else’s traffic.
- Mitigation only for attacks with a clear signature. Flowspec handles volumetric attacks with stable characteristics well, and application-layer attacks that look like legitimate traffic less well.
- It does not replace source filtering. Flowspec limits the impact of an attack, while uRPF and BCP 38 reduce the ability to spoof other parties’ addresses, on which many attacks rely.
BGP Flowspec from a company’s perspective
Most companies do not run their own Flowspec sessions — it is an operator tool. A company can still benefit from it indirectly by asking its internet service provider a few questions:
- Does the operator use Flowspec or equivalent filters in its network, and does it do so automatically?
- Does it accept Flowspec rules from the customer — for the customer’s prefixes — and on what terms?
- Who triggers filters on the customer’s request during an attack, and how quickly?
- How does Flowspec work together with anti-DDoS devices on the customer side?
Companies with their own AS number and a BGP session with the operator can agree to have rules accepted directly, which shortens the response to an attack to the time it takes to announce a rule.
It is also worth remembering that Flowspec works on data supplied by telemetry. Point 3 of the recommendation advises sampling traffic at layers L2–L4 on edge routers and switches, covering source and destination addresses, traffic intensity in packets, flows and bits per second, and TCP flags. Without such data it is hard to establish quickly which port, protocol and packet length the attack uses — and therefore hard to build an accurate rule. A company that monitors traffic at its own edge can hand the operator a ready description of the attack and so speed up the activation of filters. It is also good practice to prepare rule templates for the most common scenarios, such as a flood of DNS or NTP responses, and to test them in a quiet period.
We prepare the arrangements with the operator, including Flowspec rules and diversion to scrubbing, as part of the DDoS protection and scrubbing center service.
Summary
BGP Flowspec distributes traffic filtering rules using the same protocol that distributes routes. It allows traffic with attack characteristics to be dropped or rate-limited quickly on many routers at once, without cutting off the whole address. It does, however, require discipline: rule validation, knowledge of hardware limits and agreements with operators.