Network Security Principles and the Threats to Network Communication
What secure network communication means (confidentiality, integrity, availability, authentication, nonrepudiation), the passive and active attacks against it, and why cryptography is the answer, with eavesdropping and tampering demonstrated against plaintext and TLS in the lab.
kvi5hnuCode Sprout team member13 min readOn this page
The protocols in this course were designed for a network of cooperating researchers. IP doesn't check who sent a packet, TCP doesn't hide what's in it, DNS believes the first answer it gets, and SMTP (the protocol that carries email between servers) lets anyone claim any sender address. Today the same protocols carry banking, medical records and government traffic across networks nobody fully controls. Part 13 covers how security was added on top of them: at the link layer (802.1X, MACsec), the network layer (IPsec, WireGuard), the transport layer (TLS), and for DNS (DNSSEC) and email (DKIM, SPF, DMARC).
This article sets up the vocabulary: which properties we want, who threatens them, and what kinds of attack exist. Then it shows two attackers at work in the course lab.
Kinds of attack
Attacks on networked systems come in roughly three families:
- Implementation attacks exploit bugs: a buffer overflow that lets a crafted packet run code on a server, a parser that crashes on a malformed header. One of the first Internet worms, in 1988, spread through a buffer overflow in a network service. Protocol design can't prevent these; careful implementation, memory-safe languages and sandboxing can.
- Attacks on people get users to do something harmful: run malware, type a password into a fake site (phishing, or spear phishing when aimed at a particular person). Software that runs against the user's interest is called malware. Large collections of compromised machines controlled remotely (botnets) send spam, steal credentials and launch denial-of-service attacks, and are rented out as a service.
- Protocol attacks use network protocols exactly as specified, but for unauthorized purposes: forging a source address, injecting a TCP reset, answering a DNS query before the real server does.
This part of the course is about the third family, and about the protocols built to defeat it.
What we want: security properties
The classic triad is CIA:
- Confidentiality: only the intended parties can read the information.
- Integrity: the information isn't changed, without that being detected, between sender and receiver.
- Availability: the information and service are there when needed.
Network protocols usually need three more:
- Authentication: the party you're talking to is who they claim to be, and the message really came from them (data origin authentication).
- Nonrepudiation: a party can't later deny having sent something, because someone else can verify the proof. Digital signatures can provide this; shared-key MACs (message authentication codes, keyed checksums covered in article 79; not MAC addresses) can't, because both sides hold the key.
- Auditability: there's a trustworthy record of what happened, for investigation afterwards.

Notice that none of these protocols provides availability. Cryptography can make an attack detectable, but it can't force a packet through a link that someone is flooding or cutting.
Who threatens it: passive and active attackers
Security literature uses a small cast. Two parties want to talk securely. Eve, an eavesdropper, can see their traffic but not change it. Mallory, a malicious attacker, sits in the path and can do anything with the packets.

Passive attacks only observe:
- Eavesdropping reads the contents. On a shared Wi-Fi network, a tapped fiber or a compromised switch, it requires no more than a packet capture.
- Traffic analysis learns from the traffic's shape even when the contents are encrypted: who talks to whom, when, how much, and in what pattern. Packet sizes and timing can reveal which page of a site someone is reading, or that a video call is happening.
Passive attacks leave no trace, so the defense has to be prevention: encryption, and for traffic analysis, padding or hiding metadata.
Active attacks change the traffic:
- Message modification alters, deletes or reorders data in transit. When the attacker also relays the traffic between both sides, intercepting and possibly rewriting it, it's called a man-in-the-middle (or on-path) attack.
- Replay sends a copy of an earlier, genuine message, such as "transfer 100 to account 1234," again later.
- Impersonation (masquerading, or a spurious association) pretends to be one of the parties: a fake Wi-Fi access point, a forged DNS answer, a server with a fraudulent certificate.
- Denial of service stops communication, by dropping packets or by flooding a host or link.
Active attacks can usually be detected by cryptographic checks, but not always prevented, because an attacker who controls the path can always drop everything.
The two attackers in the lab
In the course lab, the client (192.0.2.10) talks to the server (198.51.100.10) through the router r1. The router plays both attackers.
Eve reads plaintext
First, the client fetches a page over plain HTTP with a username and password (HTTP Basic authentication), while Eve captures at the router:
192.0.2.10 GET /index.html Basic YWxpY2U6UGw0MW5UZXh0LVB3 alice:Pl41nText-Pw
Balance for ACCT-1234: 2,500.00
The first line shows, from left to right, the client's address, the HTTP method and path, the Authorization header Eve captured, and tshark's own decoding of it. The second line is the page body. The password travels base64-encoded (a reversible way of writing bytes as letters and digits), which is an encoding, not encryption: tshark decodes it to alice:Pl41nText-Pw without being asked. The page itself, the account balance, is in the capture too.
Then the same request over HTTPS (TLS 1.3, article 83), with the same capture:
17 192.0.2.10 SNI=www.example.com record types=22 lengths=1570
19 198.51.100.10 SNI=- record types=22,20,23,23,23,23 lengths=1210,1,23,456,95,69
21 192.0.2.10 SNI=- record types=20,23 lengths=1,69
22 192.0.2.10 SNI=- record types=23 lengths=158
23 198.51.100.10 SNI=- record types=23 lengths=250
24 198.51.100.10 SNI=- record types=23 lengths=250
25 198.51.100.10 SNI=- record types=23 lengths=93
26 198.51.100.10 SNI=- record types=23 lengths=19
28 192.0.2.10 SNI=- record types=23 lengths=19
Each line is one packet: frame number, sender, the server name if one is visible, and the TLS records it carries with their lengths in bytes. TLS record type 22 is a handshake message, 20 is a 1-byte change-cipher-spec message kept only for compatibility with old middleboxes, and 23 is encrypted data. Eve can no longer read the password or the page. Apart from the ClientHello and the start of the server's reply, every record is type 23: encrypted handshake messages and then application data. But traffic analysis still works:
- The server name
www.example.comis in the ClientHello in plaintext (the SNI, Server Name Indication, extension). Encrypted Client Hello (ECH, article 83) is designed to hide it. - The sizes are visible. The 1,570-byte ClientHello is that large because it carries a post-quantum hybrid key share (article 79), and the 250-byte server records are the response. A page of known size can often be identified this way.
- The addresses and ports, and timing, are visible as always.
Mallory rewrites plaintext, and is caught by TLS
Next the server sends a short instruction, AMOUNT=0100 TO=ACCT-1234, over plain TCP (port 7000) and over TLS (port 7443). Without interference, both arrive intact:
AMOUNT=0100 TO=ACCT-1234
AMOUNT=0100 TO=ACCT-1234
Now Mallory adds two nftables rules on the router. The first rewrites four bytes of the TCP payload, 0100 into 9900, in the plain connection. The second overwrites four bytes inside each TLS application data record (type 0x17):
ip saddr 198.51.100.10 tcp sport 7000 @ih,56,32 0x30313030 @ih,56,32 set 0x39393030
ip saddr 198.51.100.10 tcp sport 7443 @ih,0,8 0x17 @ih,96,32 set 0xdeadbeef counter packets 0 bytes 0
@ih,56,32 means "32 bits starting at bit 56 of the TCP payload" (ih is the inner header, the data after the TCP header). Bit 56 is byte 7, just after the 7 characters AMOUNT=. 0x30313030 is the ASCII text 0100, and 0x39393030 is 9900. The TLS rule matches a payload whose first byte is 0x17 (record type 23) and overwrites bytes 12 to 15 with 0xdeadbeef.
nftables recomputes the TCP checksum after the change, so the packets look perfectly valid to TCP. The result:
AMOUNT=9900 TO=ACCT-1234
error:0A000119:SSL routines:tls_get_more_records:decryption failed or bad record mac
error:0A000139:SSL routines::record layer failure
The plain connection delivered AMOUNT=9900 to the application, and nothing anywhere noticed. TCP's checksum detects accidental corruption, not deliberate changes: anyone who can change the data can recompute the checksum. The TLS client, on the other hand, rejected the modified record with "decryption failed or bad record mac" and closed the connection. TLS's authenticated encryption detected the change. The router's counter confirms it did tamper with the TLS records:
counter packets 4
That's the general pattern. Cryptography turns Mallory's undetectable modification into a detectable failure. It can't make the connection work in spite of Mallory: the TLS connection failed. Integrity protection protects against being fooled, not against being stopped.
Physical security, and why it isn't enough
One way to stop Eve and Mallory is to make sure only trusted people can reach the wires: locked wiring closets, private leased lines, guarded data centers. This still matters, but it can't scale to a network that crosses continents and other people's equipment, and it doesn't work at all for radio, which anyone nearby can receive.
The practical answer is cryptography: mathematical techniques that make eavesdropped data useless to anyone without the key, and modifications detectable by anyone with it. Used correctly, cryptography renders passive attacks ineffective and active attacks detectable. Article 79 covers the building blocks: symmetric ciphers, public-key cryptography, key exchange, hashes and MACs.
Common questions
Isn't TCP's checksum a form of integrity protection?
Only against accidents. It's a simple 16-bit sum that anyone can recompute, as the lab's nftables rule did automatically. Integrity against attackers needs a keyed function, such as a MAC or an AEAD (authenticated encryption with associated data) cipher's authentication tag, that can't be recomputed without the key.
If traffic is encrypted, what can an eavesdropper still learn?
Addresses, ports, timing, packet sizes and, in TLS without ECH, the server name. DNS queries are visible too unless they use DNS over HTTPS, TLS or QUIC. Over time that metadata can reveal a lot, which is why ECH, encrypted DNS and VPN (virtual private network) tunnels exist.
What's the difference between authentication and nonrepudiation?
Authentication convinces you who sent a message. Nonrepudiation lets you convince someone else. A MAC with a shared key authenticates, but since you hold the same key you could have created it yourself, so it proves nothing to a third party. A digital signature made with a private key only the sender holds can.
Can encryption stop a denial-of-service attack?
No. It can make some attacks cheaper to reject (for example, dropping packets that fail authentication early) and protocols use cookies to avoid spending effort on unverified clients. But an attacker who controls the path, or floods it, can always prevent delivery.
Why is replay an attack if the message is genuine?
Because its meaning depends on context. "Pay 100" sent twice pays 200. Protocols defeat replay by making each message unique: sequence numbers in IPsec and TLS, nonces in handshakes, timestamps in Kerberos and DNSSEC signatures.
Summary
- Attacks target implementations (bugs), people (malware, phishing) or protocols (forged, modified or replayed traffic). Part 13 is about protocols.
- Desired properties: confidentiality, integrity and availability, plus authentication, nonrepudiation and auditability.
- Passive attackers (eavesdropping, traffic analysis) are hard to detect, so they must be prevented. Active attackers (modification, replay, impersonation, denial of service) can be detected by cryptography but not always stopped.
- In the lab, an eavesdropping router read a plaintext password and page, and saw only the server name, sizes and timing of the TLS version. A tampering router changed
0100to9900in a plain TCP stream undetected, while the same change to a TLS stream caused "bad record mac" and a closed connection. - Physical security can't protect long-distance or wireless networks, so protocols rely on cryptography.
Practice questions
1. Classify each as passive or active, and name the property threatened: (a) a rogue Wi-Fi access point using the name of a coffee shop's network; (b) recording when and how much a user sends to a medical site; (c) resending a captured "unlock door" message.
Answer
(a) Active: impersonation, threatening authenticity (and then confidentiality and integrity of whatever goes through it). (b) Passive: traffic analysis, threatening confidentiality of metadata. (c) Active: replay, threatening integrity and authenticity.
2. A protocol encrypts all its messages with a strong cipher but adds no MAC or authentication tag. Which attacker can still cause harm, and how?
Answer
Mallory. Without integrity protection, Mallory can flip bits in the ciphertext. With many cipher modes (for example, stream ciphers or counter mode), flipping a ciphertext bit flips the same plaintext bit, so Mallory can change 0100 to 9100 predictably without knowing the key. That's why modern protocols use authenticated encryption.
3. Why did the TLS connection in the lab fail completely, instead of just discarding the modified record and continuing?
Answer
TLS treats any authentication failure as fatal: it sends an alert and closes the connection. It can't know whether the rest of the stream is trustworthy, and quietly skipping data would break the guarantee that the application receives exactly what was sent, in order.
4. HTTP Basic authentication sends Authorization: Basic YWxpY2U6UGw0MW5UZXh0LVB3. What does an eavesdropper have to do to read the password?
Answer
Decode the base64, which needs no key: it gives alice:Pl41nText-Pw. Base64 is an encoding for carrying bytes in text, not encryption. Basic authentication is only safe inside TLS.
5. A company sends traffic between two data centers over its own leased fiber. Give one reason to encrypt it anyway.
Answer
The fiber passes through other people's ducts, manholes and equipment, and it can be tapped without interrupting service, so physical security can't be verified along the whole path. Encryption also protects against mistakes, such as a misconfigured router sending the traffic somewhere else, and is often required by regulation.
6. Which security property do none of the protocols in Part 13 guarantee, and why not?
Answer
Availability. Cryptographic protocols can detect and reject forged or modified traffic, but an attacker who can drop or flood packets can still stop communication. Availability needs other measures: redundancy, rate limiting, filtering and capacity.
Previous: Bufferbloat, Active Queue Management, ECN and L4S
Next: Cryptography for Networking: Ciphers, Key Exchange, Hashes, MACs and Post-Quantum Keys

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.