TCP ACK Flood Mitigation: Detecting ACK, RST and FIN Floods
TCP ACK flood mitigation starts with recognizing the pattern: a large packet rate of small TCP segments carrying only the ACK, RST or FIN flag, aimed at hosts that have no matching connection. Flow data shows it as a pps spike with modest bps. The fix is to drop that traffic as early and as cheaply as possible, before conntrack and stateful firewalls have to process it.
These floods are popular because they are cheap to send and expensive to receive. A 40-byte packet costs the attacker almost nothing, but every packet forces a state lookup on your side.
Why ACK, RST and FIN floods hurt stateful devices
Stateless routers forward these packets at line rate. The trouble starts at the first stateful hop: a Linux host with conntrack, a firewall appliance, a load balancer or a NAT gateway.
- Per-packet state lookup. Every packet triggers a hash lookup and often a lock. At several Mpps, softirq CPU saturates long before the link does.
- Loose conntrack. Linux defaults to
nf_conntrack_tcp_loose=1, so a bare ACK with no prior SYN can create a conntrack entry in ESTABLISHED state. The default established timeout is five days. A spoofed ACK flood can fill the table with entries that will not expire for a long time. - Invalid-packet handling. Stray RST and FIN packets are tracked, marked INVALID or answered with RSTs. That is extra work and extra outbound pps.
- Challenge ACKs. If a spoofed RST or SYN lands inside the receive window of a real connection, modern stacks reply with a challenge ACK (RFC 5961). Under flood this adds outbound traffic. Linux limits it with
net.ipv4.tcp_challenge_ack_limit. - Session table exhaustion on appliances. Many firewalls allocate a session on the first packet they see, including non-SYN packets, depending on configuration.
If your box is already dropping packets with a full table, also check conntrack sizing and timeouts. This article focuses on keeping the junk out of conntrack in the first place.
Flow-based detection signals
You do not need packet capture to spot this. NetFlow v5/v9, IPFIX and sFlow all carry the fields you need.
What to look for
- pps up, bps flat. Per-destination pps rises 10x or more while bps barely moves. Average packet size sits around 40–60 bytes. 1 Mpps of 40-byte packets is only about 320 Mbps at L3, which looks harmless on an interface graph.
- TCP flags in flow records. In NetFlow/IPFIX the
tcp_flagsfield is the cumulative OR of flags seen in the flow. A legitimate TCP flow that completes will show SYN, ACK, PSH and FIN together. Flood flows show: - ACK flood:0x10only - RST flood:0x04or0x14(RST+ACK) - FIN flood:0x01or0x11(FIN+ACK) - One-packet flows. Many flows with exactly 1 packet and one of the flag values above are a strong signal.
- No reverse traffic. Inbound pps to a destination IP with no corresponding outbound data flows.
- Source diversity. Spoofed floods show a huge number of unique source IPs, often spread evenly across the address space. Reflected or botnet floods show more clustered sources.
- Port pattern. Random destination ports suggest hitting closed ports. A fixed port like 443 suggests the attacker wants to reach your application or load balancer.
Caveats
- Pure ACKs are legitimate. A client downloading a file sends a continuous stream of ACK-only packets to the server. Do not alert on ACK flags alone. Alert on high pps combined with short flows and no matching reverse traffic.
- With sampling (for example 1:1000), you will see flags on sampled packets only. That is fine for detecting a multi-Mpps attack but weak for small ones.
- RST and SYN-ACK floods can be backscatter from someone spoofing your addresses in a SYN flood against a third party. Check whether your hosts actually sent SYNs.
Example with nfdump (check filter syntax for your version):
nfdump -R /var/cache/nfdump -n 10 -s dstip/packets \
'proto tcp and flags A and packets 1'
For automated detection, per-IP and per-prefix pps thresholds are the most reliable trigger, because bps thresholds will miss this attack class. NixMon ingests NetFlow v5/v9, IPFIX and sFlow and applies per-IP/prefix bps and pps thresholds, so a pps-based rule fires even when bandwidth looks normal. For tuning, see pps vs bps thresholds and hysteresis in our earlier threshold guide.
Host-level filtering with nftables
Drop what you can before conntrack, in the raw priority hook, and make conntrack strict for the rest.
sysctl -w net.netfilter.nf_conntrack_tcp_loose=0
With loose tracking off, an ACK without a known connection becomes INVALID instead of creating an entry. Caveats: connections established before the change, HA failover onto a cold node, and asymmetric routing can all break.
table inet tcpflood {
set services { type inet_service; elements = { 22, 80, 443 } }
set protected4 { type ipv4_addr; flags interval; elements = { 192.0.2.0/24 } }
chain pre {
type filter hook prerouting priority raw; policy accept;
# impossible flag combinations
tcp flags & (fin|syn) == fin|syn drop
tcp flags & (syn|rst) == syn|rst drop
tcp flags & (fin|syn|rst|psh|ack|urg) == 0 drop
# TCP to closed ports, unless it looks like return traffic
ip daddr @protected4 tcp dport != @services \
tcp sport != { 53, 80, 443 } drop
}
chain input {
type filter hook input priority filter; policy drop;
ct state invalid drop
tcp flags & rst == rst meter rstflood { ip saddr limit rate over 50/second } drop
ct state established,related accept
tcp dport @services ct state new accept
}
}
Use the forward hook instead of input if this box routes traffic for VMs or customers. The legacy iptables equivalents:
iptables -t raw -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
iptables -t raw -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -t raw -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -m conntrack --ctstate INVALID -j DROP
Common mistakes
- Dropping all TCP to non-service ports on a hosting network. Servers that make outbound connections receive replies on ephemeral ports. Allow replies by source port, as above, or you will break updates, API calls and mail delivery.
- Rate-limiting RST globally. A global limit lets the attacker starve real connections. Use per-source meters, and accept that spoofed sources defeat per-source limits.
- Relying on
iptables -m staterules placed after conntrack. By then the entry exists and the CPU is spent.
Edge ACLs on routers
Router ACLs run in hardware on most platforms, so they are the cheapest place to drop closed-port traffic. They are stateless, so be careful.
Juniper (Junos):
firewall {
family inet {
filter PROTECT-TCP {
term bad-flags {
from {
destination-address 192.0.2.0/24;
protocol tcp;
tcp-flags "(syn & fin) | (syn & rst) | !(fin|syn|rst|psh|ack|urg)";
}
then { count bad-flags; discard; }
}
term closed-ports {
from {
destination-address 192.0.2.0/24;
protocol tcp;
destination-port-except [ 22 80 443 ];
source-port-except [ 53 80 443 ];
}
then { count closed-ports; discard; }
}
term rest { then accept; }
}
}
}
MikroTik RouterOS v7 (raw table, before connection tracking):
/ip firewall raw
add chain=prerouting protocol=tcp dst-address=192.0.2.10 dst-port=22,80,443 action=accept
add chain=prerouting protocol=tcp dst-address=192.0.2.10 src-port=53,80,443 action=accept
add chain=prerouting protocol=tcp dst-address=192.0.2.10 action=drop
Cisco IOS-XE: the established keyword matches ACK or RST, so it is not a flood filter. Use explicit port-based permits for service ports and a counted deny for the rest, and check counters to confirm the ACL is actually matching.
Always count matches first and confirm what you are dropping before switching to discard.
When ACLs are not enough: FlowSpec
If the attack targets an open port such as 443, port-based ACLs let it through. Match on destination, protocol, flags and packet length instead. With BGP FlowSpec you can push this to your edge routers from the detector. A conceptual rule (syntax differs per platform):
match destination 192.0.2.10/32; protocol tcp;
destination-port =443; tcp-flags ack; packet-length >=40 <=60;
then rate-limit 5000000 # or discard
Be careful here. Pure-ACK packets on port 443 are exactly what your legitimate clients send. A discard action will cut real users off. Prefer a rate-limit, or narrow the match with source prefixes, ports or a known-bad packet length. Test on one router first and watch your FlowSpec counters. For safety rules, see our FlowSpec guide.
RTBH is the last resort: it takes the victim IP offline for everyone, so it protects the rest of your network at the cost of that host.
When to escalate to a scrubbing tunnel
Escalate when:
- the attack exceeds what your edge hardware can drop in pps, or saturates your transit;
- you cannot separate attack from legitimate ACK/RST traffic with stateless matching;
- spoofed sources are spread so widely that per-source limits are meaningless;
- you are repeatedly using RTBH on revenue-generating IPs.
A scrubbing provider keeps connection state and can drop packets that do not belong to any real session. NixGuard Edge is built for networks with their own ASN and at least one /24. Your prefixes are announced from the scrubbing edge, and clean traffic returns over a GRE tunnel with a BGP session inside. It can run always-on or on-demand, so you can trigger it from detection and keep stateless ACLs and FlowSpec for smaller events.
A practical order of operations
- Alert on per-IP pps, not only bps.
- Check flow flags, packet size and reverse traffic to classify the attack.
- Apply raw-table drops and strict conntrack on hosts.
- Push closed-port and bad-flag ACLs to the edge.
- Use a narrow FlowSpec rule with a rate limit for open-port floods.
- Move the prefix to scrubbing if stateless filtering fails.
- Review afterward: which signal fired first, and how long did mitigation take?
You can test flow-based pps detection for this attack class with the 15-day free trial, with no credit card required.
Frequently asked questions
How do I tell an ACK flood from normal traffic in NetFlow?
Look for per-destination pps spikes with small average packet size, many one-packet flows whose cumulative TCP flags are only ACK (0x10), and no matching outbound data flows. ACK-only packets alone are normal, since clients send them during downloads, so combine flags with pps, flow length and reverse traffic.
Why does an ACK flood fill the conntrack table?
With nf_conntrack_tcp_loose=1, which is the Linux default, an ACK without a prior SYN can create an ESTABLISHED conntrack entry with a very long timeout. Setting it to 0 makes such packets INVALID so they can be dropped without creating state.
Can I block RST and FIN packets with a firewall rule?
Not outright, because legitimate connections use both to close. Drop impossible flag combinations, drop INVALID state, apply per-source rate limits and filter closed ports. For floods on open ports, use a narrow FlowSpec rate limit or scrubbing.
When should I use FlowSpec instead of RTBH for this type of flood?
Use FlowSpec when the attack can be matched by protocol, flags, port or packet length and you want to keep the victim IP online. Use RTBH only when the attack threatens your wider network and no safe match exists. Use scrubbing when you need stateful filtering.