|
|
@@ -31,7 +31,7 @@ Previous: [File integrity and alerting](File-Integrity-and-Alerting-Tripwire-AID
|
|
|
- [Claims register](#claims-register)
|
|
|
<!-- END GENERATED PAGE CONTENTS -->
|
|
|
|
|
|
-Lesson D4, the last of four lessons on network and host defense. Read it after [Subnets, NAT and firewalls by hand](Subnets-NAT-and-Firewalls-By-Hand.md) and [APIs and tokens from zero](APIs-and-Tokens-From-Zero.md), because it uses their words (NAT, firewall, `429`, token, scope). It is written to be read after [How a web request works](How-a-Web-Request-Works.md) too, since that page names the CDN, the proxy and the load balancer that this page tells apart. The other three lessons in the track are [Packet filters compared: iptables, nftables, UFW and pf](Packet-Filters-Compared-iptables-nftables-ufw-pf.md), [IDS and IPS: Snort and Suricata](IDS-and-IPS-Snort-and-Suricata.md) and [File integrity and alerting: Tripwire, AIDE and Wazuh](File-Integrity-and-Alerting-Tripwire-AIDE-Wazuh.md). They were written at the same time as this one, so those three links, and the link to the WordPress lesson below, **may not resolve until they are merged**. This page does not depend on them.
|
|
|
+Lesson D4, the last of four lessons on network and host defense. Read it after [Subnets, NAT and firewalls by hand](Subnets-NAT-and-Firewalls-By-Hand.md) and [APIs and tokens from zero](APIs-and-Tokens-From-Zero.md), because it uses their words (NAT, firewall, `429`, token, scope). It is written to be read after [How a web request works](How-a-Web-Request-Works.md) too, since that page names the CDN, the proxy and the load balancer that this page tells apart. The other three lessons in the track are [Packet filters compared: iptables, nftables, UFW and pf](Packet-Filters-Compared-iptables-nftables-ufw-pf.md), [IDS and IPS: Snort and Suricata](IDS-and-IPS-Snort-and-Suricata.md) and [File integrity and alerting: Tripwire, AIDE and Wazuh](File-Integrity-and-Alerting-Tripwire-AIDE-Wazuh.md). This page does not depend on them.
|
|
|
|
|
|
Next: [Detection, Wazuh and the landscape](Detection-and-Monitoring-Wazuh-and-the-Landscape.md).
|
|
|
|
|
|
@@ -62,7 +62,7 @@ I searched the wiki before writing this page.
|
|
|
| Idea | Where it is today | The gap this page fills |
|
|
|
|---|---|---|
|
|
|
| A rate limit is a cap on requests in a time window, answered with `429` | [APIs and tokens: rate limits and pagination](APIs-and-Tokens-From-Zero.md#rate-limits-and-pagination) is one paragraph and the `Retry-After` row of a header table. | How a limiter works inside, what it counts, and what the client should do on a `429`. |
|
|
|
-| Rate limiting and bot management at concept level, plus a login limit in a lab | The WordPress at scale lesson ([WordPress at scale: CDN, WAF and CI](WordPress-at-Scale-CDN-WAF-and-CI.md); may not resolve until merged) has a short concept section, a login-path limit in its Nginx edge and a toy WAF, all aimed at WordPress. | The general reasoning for every layer, the algorithms, the keys and the failure modes. This page reuses that lesson's words (edge, origin, noisy neighbor) and does not repeat its lab. |
|
|
|
+| Rate limiting and bot management at concept level, plus a login limit in a lab | The WordPress at scale lesson ([WordPress at scale: CDN, WAF and CI](WordPress-at-Scale-CDN-WAF-and-CI.md)) has a short concept section, a login-path limit in its Nginx edge and a toy WAF, all aimed at WordPress. | The general reasoning for every layer, the algorithms, the keys and the failure modes. This page reuses that lesson's words (edge, origin, noisy neighbor) and does not repeat its lab. |
|
|
|
| Firewalls, NAT, default deny and stateful rules | [Subnets, NAT and firewalls by hand](Subnets-NAT-and-Firewalls-By-Hand.md) and [DigitalOcean network and firewalls](DigitalOcean-Network-and-Firewalls.md). | Rules that count (a rate) instead of only allow or deny. |
|
|
|
| Detecting brute force by counting failures | [Logs, SIEM and detection basics](Logs-SIEM-and-Detection-Basics.md) builds a "five failures in sixty seconds" rule and shows how a slow attacker walks under it. | The same counting idea used as a **control** (it refuses) instead of a **detection** (it tells you), and the difference between them. |
|
|
|
| Proxies, CDNs and load balancers in one sentence each | [How a web request works](How-a-Web-Request-Works.md#caching-cdns-proxies-and-load-balancers-a-sentence-each). | What each can see, and why a limit placed at the wrong one counts the wrong thing. |
|
|
|
@@ -444,7 +444,7 @@ The operating system sees packets and connections, not requests. Three things ar
|
|
|
2. **SYN cookies.** A TCP connection starts with a three-step handshake (SYN, SYN-ACK, ACK; see the Glossary). A **SYN flood** sends many SYNs and never finishes; the server keeps half-open connections in a queue until it fills and real clients are refused. A **SYN cookie** avoids keeping that state: the server encodes what it needs in the sequence number of its reply and allocates nothing until a valid ACK comes back, which a spoofed sender cannot produce ([RFC 4987](https://www.rfc-editor.org/rfc/rfc4987.txt), read 2026-10-22). The kernel's documentation says cookies are sent "when the syn backlog queue of a socket overflows", that the default is 1, and that syncookies is "fallback facility. It MUST NOT be used to help highly loaded servers to stand against legal connection rate"; it also warns that cookies "seriously violate TCP protocol" and can degrade some services. `tcp_max_syn_backlog` is "a per-listener limit" ([kernel networking sysctl documentation](https://docs.kernel.org/networking/ip-sysctl.html), read 2026-10-22). Exercise 7 shows the counters move.
|
|
|
3. **The connection tracking table.** A stateful firewall remembers every connection. The table has a maximum (`nf_conntrack_max`); when it is full, new connections are dropped for everyone. The kernel documentation notes that each entry is added twice, once per direction. A flood of spoofed connections, or simply a service that holds many, can fill it (est.: the exact failure message and defaults depend on the distribution). A per-source connection limit upstream of the table keeps one source from using it all.
|
|
|
|
|
|
-What the kernel cannot see is anything inside the connection. It cannot count login failures or paths. Its keys are addresses, so NAT and IPv6 hurt here exactly as they do at the edge. A **fail2ban**-style tool bridges the gap: it "scans log files like /var/log/auth.log and bans IP addresses conducting too many failed login attempts" by "updating system firewall rules to reject new connections from those IP addresses, for a configurable amount of time", and the project says plainly that it "cannot eliminate the risk presented by weak authentication" ([fail2ban README](https://github.com/fail2ban/fail2ban/blob/master/README.md), read 2026-10-22). That makes it a **slow, log-driven** limiter: the damage happens first, then the ban. It belongs on the file-integrity and alerting lesson as much as this one ([File integrity and alerting](File-Integrity-and-Alerting-Tripwire-AIDE-Wazuh.md); may not resolve until merged).
|
|
|
+What the kernel cannot see is anything inside the connection. It cannot count login failures or paths. Its keys are addresses, so NAT and IPv6 hurt here exactly as they do at the edge. A **fail2ban**-style tool bridges the gap: it "scans log files like /var/log/auth.log and bans IP addresses conducting too many failed login attempts" by "updating system firewall rules to reject new connections from those IP addresses, for a configurable amount of time", and the project says plainly that it "cannot eliminate the risk presented by weak authentication" ([fail2ban README](https://github.com/fail2ban/fail2ban/blob/master/README.md), read 2026-10-22). That makes it a **slow, log-driven** limiter: the damage happens first, then the ban. It belongs on the file-integrity and alerting lesson as much as this one ([File integrity and alerting](File-Integrity-and-Alerting-Tripwire-AIDE-Wazuh.md)).
|
|
|
|
|
|
## When one address is not one attacker
|
|
|
|
|
|
@@ -453,7 +453,7 @@ A limit per address assumes an attacker has few addresses. A botnet of ten thous
|
|
|
- **Count something that does not rotate.** The account being attacked (credential stuffing), the path being hit, the target being scraped. Exercise 2 showed this.
|
|
|
- **A global ceiling** on an expensive endpoint, so the whole service refuses the surplus no matter who sends it. It is blunt: real users get refused during the attack. It protects the backend at the cost of availability.
|
|
|
- **A challenge** instead of a block: a proof of work, a browser check, a CAPTCHA, an extra factor. It costs real users a little and costs a bot farm money. OWASP and NIST both present challenges as a cost-raiser, not a wall (see above).
|
|
|
-- **Reputation and context.** Known-bad networks, hosting providers, fingerprints of a client library (Cloudflare can count by a TLS fingerprint on its top plans), a login from an address that has just failed at a hundred other sites. Detection rather than counting; see [IDS and IPS](IDS-and-IPS-Snort-and-Suricata.md) (may not resolve until merged) and [Logs, SIEM and detection basics](Logs-SIEM-and-Detection-Basics.md).
|
|
|
+- **Reputation and context.** Known-bad networks, hosting providers, fingerprints of a client library (Cloudflare can count by a TLS fingerprint on its top plans), a login from an address that has just failed at a hundred other sites. Detection rather than counting; see [IDS and IPS](IDS-and-IPS-Snort-and-Suricata.md) and [Logs, SIEM and detection basics](Logs-SIEM-and-Detection-Basics.md).
|
|
|
- **Cost caps.** If the real danger is a bill, a hard spending limit or an alert at the provider stops the damage even when no rate limit caught the cause.
|
|
|
|
|
|
## Fail open or fail closed
|