Files
udp_nostr/docs-ideas/protocol_hardening.md
2026-08-12 16:34:22 -04:00

12 KiB

Protocol Substrate Hardening

The Core Idea

Design the communication protocol so that interfering with it requires breaking something essential. The adversary faces a dilemma: either allow your communication, or break something that everyone needs.

This is different from the other approaches. Anonymity hides where you are. Encryption hides what you say. Decentralization makes copies unstoppable. Protocol hardening makes the medium itself resistant to discrimination.


The Envelope Analogy

Imagine the internet is like a postal system. Messages are sent in packets (envelopes). The postal system has rules about what kinds of packets it will carry.

Most communication protocols use big, complicated packets that require special handling. The postal system has to open them, read them, repackage them, and send them in multiple pieces (fragmentation). This gives the adversary many opportunities to inspect and block them.

Protocol hardening is the opposite. You design your message to fit in the smallest, most standard packet possible — one that the postal system processes without even thinking about it. Your packet looks exactly like millions of other packets. The postal system handles it automatically, at full speed, without ever looking inside.

Now the adversary wants to stop your packet. Their options are:

  1. Deep packet inspection (DPI) — Open every single packet that goes through the postal system. This is incredibly expensive. There are billions of packets every day. And if your packet is encrypted, they can't even read it without breaking the seal first.

  2. Block all packets of that size — But that size is used for essential things: DNS lookups, VoIP calls, video game traffic, QUIC/HTTP3 connections. Stopping them would break the internet itself.

  3. Do nothing — Your packet goes through.


The Size Limit: MTU

There is a maximum size for the simplest, fastest kind of packet on the internet. It's called the MTU — Maximum Transmission Unit. For most networks, the MTU is 1500 bytes (roughly 1500 characters of text). This is not an arbitrary choice — it comes from the physical hardware of the network itself. Every network cable, every router, every switch on earth is built to handle packets up to this size automatically, at full speed.

If your message fits in a single UDP datagram (a simple, no-frills packet) under this size limit, it gets processed at the hardware level without any special handling. No one has to read it, repackage it, or even think about it. It just goes through.

The technical breakdown: Ethernet MTU (1500) minus IP header (20 bytes) minus UDP header (8 bytes) = 1472 bytes of usable payload. This is the magic number. If your message is 1472 bytes or less, it fits in a single, unfragmented UDP datagram.

The adversary cannot block your message without either:

  • Inspecting every single packet on the network (impossibly expensive), or
  • Blocking all UDP traffic (which breaks DNS, VoIP, video calls, gaming, QUIC/HTTP3, and more), or
  • Letting your message through.

The General Principle

Make your message look exactly like the most common, most essential traffic on the network. When you do this, the adversary cannot block you without blocking everything.

The internet has several natural boundaries — substrate constraints — that are processed automatically by hardware and operating systems:

What It Is Technical Term Natural Size Why It Matters
The smallest internet packet MTU (Maximum Transmission Unit) 1500 bytes Fits in one piece, processed at hardware speed by every network device on earth
A common encrypted connection TCP port 443 (HTTPS) Any size Used by almost every secure website; blocking it breaks the web
A common directory lookup UDP port 53 (DNS) Small packets Used by every device to find websites; blocking it breaks the internet
A computer's memory chunk OS page 4096 bytes The operating system handles it automatically via memory-mapped I/O (mmap)
A computer's fast-access unit CPU cache line 64 bytes The processor handles it in one clock cycle; a Schnorr signature is exactly 64 bytes

Each of these is a discrimination boundary. If your message fits within the boundary, the adversary must either:

  • Inspect every message crossing that boundary (expensive), or
  • Block all messages crossing that boundary (destructive), or
  • Let your message through.

Real-World Examples

1. Hide in Encrypted Web Traffic (HTTPS on Port 443)

Most secure websites use TCP port 443 (HTTPS). If you make your communication look like a secure web connection, the adversary cannot block you without blocking all secure websites. They would have to inspect every secure connection on the network to find yours, which means decrypting every one of them — computationally impossible.

Tor obfs4 bridges exploit this. They make Tor traffic look like HTTPS traffic on port 443. The adversary cannot block the bridge without blocking all HTTPS traffic to that server.

2. Hide in Directory Lookups (DNS Tunneling)

Every time you visit a website, your computer looks up the address using DNS (Domain Name System) on UDP port 53. These lookups are small, fast, and essential. If you encode your message in a DNS query (DNS tunneling), the adversary must either:

  • Inspect every DNS query (expensive, and they're now encrypted with DNS-over-HTTPS)
  • Block all DNS lookups (breaks the internet)
  • Let your message through

3. Hide in Video Call Traffic (QUIC/HTTP3)

Modern video calls use QUIC (a Google-developed protocol) which runs over UDP on port 443. QUIC is the foundation of HTTP/3, the newest version of the web protocol. If your message uses the same type of connection, the adversary cannot tell the difference without inspecting every QUIC packet on the network.

4. Hide in Network Diagnostics (ICMP)

ICMP (ping) is essential for network diagnostics. Some protocols tunnel data over ICMP echo requests. Blocking ICMP breaks network troubleshooting. The adversary must either inspect every ping packet or let them through.

5. Use the Operating System's Guarantees (Kernel-Level)

The operating system kernel (Linux, Windows, macOS) has built-in guarantees about how files are created and stored. These are substrate-enforced rules — they are not promises from your application, they are guarantees from the kernel itself:

  • Atomic creation (O_CREAT | O_EXCL): The kernel guarantees that a file is either created completely or not at all. There is no in-between state. This is used for deduplication — if the file already exists, the creation fails, so you know you have a unique copy. To violate this, the adversary would need to modify the kernel.

  • Atomic replacement (rename()): The kernel guarantees that replacing a file happens in a single, instant step. This is used for replaceable events (like updating your profile) — the old file is replaced atomically. To violate this, the adversary would need to modify the kernel.

  • Zero-copy transfer (mmap + sendfile): Data can be sent from storage to the network without any software ever touching it. The hardware (DMA — Direct Memory Access) does it directly from the OS page cache to the network interface card. To intercept it, the adversary would need to modify the hardware itself.

These are not enforced by your application (which can be bypassed, corrupted, or replaced). They are enforced by the operating system and the hardware. The adversary cannot violate them without compromising the entire system.


The Asymmetry

The adversary has a fundamental resource problem:

  • Sending a message is cheap. A single UDP datagram costs almost nothing in energy or compute.
  • Inspecting messages is expensive. The adversary must process every packet on the network, decide whether to block it, and do so in real time (line speed). The cost grows with the total bandwidth of the network.
  • Blocking all messages is destructive. The adversary breaks the very thing they are trying to control.

This is a cost asymmetry similar to the computational asymmetry of encryption. The person sending the message pays a small, fixed cost. The adversary pays a cost that grows with the total size of the internet — which is enormous and growing every year.

If your message looks like legitimate traffic, the adversary's cost approaches the total bandwidth of the entire internet. This is unbounded and grows over time.


The Relationship to Other Approaches

Protocol hardening is different from the other approaches:

Approach What it protects How
Anonymity Location of the computer Hide where you are
Decentralization Existence of the data Make unstoppable copies
Encryption Content of the message Make it unreadable
Steganography Fact of communication Make it invisible
Physical transport Network path Don't use the network
Protocol hardening The medium itself Make discrimination impossible

Protocol hardening is the only approach that makes the adversary's discrimination impossible, rather than hiding something from them. It forces the adversary into a dilemma where their only options are to do nothing or to break the network.


Combining Protocol Hardening with Other Approaches

The strongest systems combine protocol hardening with other approaches:

  • Single UDP datagram + encryption: The message fits in one unfragmented packet (protocol hardening) and the payload is encrypted (encryption). The adversary must inspect every UDP packet on the network to even see if it's your message, and they can't read it without the key.

  • Single UDP datagram on port 443 + encryption: Now your traffic looks like QUIC/HTTP3 traffic. The adversary must inspect every QUIC packet on the network to find your messages. This is computationally impossible.

  • Kernel-level deduplication + content-addressed storage: The kernel guarantees atomic file creation (O_EXCL). The data is stored by its hash (a cryptographic fingerprint). The adversary cannot corrupt the data without changing its hash, which changes the filename, which is a different file. To corrupt a specific file, the adversary must know its hash, which requires reading it first — a circular problem.

  • Single datagram + encryption + ephemeral keys: The message is sent once, in a single UDP packet, with a key that is used once and never again (forward secrecy). The adversary must inspect every packet on the network in real time, decrypt it (impossible without the key), and decide whether to block it — all before the packet reaches its destination. If they fail, the message is delivered and the key is thrown away.


The Limits

Protocol hardening is not a silver bullet:

  1. It requires deep expertise. You must understand how the network, the operating system, and the hardware actually work at a deep level — kernel internals, CPU architecture, memory alignment, cache lines, MTU boundaries.

  2. It depends on the platform. A technique that exploits Linux kernel guarantees may not work on Windows or macOS. A technique that aligns to x86-64 cache lines may not work on ARM processors.

  3. The adversary can escalate. If the adversary controls the internet infrastructure (your ISP, the backbone routers), they can block all UDP traffic regardless of the consequences. This is destructive, but a sufficiently determined adversary may do it anyway.

  4. The adversary can attack the foundation. If the adversary can modify the operating system (via malware, forced updates, or supply chain attacks), the kernel's guarantees are no longer reliable.

  5. It does not provide anonymity. Protocol hardening does not hide your IP address. The adversary can still see where packets are coming from and going to. You need anonymity (TOR, I2P) for that.

Protocol hardening is best used as one layer in a multi-layer defense. It raises the cost of discrimination, forcing the adversary to use more expensive and more destructive methods, which in turn makes them easier to detect and resist.