Notes
IP spoofing
Start with the root weakness. The source address on an IP packet is just a field the sender fills in, and nothing checks it. An attacker can write any address there. The catch is that replies go to the forged address, not to the attacker, so spoofing is useless for holding a conversation but ideal for flooding and for blaming someone else. It is especially easy with UDP, which has no handshake to complete.
- an IP packet carries a source address, unverified
- an attacker can write any address there
- the reply goes to the forged address, not to them
- so: fine for floods, useless for a normal conversation
- UDP has no handshake: easy
The handshake
To see the next attack you need the TCP handshake. The client sends a SYN. The server answers with a SYN-ACK and, importantly, reserves a little memory for this half-open connection while it waits. The client replies with an ACK and data can flow. Notice the imbalance: the server commits resources after receiving a single cheap packet. That imbalance is the whole attack.
- client: SYN (let us talk)
- server: SYN-ACK (agreed) and it reserves memory for this half-open connection
- client: ACK (confirmed)
- now data can flow
- the server commits resources after only one packet
SYN flood
A SYN flood exploits it. The attacker sends a storm of SYN packets, often with spoofed source addresses, and never completes the handshake. The server reserves a slot for each one and waits for an acknowledgement that never arrives. The queue of half-open connections fills, and real clients are turned away. The server is not broken into. It is simply too busy holding the door for nobody to let anyone in.
- the attacker sends a storm of SYNs, often spoofed
- the server reserves a slot for each and waits for ACKs that never come
- the queue fills up real clients are turned away
- a classic denial of service
Resets and hijacking
A live connection can be attacked too. TCP identifies a connection only by addresses, ports and sequence numbers. An attacker who can observe or guess them can inject a packet that appears to belong to it. A forged reset tears the connection down. Forged data is session hijacking. Modern systems randomise sequence numbers, which makes blind guessing very hard, and TLS finishes the job: injected data fails its integrity check and is thrown away.
- a connection is identified by addresses, ports and sequence numbers
- guess or observe them and you can inject a packet
- a forged RST kills the connection
- forged data = session hijack
- far harder with random sequence numbers; TLS rejects injected data
Amplification
Spoofing and UDP combine into amplification. The attacker sends a small request to an open server, with the victim's address forged as the source. The server sends its much larger reply to the victim. Open DNS resolvers, time servers and exposed cache servers have all been used this way, multiplying an attacker's traffic many times over. Your duty as an engineer is not to be the amplifier: no open resolvers, rate limits, and no UDP services exposed without need.
- send a small UDP request with the *victim's* address as the source
- an open server sends its large reply to the victim
- DNS, NTP, memcached have amplified traffic many times
- fix: no open resolvers, rate limit, disable unused UDP
ICMP abuse
ICMP, the protocol behind ping and network error messages, gets abused as well. Ping sweeps map which hosts are alive. Forged redirect messages try to change a host's routing. And data can be hidden inside ping payloads as a covert channel. The temptation is to block ICMP completely, but that breaks useful things like path size discovery. The sensible setting is to ignore redirects, rate limit, and allow the message types the network actually needs.
- ping sweeps: map which hosts are alive
- ICMP redirects: tell a host to use a different route
- ICMP tunnels: hide data in ping payloads
- do not block it all: path MTU discovery needs it
- ignore redirects; rate limit
Filtering
Spoofing can be stopped where traffic enters a network. A router knows which addresses can legitimately arrive on each link, and can drop packets that claim an impossible source. On Linux that is reverse path filtering. For internet providers it is a practice known as BCP thirty eight. Cloud providers block spoofed packets from their virtual machines. The more networks filter, the less spoofing works anywhere. Hardening benchmarks include these kernel settings.
# drop packets whose source # could not arrive on this path net.ipv4.conf.all.rp_filter = 1 # ignore redirects, source routes net.ipv4.conf.all.accept_redirects=0 net.ipv4.conf.all.accept_source_route=0 ISPs: BCP 38 ingress filtering cloud: providers block spoofing
What protects you
In practice three layers do most of the work. Sane kernel network settings: SYN cookies, reverse path filtering and ignoring redirects, all of which the hardening benchmarks from Part one check. TLS everywhere, which makes injected or altered data worthless. And firewalls plus upstream DDoS protection for sheer volume. You will rarely fight these attacks by hand. Your job is to make sure the defaults are on and nothing you run can be used against others.
- hardened kernel defaults: SYN cookies, rp_filter, no redirects (CIS checks these)
- TLS everywhere: injected or altered data is rejected
- firewalls and upstream DDoS protection for volume
- do not run exposed UDP services you do not need
Common mistakes
Mistakes. Turning off SYN cookies because an old tuning guide said so. Running an open DNS resolver or time server that anyone can use as an amplifier. Exposing cache servers or other UDP services to the internet. Blocking all ICMP and breaking the network in subtle ways. Treating a source IP address as proof of identity, in firewall rules or in application logic. And still running plain-text protocols, where hijacking is easy.
- SYN cookies disabled by an old tuning guide
- open DNS resolver or NTP server on the internet
- memcached or other UDP services exposed
- blocking all ICMP
- trusting source IP as identity
- plain-text protocols
Say it like this
In the interview: in a SYN flood the attacker sends many SYN packets, often with spoofed sources, and never completes the handshake, so the server's queue of half-open connections fills and real clients are refused. SYN cookies mitigate it by encoding state in the SYN-ACK and storing nothing until a valid acknowledgement returns. I also tune the backlog and timeouts, and for large floods rely on upstream DDoS protection.
- "The attacker sends many SYNs, often spoofed, and never
- completes the handshake, so the half-open queue fills and real
- clients are refused. SYN
- cookies avoid storing state
- until a valid ACK returns; for large floods I add upstream
- DDoS protection."