NanumOS

Request filter and bot guard (WAF) — keeping bad visitors out of the front door

What it is

The NanumOS web server (httpd, httpsd, and the NanumFlare edge that is built on them) can look at every request before it answers and turn away the ones that are plainly attacks or robots. It is the part of Cloudflare people call the "WAF" and "bot fight mode", done in software on your own machine: a short list of attack signs it always checks (the core set), a rule file of your own, a speed limit per visitor, and a small "prove you are a browser" page for visitors that ask too fast.

What to do now: nothing is needed for a normal site. Type httpd waf test https://example.org/.env to see what the filter would do with a request, and httpd waf status to see what it turned away in the last hour. Turn it on with -W default (or a rule file path) on the httpd line.

Basics

Think of a door person at a shop. They do not read minds; they look for a few plain things: someone trying the back-room doors (/.env, /.git, /wp-admin on a site that has none), someone passing a note that says "open the till" (SQL injection) or "run this on every customer" (a script tag), someone walking in with ../../ as directions, someone knocking a hundred times a second. Most are sent away at once (answer 403). A visitor who is only too fast is first asked to do a small sum in the browser; a real browser does it in a second, a simple robot cannot, and it gets 429 "slow down" after that.

How to use it

Turn it on

Look and test (these change nothing)

Change the rules (needs your approval)

httpd waf add 'block path starts /staging' --approved adds one line (checked first; the old file is kept as waf.rules.bak). httpd waf remove 3 --approved removes line 3. Without --approved they refuse: what visitors can reach is your decision. The assistant asks with an approval card and passes --approved only after you press [Allow].

The rule file

One rule per line, ACTION FIELD OP VALUE, then optionally # a short label (the label is what status shows). Rules run top to bottom; the first block, challenge or rate that matches decides; allow ends the check (the core set too); log only notes and goes on.

PartChoices
ACTIONallow · block (403) · challenge (browser proof, then in) · log (note only) · rate:N/S (N matching requests in S seconds per visitor, then 429)
FIELDpath · query · method · ua (User-Agent) · host · body (the first bytes of the body, when the server reads it) · ip · header:Name

Examples:

Settings (set NAME VALUE): rate (requests a second per visitor, 30) · burst (90) · ban (seconds, 60) · strikes (overruns in a minute before a ban, 20) · pow_bits (difficulty of the browser sum, 15) · cookie_ttl (seconds the pass lasts, 1800) · core block|log|off · skip traversal|scanner|wp|sqli|xss|rce|method|size|nullbyte · methods GET,HEAD,POST,... · max_header (8192) · max_target (2048) · body_bytes (4096) · proxy_from CIDR and proxy_header Name (behind Cloudflare or another proxy: take the visitor's address from that header, but only when the connection comes from the proxy) · crawler NAME WORD .suffix....

country rules are not supported: a country needs an offline address database, and none with a licence we accept is built in. A country line is reported as an error, not ignored.

How it works

Every request goes through the same steps, in this order. The first step that decides, ends it.

  1. The proof answer. /__nflare/chal is where the browser sum is handed in (see step 5).
  2. Your rule file, top to bottom.
  3. The core set (looks at the path, the query, a text body and the headers, after decoding %41-style escapes twice and folding capital letters): path traversal (../ as a whole path piece, encoded or not) · SQL injection signs (UNION SELECT with columns, OR 1=1, ' OR ''=', SLEEP(5), information_schema, stacked ; DROP TABLE, a quote followed by a comment) · script injection (<script>, <img onerror=, javascript:alert() · command and file strings (/etc/passwd, ` whoami , ${jndi: of Log4Shell, Shellshock () {, php://) · scanner paths (every hidden file such as /.env and /.git except /.well-known, /wp-admin and /wp-login.php, /phpmyadmin, /xmlrpc.php, /cgi-bin/ …) · methods outside GET HEAD POST PUT PATCH DELETE OPTIONS (so TRACE) · a request line over 2048 bytes, headers over 8192 bytes, over 100 headers or one over 4096 · null bytes (%00`). Ordinary words that only look like code pass: "select a file from the list", "javascript: the good parts", "drop table tennis", Korean text, tracking parameters, URLs in a value. Binary bodies (images, video, multipart uploads) are not read.
  4. The speed limit. Each visitor address has a bucket of burst requests that refills at rate a second. A normal page with its 80 files fits. When it is empty:
  5. Good crawlers. Googlebot, Bingbot and Naver's Yeti are not slowed when their address passes a forward-confirmed reverse lookup: the address's name ends in the search company's domain and that name points back to the same address. The name in User-Agent alone proves nothing, so it is never trusted by itself. The lookup waits for the network, so it only runs when the crawler would otherwise be slowed (at most 5 a second), and the answer is remembered for an hour (ten minutes if it failed). A crawler still meets the core set.
Technical details
  • Code: user/cmds/waf.h (header only; one call, waf_http(), from handle() in user/cmds/httpd.c; the edge calls the same waf_check() with the body prefix). Tests: tests/test_waf.py, the lists in tests/waf/corpus.py, the fuzz target tests/fuzz/waf.
  • The core patterns are our own short POSIX regular expressions. The ideas of what to catch follow the OWASP Core Rule Set (Apache-2.0) — SQL injection, XSS, traversal, scanner and Log4Shell families — but no CRS rule file is copied, and there is no anomaly scoring and no paranoia levels. docs/qa/NFLARE-PARITY.md says honestly how far this is from Cloudflare's managed rules.
  • Per-visitor state is one table of 8192 slots (the least recently used slot gives way): a bucket, a strike count, per-rule windows, crawler verdicts. It lives in memory and starts empty after a restart.
  • The pass cookie is expiry-in-hex. + the first 96 bits of HMAC-SHA-256(secret, k|address|expiry). The secret is 32 random bytes made at start, so a restart invalidates every pass. The sum token is time. + 64 bits of HMAC over (address, time, difficulty); it is good for 5 minutes. After the sum the visitor goes back only to a same-site path (never //host, a backslash, or a new line).
  • The browser script uses crypto.subtle, which exists on https pages (and localhost) only. The edge is https; a plain-http page shows "This browser cannot do the check".

What this filter takes

Frequently asked

My own page was blocked (403). Run httpd waf test 'https://yoursite/the/path': it names the rule. For the core set, set skip NAME in the rule file switches that group off (wp for a WordPress site, scanner for hidden paths you do use), or put an allow line above for just that path. Start with set core log to see what would be blocked before blocking anything.

Does it stop an attack with thousands of machines? No. It slows one address and refuses obvious attack strings. A flood that fills your internet line has to be absorbed before it reaches you — that is what a big front service does and a filter on the receiving machine cannot.

A visitor sees the "Checking your browser" page and nothing happens. The browser has JavaScript off, or the page is plain http. The page says so; there is no other way in, on purpose (no third-party puzzle, no tracking).

Why not block by country? It needs an address-to-country database. We do not ship one (licences), so country rules are refused instead of pretending.

NanumOS 0.1.15511 · 2026-11-25