Update to Anubis v1.28.2 (#1)
This upgrades the Masyunis fork from Anubis v1.25.0 to the latest stable release, **v1.28.2** (“Wuk Lamat Echo 2”), while keeping the fork’s custom styling and removals. ## Approach The Gitea repo is a tree snapshot of v1.25.0, not a git-level fork of [TecharoHQ/anubis](https://github.com/TecharoHQ/anubis). The histories share no commits, so a merge or rebase onto the upstream tag is not usable. The first commit on this branch replaces the tree with a snapshot of the **v1.28.2** tag (`git rm -r` plus `git checkout v1.28.2 -- .`; the import tree is identical to the tag). A short patch series on top restores the Masyunis customizations. ## Customizations kept - Masyunya mascots (`web/static/img/{happy,pensive,reject}.webp`), hashes match current `master`. - `web/static/img/ATTRIBUTIONS.txt` stays deleted. - Challenge footer: drop the `made_with` (Canada / maple-leaf) line and the CELPHASE mascot credit; keep “Protected by Anubis from Techaro”. The generated `web/index_templ.go` matches `go generate ./web`. - Short README (the old `anubisc` typo is fixed). - Version stamped `v1.28.2/masyunis` via Makefile ldflags. `anubis.go` `init()` does not overwrite a link-time version; `go run` / `go test` still report `devel` on purpose. - Upstream `.github`, `.devcontainer`, `.husky`, and `.vscode` stay deleted. - `"uk"` is removed from `lib/localization/locales/manifest.json` **on purpose**, because of Alpine locale problems. `uk.json` and its test entry stay; the served manifest lists 27 languages. - `package.json` `prepare` no longer runs `husky` (the hooks directory is gone). The rest of the script is unchanged. `husky` remains in devDependencies, as upstream left it. ## Deploy notes - **Cookie rename (v1.27):** with the default `DYNAMIC_COOKIE_SUFFIX=true`, cookie names become e.g. `techaro.lol-anubis-auth-<hash>`. Existing clients get a **one-time re-challenge**. That is expected, not a loop. - **Docker / ko / yeet builds** skip the Makefile ldflags, so the displayed version is `<git-version>/masyunis`. It is `v1.28.2/masyunis` only when built from a `v1.28.2` tag (or via `make build` / `make prebaked-build`). - Go 1.27.3 is required (upstream bump in v1.28.2). Thoth (`THOTH_URL` / `THOTH_TOKEN`) was removed upstream; those settings now warn and do nothing. New WASM challenge methods stay disabled unless opted in. ## Verification - `make build` succeeds. `./var/anubis --version` prints `Anubis v1.28.2/masyunis`. - `SKIP_INTEGRATION=1 go test ./...` passes (unit tests; integration package is skipped). - Local challenge/reject pages (en and ru) show Masyunya, version `v1.28.2/masyunis`, and no Canada / CELPHASE / mascot-credit text. Screenshots:   - Upstream Playwright tests (`make test` without `SKIP_INTEGRATION`) fail on this box because the browser download fails. A clean v1.28.2 tree fails the same three Playwright tests here, so this is not a fork regression. - `npm audit` reports **4** findings in upstream’s lockfile (2 moderate, 2 high: `brace-expansion`, `fast-uri`, `lodash.trim`, `source-map-js`). Left alone. Please review and merge when ready. I will not merge this myself. Reviewed-on: #1 Co-authored-by: Lead <3+lead_bot@noreply.git.unvr.site>
No files matched your search
|
After Width: | Height: | Size: 33 KiB |
@@ -0,0 +1,78 @@
|
||||
---
|
||||
slug: release/v1.27.0
|
||||
title: Anubis v1.27.0 is now available!
|
||||
authors: [xe]
|
||||
tags: [release]
|
||||
image: la-noscea.webp
|
||||
---
|
||||
|
||||

|
||||
|
||||
Anubis v1.27.0 (Moenbryda Wilfsunnwyn) is [now available](https://github.com/TecharoHQ/anubis/releases/tag/v1.27.0) via Docker and direct download from GitHub releases. This release adds Windows Server support, automatically renames cookies based on settings to avoid infinite challenge loops, adds two new localizations, and more.
|
||||
|
||||
{/* truncate */}
|
||||
|
||||
### Breaking change: cookie names are dynamically created based on cookie settings
|
||||
|
||||
Anubis tries to avoid breaking changes as much as possible, but sometimes we have to make them for the sake of the users. This is technically a breaking change in something that is not part of the public API of Anubis; but some administrators rely heavily on cookie names in advanced configurations.
|
||||
|
||||
It seems that browsers store cookies disambiguated with their options. This means you can have multiple cookies named the same but with different options. Browsers will send these cookies to the server without the list of options. This means that changing any cookie settings requires you to change `COOKIE_PREFIX`, creating a new "cookie epoch" that will set things properly.
|
||||
|
||||
In order to be more robust, Anubis will automatically change cookie names based on the cookie settings. For example, the default configuration creates cookies named `techaro.lol-anubis-auth-347ddb4a`.
|
||||
|
||||
Without this change, changing _any_ cookie setting without every client clearing their cookies causes challenges to become an infinite loop of thrashing, making it appear that Anubis "blocked" them.
|
||||
|
||||
If this becomes onerous in practice for administrators of HAProxy and other advanced setups that rely on cookie names, we will add an escape hatch in the policy file.
|
||||
|
||||
### Windows Server support (beta)
|
||||
|
||||
Anubis now publishes `.msi` packages, allowing administrators to install and run Anubis on Windows Server. Please read the [Windows Server page](https://anubis.techaro.lol/docs/admin/environments/windows) for more information.
|
||||
|
||||
This support is beta-grade as the Anubis team does not have a lot of experience with developing software for Windows Server. Feedback is more than welcome.
|
||||
|
||||
Please let us know how it works for you!
|
||||
|
||||

|
||||
|
||||
### Pre-release docker images no longer populate the `latest` tag
|
||||
|
||||
Due to a misconfiguration of the GitHub Action [docker/metadata-action](https://github.com/docker/metadata-action), pre-release Docker images previously populated the `:latest` tag. This means that administrators that expected the `:latest` tag to result in a stable release of Anubis got a prerelease version suddenly when they ran automatic updates.
|
||||
|
||||
If administrators want to opt-in to the prerelease build track of Anubis for more frequent access to new features, they can use the `:pre` tag:
|
||||
|
||||
```yaml
|
||||
image: ghcr.io/techarohq/anubis:pre
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
- Allow importing bot policy rules [using wildcard matching](https://anubis.techaro.lol/docs/admin/configuration/import#importing-many-files-at-once) ([#1815](https://github.com/TecharoHQ/anubis/issues/1815)).
|
||||
- Add support for JSON sources to iplist2rule ([#1833](https://github.com/TecharoHQ/anubis/pull/1833))
|
||||
- Make the honeypot feature log detected addresses to the disk every minute when `honeypot.ip_log_file` is set. See the [IP address logging](https://anubis.techaro.lol/docs/admin/honeypot/overview#ip-address-logging) section for more information.
|
||||
- Add standard library rules for making Dillo less threatening to Anubis and [document how to enable them](https://anubis.techaro.lol/docs/admin/faq#how-do-i-allow-small-internet-browsers-like-dillo-netsurf-and-pale-moon-to-bypass-anubis).
|
||||
|
||||
#### Crawlers
|
||||
|
||||
- Allow [Arquivo.pt](https://arquivo.pt), the Portuguese web archive, by default via its crawling network.
|
||||
- Add `(data)/bots/lyrenth.yaml` snippet that denies [Lyrenth](https://lyrenth.com/bot)'s `AIWebIndex` crawler and `AIWebIndex-Agent` on-demand fetcher by user agent and by their [published IP ranges](https://www.lyrenth.com/bot/ip-ranges.json). This is imported by `(data)/bots/_deny-pathological.yaml`.
|
||||
- Updates Alibaba cloud IP list ([#1813](https://github.com/TecharoHQ/anubis/pull/1813))
|
||||
- Updates Googlebot IP list ([#1812](https://github.com/TecharoHQ/anubis/pull/1812))
|
||||
- Updates IP list for DuckDuckBot ([#1810](https://github.com/TecharoHQ/anubis/pull/1810))
|
||||
- Update Huawei Cloud IP list ([#1814](https://github.com/TecharoHQ/anubis/pull/1814))
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix bot policy imports to not require pedantically correct YAML formatting when using wildcard matching.
|
||||
- JavaScript served by the `fast` challenge is loaded using [`defer`](https://www.w3schools.com/tags/att_script_defer.asp) instead of `async` ([#1782](https://github.com/TecharoHQ/anubis/issues/1782)).
|
||||
- Amend default [Lightpanda](https://lightpanda.io/) rule to match current behaviour, add smoke test to ensure it keeps working ([#1822](https://github.com/TecharoHQ/anubis/issues/1822)).
|
||||
- Fix a panic when a request asks for the undetermined language tag, such as `Accept-Language: und` ([#1776](https://github.com/TecharoHQ/anubis/issues/1776)).
|
||||
- Allow user agents that start with capital-G `Git` in `(data)/clients/git.yaml`.
|
||||
- Enabled the Partitioned flag on cookies by default ([#1701](https://github.com/TecharoHQ/anubis/issues/1701)).
|
||||
- Fix Windows MSI builds on prerelease tags such as `v1.27.0-pre1`.
|
||||
- Bump AI-robots.txt to version 1.47.
|
||||
|
||||
### i18n
|
||||
|
||||
- Add Basque (eu) localization.
|
||||
- Update Bulgarian locale ([#1708](https://github.com/TecharoHQ/anubis/pull/1708))
|
||||
- Add Croatian (hr) localization.
|
||||
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,320 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import styles from "./styles.module.css";
|
||||
|
||||
// The diagram shows a 64 bit hash rather than a full SHA-256 digest. Real
|
||||
// hashes are 256 bits, but 64 of them fit on a phone screen and the point
|
||||
// about bits versus nibbles is the same either way.
|
||||
const HASH_BYTES = 8;
|
||||
const HEX_CHARS = HASH_BYTES * 2;
|
||||
const HASH_BITS = HASH_BYTES * 8;
|
||||
|
||||
// Each row of the diagram covers four hex characters, so 16 bits.
|
||||
const HEX_PER_CHUNK = 4;
|
||||
const BITS_PER_CHUNK = HEX_PER_CHUNK * 4;
|
||||
const CHUNKS = HEX_CHARS / HEX_PER_CHUNK;
|
||||
|
||||
// A fixed starting hash so the server-rendered markup matches the first
|
||||
// client render. Mining replaces it with random hashes.
|
||||
const INITIAL_HEX = "f3a2b1c4d5e6f7a8";
|
||||
const INITIAL_BIN = hexToBin(INITIAL_HEX);
|
||||
|
||||
// Number of hashes to try per animation frame. High enough to feel like
|
||||
// mining, low enough to keep the page responsive.
|
||||
const HASHES_PER_FRAME = 200;
|
||||
|
||||
// How often the hash display is allowed to change when the reader has asked
|
||||
// for reduced motion. Mining still runs every frame; only the repaint slows
|
||||
// down, which turns a 60fps strobe into a readable ticker.
|
||||
const REDUCED_MOTION_PAINT_MS = 400;
|
||||
|
||||
// Converts a hex string into its binary expansion, four bits per character.
|
||||
function hexToBin(hex) {
|
||||
return hex
|
||||
.split("")
|
||||
.map((c) => parseInt(c, 16).toString(2).padStart(4, "0"))
|
||||
.join("");
|
||||
}
|
||||
|
||||
// Generates a random hash value in both hex and binary form.
|
||||
function generateRandomHash() {
|
||||
const buffer = new Uint8Array(HASH_BYTES);
|
||||
crypto.getRandomValues(buffer);
|
||||
const hex = Array.from(buffer)
|
||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
return { hex, bin: hexToBin(hex) };
|
||||
}
|
||||
|
||||
// Reports whether a hash clears the target: `difficulty` leading zero bits in
|
||||
// bit mode, or `difficulty` leading zero hex characters in nibble mode.
|
||||
function meetsTarget(mode, difficulty, hex, bin) {
|
||||
const prefix = "0".repeat(difficulty);
|
||||
return mode === "bit" ? bin.startsWith(prefix) : hex.startsWith(prefix);
|
||||
}
|
||||
|
||||
// Tracks the reader's reduced motion preference. Starts false so the server
|
||||
// and the first client render agree, then corrects itself on mount.
|
||||
function usePrefersReducedMotion() {
|
||||
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
||||
setPrefersReducedMotion(query.matches);
|
||||
|
||||
const handleChange = (event) => setPrefersReducedMotion(event.matches);
|
||||
query.addEventListener("change", handleChange);
|
||||
return () => query.removeEventListener("change", handleChange);
|
||||
}, []);
|
||||
|
||||
return prefersReducedMotion;
|
||||
}
|
||||
|
||||
export default function DifficultyVisualizer() {
|
||||
const [mode, setMode] = useState("nibble");
|
||||
const [difficulty, setDifficulty] = useState(1);
|
||||
const [nonce, setNonce] = useState(0);
|
||||
const [hashHex, setHashHex] = useState(INITIAL_HEX);
|
||||
const [hashBin, setHashBin] = useState(INITIAL_BIN);
|
||||
const [isMining, setIsMining] = useState(false);
|
||||
const frameRef = useRef(null);
|
||||
const untalliedRef = useRef(0);
|
||||
const lastPaintRef = useRef(0);
|
||||
const prefersReducedMotion = usePrefersReducedMotion();
|
||||
|
||||
const maxDifficulty = mode === "bit" ? HASH_BITS : HEX_CHARS;
|
||||
const isSolved = nonce > 0 && meetsTarget(mode, difficulty, hashHex, hashBin);
|
||||
const isSlow =
|
||||
(mode === "bit" && difficulty > 20) ||
|
||||
(mode === "nibble" && difficulty > 5);
|
||||
|
||||
// Drives the mining loop. Reruns whenever the target changes so the loop
|
||||
// always tests against the current mode and difficulty.
|
||||
useEffect(() => {
|
||||
if (!isMining) return;
|
||||
|
||||
const mineStep = () => {
|
||||
let found = false;
|
||||
let latest = null;
|
||||
|
||||
for (let i = 0; i < HASHES_PER_FRAME; i++) {
|
||||
untalliedRef.current++;
|
||||
latest = generateRandomHash();
|
||||
if (meetsTarget(mode, difficulty, latest.hex, latest.bin)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Under reduced motion, keep hashing at full speed but let the display
|
||||
// settle between updates. The winning hash always paints immediately.
|
||||
const now = performance.now();
|
||||
const shouldPaint =
|
||||
found ||
|
||||
!prefersReducedMotion ||
|
||||
now - lastPaintRef.current >= REDUCED_MOTION_PAINT_MS;
|
||||
|
||||
if (shouldPaint) {
|
||||
const tried = untalliedRef.current;
|
||||
untalliedRef.current = 0;
|
||||
lastPaintRef.current = now;
|
||||
setNonce((prev) => prev + tried);
|
||||
setHashHex(latest.hex);
|
||||
setHashBin(latest.bin);
|
||||
}
|
||||
|
||||
if (found) {
|
||||
setIsMining(false);
|
||||
} else {
|
||||
frameRef.current = requestAnimationFrame(mineStep);
|
||||
}
|
||||
};
|
||||
|
||||
frameRef.current = requestAnimationFrame(mineStep);
|
||||
|
||||
return () => {
|
||||
if (frameRef.current !== null) {
|
||||
cancelAnimationFrame(frameRef.current);
|
||||
frameRef.current = null;
|
||||
}
|
||||
|
||||
// Stopping between throttled repaints would otherwise drop the hashes
|
||||
// tried since the last one, leaving the nonce reading low.
|
||||
if (untalliedRef.current > 0) {
|
||||
const tried = untalliedRef.current;
|
||||
untalliedRef.current = 0;
|
||||
setNonce((prev) => prev + tried);
|
||||
}
|
||||
};
|
||||
}, [isMining, mode, difficulty, prefersReducedMotion]);
|
||||
|
||||
const handleModeChange = (nextMode) => {
|
||||
setMode(nextMode);
|
||||
setDifficulty(1);
|
||||
setIsMining(false);
|
||||
};
|
||||
|
||||
const handleDifficultyChange = (event) => {
|
||||
setDifficulty(Number(event.target.value));
|
||||
setIsMining(false);
|
||||
};
|
||||
|
||||
const handleMineClick = () => {
|
||||
setNonce(0);
|
||||
untalliedRef.current = 0;
|
||||
lastPaintRef.current = 0;
|
||||
setIsMining(true);
|
||||
};
|
||||
|
||||
const handleStopClick = () => {
|
||||
setIsMining(false);
|
||||
};
|
||||
|
||||
// Renders one slice of the hash: a few hex characters with the bits they
|
||||
// encode lined up directly underneath them.
|
||||
const renderChunk = (chunkIndex) => {
|
||||
const hexOffset = chunkIndex * HEX_PER_CHUNK;
|
||||
const binOffset = chunkIndex * BITS_PER_CHUNK;
|
||||
const hexChunk = hashHex.slice(hexOffset, hexOffset + HEX_PER_CHUNK);
|
||||
const binChunk = hashBin.slice(binOffset, binOffset + BITS_PER_CHUNK);
|
||||
|
||||
return (
|
||||
<div key={chunkIndex} className={styles.chunk}>
|
||||
{chunkIndex === 0 && (
|
||||
<div className={styles.sectionLabel}>Hexadecimal</div>
|
||||
)}
|
||||
<div className={styles.hexRow}>
|
||||
{hexChunk.split("").map((char, localIndex) => {
|
||||
const index = hexOffset + localIndex;
|
||||
const isTarget = mode === "nibble" && index < difficulty;
|
||||
return (
|
||||
<div
|
||||
key={`hex-${index}`}
|
||||
className={clsx(
|
||||
styles.hexCell,
|
||||
isTarget && (char === "0" ? styles.cellHit : styles.cellBad),
|
||||
)}
|
||||
>
|
||||
{char}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{chunkIndex === 0 && (
|
||||
<div className={styles.sectionLabel}>Binary ({HASH_BITS} bits)</div>
|
||||
)}
|
||||
<div className={styles.binRow}>
|
||||
{binChunk.split("").map((bit, localIndex) => {
|
||||
const index = binOffset + localIndex;
|
||||
const isBitTarget = mode === "bit" && index < difficulty;
|
||||
const isNibbleTarget =
|
||||
mode === "nibble" && Math.floor(index / 4) < difficulty;
|
||||
const isZero = bit === "0";
|
||||
|
||||
let state = null;
|
||||
if (isBitTarget) {
|
||||
state = isZero ? styles.cellOk : styles.cellBad;
|
||||
} else if (isNibbleTarget) {
|
||||
state = isZero ? styles.cellHit : styles.cellBad;
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={`bin-${index}`} className={clsx(styles.binCell, state)}>
|
||||
{bit}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
{/* Controls */}
|
||||
<div className={styles.controls}>
|
||||
<div className={styles.controlGroup}>
|
||||
<span className={styles.label}>Measurement mode</span>
|
||||
<div className={styles.modeButtons}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleModeChange("nibble")}
|
||||
className={clsx(
|
||||
styles.modeButton,
|
||||
mode === "nibble" && styles.modeButtonActiveHit,
|
||||
)}
|
||||
>
|
||||
Nibbles (hex)
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleModeChange("bit")}
|
||||
className={clsx(
|
||||
styles.modeButton,
|
||||
mode === "bit" && styles.modeButtonActiveOk,
|
||||
)}
|
||||
>
|
||||
Bits (binary)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.controlGroup}>
|
||||
<label
|
||||
htmlFor="dv-difficulty"
|
||||
className={clsx(styles.label, styles.labelRow)}
|
||||
>
|
||||
<span>Target difficulty</span>
|
||||
<span className={styles.difficultyValue}>
|
||||
{difficulty} {mode}
|
||||
{difficulty === 1 ? "" : "s"}
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
id="dv-difficulty"
|
||||
type="range"
|
||||
min="1"
|
||||
max={maxDifficulty}
|
||||
value={difficulty}
|
||||
onChange={handleDifficultyChange}
|
||||
className={styles.slider}
|
||||
/>
|
||||
<div className={styles.hintRow}>
|
||||
<p className={styles.hint}>
|
||||
{mode === "nibble" ? difficulty * 4 : difficulty} / {HASH_BITS}{" "}
|
||||
leading zero bits
|
||||
</p>
|
||||
{isSlow && <p className={styles.warning}>Slow</p>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mining dashboard */}
|
||||
<div className={styles.dashboard}>
|
||||
{!isMining && isSolved && <div className={styles.successGlow} />}
|
||||
|
||||
<div className={styles.statusRow}>
|
||||
<div className={styles.nonce}>
|
||||
Nonce:
|
||||
<span className={styles.nonceValue}>{nonce.toLocaleString()}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={isMining ? handleStopClick : handleMineClick}
|
||||
className={clsx(
|
||||
styles.mineButton,
|
||||
isMining && styles.mineButtonMining,
|
||||
)}
|
||||
>
|
||||
{isMining ? "Stop mining" : "Start mining"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={styles.hashGrid}>
|
||||
{Array.from({ length: CHUNKS }, (_, i) => renderChunk(i))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
/* Theme tokens. Light values are the default, dark values override below. */
|
||||
.container {
|
||||
--dv-surface: var(--ifm-background-surface-color);
|
||||
--dv-raised: var(--ifm-color-emphasis-100);
|
||||
--dv-sunken: var(--ifm-color-emphasis-200);
|
||||
--dv-border: var(--ifm-color-emphasis-300);
|
||||
--dv-muted: var(--ifm-color-emphasis-700);
|
||||
|
||||
--dv-hit-text: var(--ifm-color-primary-dark);
|
||||
--dv-hit-border: var(--ifm-color-primary);
|
||||
--dv-hit-bg: rgb(255 86 48 / 0.12);
|
||||
|
||||
--dv-ok-text: rgb(21 128 61);
|
||||
--dv-ok-border: rgb(34 197 94);
|
||||
--dv-ok-bg: rgb(34 197 94 / 0.12);
|
||||
|
||||
--dv-bad-text: rgb(185 28 28);
|
||||
--dv-bad-border: rgb(239 68 68);
|
||||
--dv-bad-bg: rgb(239 68 68 / 0.12);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .container {
|
||||
--dv-hit-text: var(--ifm-color-primary-lighter);
|
||||
--dv-hit-bg: rgb(255 86 48 / 0.18);
|
||||
|
||||
--dv-ok-text: rgb(74 222 128);
|
||||
--dv-ok-bg: rgb(34 197 94 / 0.18);
|
||||
|
||||
--dv-bad-text: rgb(248 113 113);
|
||||
--dv-bad-bg: rgb(239 68 68 / 0.18);
|
||||
}
|
||||
|
||||
/* Main container styles */
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 40rem;
|
||||
margin: 1.5rem auto;
|
||||
overflow: hidden;
|
||||
color: var(--ifm-font-color-base);
|
||||
background-color: var(--dv-raised);
|
||||
border: 1px solid var(--dv-border);
|
||||
border-radius: var(--ifm-global-radius);
|
||||
}
|
||||
|
||||
/* Control panel styles */
|
||||
.controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem;
|
||||
border-bottom: 1px solid var(--dv-border);
|
||||
}
|
||||
|
||||
.controlGroup {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
font-size: 0.8125rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.375rem;
|
||||
}
|
||||
|
||||
.labelRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.difficultyValue {
|
||||
font-family: var(--ifm-font-family-monospace);
|
||||
font-weight: 400;
|
||||
padding: 0.125rem 0.375rem;
|
||||
background-color: var(--dv-sunken);
|
||||
border-radius: var(--ifm-global-radius);
|
||||
}
|
||||
|
||||
/* Mode switch styles */
|
||||
.modeButtons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.modeButton {
|
||||
font: inherit;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
padding: 0.375rem 0.75rem;
|
||||
color: var(--ifm-font-color-base);
|
||||
background-color: var(--dv-sunken);
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 200ms,
|
||||
color 200ms;
|
||||
}
|
||||
|
||||
.modeButton:hover {
|
||||
background-color: var(--dv-border);
|
||||
}
|
||||
|
||||
.modeButtonActiveHit,
|
||||
.modeButtonActiveHit:hover {
|
||||
color: var(--ifm-button-color);
|
||||
background-color: var(--ifm-color-primary);
|
||||
}
|
||||
|
||||
.modeButtonActiveOk,
|
||||
.modeButtonActiveOk:hover {
|
||||
color: var(--ifm-button-color);
|
||||
background-color: rgb(21 128 61);
|
||||
}
|
||||
|
||||
/* Difficulty slider styles */
|
||||
.slider {
|
||||
display: block;
|
||||
width: 100%;
|
||||
accent-color: var(--ifm-color-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hintRow {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 0.75rem;
|
||||
font-family: var(--ifm-font-family-monospace);
|
||||
color: var(--dv-muted);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.warning {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--ifm-color-warning-darkest);
|
||||
margin-bottom: 0;
|
||||
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .warning {
|
||||
color: var(--ifm-color-warning);
|
||||
}
|
||||
|
||||
/* Mining dashboard styles */
|
||||
.dashboard {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.successGlow {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-color: var(--dv-ok-bg);
|
||||
pointer-events: none;
|
||||
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
||||
}
|
||||
|
||||
.statusRow {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.nonce {
|
||||
font-family: var(--ifm-font-family-monospace);
|
||||
font-size: 0.8125rem;
|
||||
color: var(--dv-muted);
|
||||
padding: 0.375rem 0.625rem;
|
||||
background-color: var(--dv-surface);
|
||||
border: 1px solid var(--dv-border);
|
||||
border-radius: var(--ifm-global-radius);
|
||||
}
|
||||
|
||||
.nonceValue {
|
||||
color: var(--ifm-font-color-base);
|
||||
margin-left: 0.375rem;
|
||||
}
|
||||
|
||||
.mineButton {
|
||||
font: inherit;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
padding: 0.5rem 1rem;
|
||||
color: var(--ifm-button-color);
|
||||
background-color: var(--ifm-color-primary);
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
cursor: pointer;
|
||||
transition: background-color 200ms;
|
||||
}
|
||||
|
||||
.mineButton:hover {
|
||||
background-color: var(--ifm-color-primary-dark);
|
||||
}
|
||||
|
||||
.mineButtonMining,
|
||||
.mineButtonMining:hover {
|
||||
color: var(--dv-bad-text);
|
||||
background-color: var(--dv-bad-bg);
|
||||
border-color: var(--dv-bad-border);
|
||||
}
|
||||
|
||||
/* Hash display styles */
|
||||
.hashGrid {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-width: 32rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.chunk {
|
||||
padding: 0.5rem;
|
||||
background-color: var(--dv-surface);
|
||||
border: 1px solid var(--dv-border);
|
||||
border-radius: var(--ifm-global-radius);
|
||||
}
|
||||
|
||||
.sectionLabel {
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--dv-muted);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
/* Both rows share one 16 column grid, and each hex cell spans four columns.
|
||||
That puts every hex character directly above the four bits it encodes
|
||||
without needing spacer elements. */
|
||||
.hexRow,
|
||||
.binRow {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(16, minmax(0, 1fr));
|
||||
gap: 2px;
|
||||
font-family: var(--ifm-font-family-monospace);
|
||||
}
|
||||
|
||||
.hexRow {
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
.hexCell {
|
||||
grid-column: span 4;
|
||||
height: 2.25rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--dv-muted);
|
||||
background-color: var(--dv-sunken);
|
||||
border: 1px solid var(--dv-border);
|
||||
border-radius: var(--ifm-global-radius);
|
||||
transition: all 200ms;
|
||||
}
|
||||
|
||||
.binRow {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.binCell {
|
||||
height: 1.75rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--dv-muted);
|
||||
background-color: var(--dv-sunken);
|
||||
border-bottom: 2px solid var(--dv-border);
|
||||
transition: all 200ms;
|
||||
}
|
||||
|
||||
/* Cell highlight states */
|
||||
.cellHit {
|
||||
color: var(--dv-hit-text);
|
||||
background-color: var(--dv-hit-bg);
|
||||
border-color: var(--dv-hit-border);
|
||||
}
|
||||
|
||||
.cellOk {
|
||||
color: var(--dv-ok-text);
|
||||
background-color: var(--dv-ok-bg);
|
||||
border-color: var(--dv-ok-border);
|
||||
}
|
||||
|
||||
.cellBad {
|
||||
color: var(--dv-bad-text);
|
||||
background-color: var(--dv-bad-bg);
|
||||
border-color: var(--dv-bad-border);
|
||||
}
|
||||
|
||||
/* Glow animation */
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
/* Responsive styles */
|
||||
@media (min-width: 768px) {
|
||||
.controls {
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Every nested padding costs the bit grid 16 columns worth of width, so trim
|
||||
the padding and the type together on small screens. */
|
||||
@media (max-width: 480px) {
|
||||
.controls,
|
||||
.dashboard {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.chunk {
|
||||
padding: 0.375rem;
|
||||
}
|
||||
|
||||
.hexRow {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.hexCell {
|
||||
height: 2rem;
|
||||
}
|
||||
|
||||
.binRow {
|
||||
font-size: 0.625rem;
|
||||
}
|
||||
|
||||
.binCell {
|
||||
height: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.warning,
|
||||
.successGlow {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.modeButton,
|
||||
.mineButton,
|
||||
.hexCell,
|
||||
.binCell {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
---
|
||||
slug: 2026/anubis-wasm
|
||||
title: It took a year to ship WebAssembly in Anubis
|
||||
authors: [xe]
|
||||
tags: [wasm, engineering]
|
||||
image: chrystarium.webp
|
||||
---
|
||||
|
||||

|
||||
|
||||
After a year of work, hundreds of commits, 5 generations of pull requests, dozens of tests, rewriting part of Anubis in Rust, the first compiler bug of my career, and at least three times making my tower run out of ram I think I have finally done it. The next version of Anubis will ship with [WebAssembly-based proof of work checks](https://anubis.techaro.lol/docs/admin/configuration/challenges/wasm) that admins can enable in their thresholds or bot rules:
|
||||
|
||||
{/* truncate */}
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: argon2id
|
||||
difficulty: 6
|
||||
```
|
||||
|
||||
This makes Anubis challenges use a [memory-hard](https://en.wikipedia.org/wiki/Memory-hard_function) proof of work function ([argon2id](https://en.wikipedia.org/wiki/Argon2)) instead of just a CPU hard one. It also means that the "hey Claude vibeslop me a CUDA Anubis solver" route is on its way to being fundamentally dead. Overall, this project taught me a lot of things about how WebAssembly works in practice, what the rough edges are when operating on the bleeding edge like I am, and led to the first genuine compiler bug of my career.
|
||||
|
||||
Today I want to take you through the journey and process behind adding these WebAssembly based proof of work checks and all the problems that came up along the way.
|
||||
|
||||
## Why use WebAssembly in the first place?
|
||||
|
||||
The big impetus behind wanting to use WebAssembly in Anubis is that there's a constant tension that's underlined a lot of the performance work I've been doing: phone CPUs suck and trying to balance equitability to phone CPUs with trying to punish scraper CPUs is a huge challenge.
|
||||
|
||||
:::note Aside
|
||||
|
||||
To be clear: I am tackling the "Anubis makes my phone overheat" problem. It's hard to just lower the difficulty for phones without giving attackers enough information to lower the difficulty for scrapers. If you want to contribute performance data so that I can improve my classification process and/or target future development, please [get in touch with me](https://xeiaso.net/contact/). I want to make things better but can't without data. I am actively testing with a [Moto G8 Power](https://www.gsmarena.com/motorola_moto_g8_power-10052.php) alongside my normal testing steps.
|
||||
|
||||
:::
|
||||
|
||||
Using WebAssembly here means that the binary will run faster, which will make Anubis _go away_ faster, which is what we all want, right?
|
||||
|
||||
### The same binary runs on both the client and the server
|
||||
|
||||
One of the other big advantages of this setup is that it lets clients and servers run the same binary in order to solve and validate challenges. Note that I didn't say the same code, I said the same _binary_. This means that the client and server are in lockstep, much like the [CIC chip in the NES](<https://en.wikipedia.org/wiki/CIC_(Nintendo)>). This also does mean that a bug in the shared code means that the client could send an invalid value that the server would accept as valid, but I don't think this is a practical concern until something like that happens.
|
||||
|
||||
Right now the [`fast` challenge](https://anubis.techaro.lol/docs/admin/configuration/challenges/proof-of-work) has two implementations in Anubis: one [in JavaScript](https://github.com/TecharoHQ/anubis/blob/main/web/js/worker/sha256.ts) and the other [in Go](https://github.com/TecharoHQ/anubis/blob/main/lib/challenge/proofofwork/proofofwork.go). Updating it in one place means making the same updates in other places and also making sure that everywhere else that assumes how challenges work is also updated.
|
||||
|
||||
:::note Aside
|
||||
|
||||
Yeah, it's probably bad to have made those assumptions about how challenges work across the codebase. There's a lot of weird technical debt here that needs to be solved at some point. I expect that to be a fair bit of effort to untangle, it may end up with keeping the `fast` challenge only for tests when the WebAssembly based routes are working out well enough to make the default/only option.
|
||||
|
||||
:::
|
||||
|
||||
Making the same binary run on both the client and the server means that future experiments like per-client program synthesis can also proceed. I'll get more into that sometime in the future.
|
||||
|
||||
### This lets us sneak Rust into Anubis
|
||||
|
||||
Right now the core of Anubis is written in Go. Go's standard library HTTP server is surprisingly performant and is the key component of things like Google's HTTP frontend service. I have no intention to rewrite Anubis in Rust or anything as drastic as that.
|
||||
|
||||
However breaking up Anubis from one monolithic binary into what amounts to a plugin loader is a lot more interesting from a maintenance standpoint. One of the main problems with Anubis is that the combination of rules I've set for myself (no CGo allowed and everything must cross compile to prod from my MacBook) means that updating any part of Anubis means recompiling all of Anubis across prod. Making Anubis be _able_ to have parts of it downloaded and swapped out at runtime is really interesting to me because it means being able to adapt to threats _as soon as the threat actors change behaviour_.
|
||||
|
||||
Also I figured out pretty quickly that Rust builds some of the smallest WebAssembly binaries that run hilariously fast, so I wrote all the WebAssembly code in Rust (no-std, wasm32-unknown-unknown)\!
|
||||
|
||||
### Finally fixing the challenge difficulty scaling issue
|
||||
|
||||
Along the way this also lets me fix one of the bigger administrative problems with Anubis: challenges scale incorrectly with the `fast` challenge. Anubis uses string comparison to count the number of leading zero _nibbles_ in a hash instead of the number of leading zero _bits_. This means that adding one (1) to the difficulty of a challenge makes it 16 (sixteen) times as hard to solve in the worst case.
|
||||
|
||||
Here's an interactive diagram to help you understand the difference in scaling at play:
|
||||
|
||||
import DiffViz from "./diagrams/DifficultyVisualizer";
|
||||
|
||||
<DiffViz />
|
||||
|
||||
This was a mistake in retrospect, but if we're changing details about how challenges work here then we may as well wrap up the fix into that.
|
||||
|
||||
## How you normally add WebAssembly to something like this
|
||||
|
||||
In a normal world you'd not have about half of the restrictions that I have when working with Anubis. Normally you just write your code, compile it to WebAssembly, and then make sure it runs on modern browsers. This is nice and simple. I wish I could live in this world.
|
||||
|
||||
Comparatively, this is what it's like getting all of this working across browser versions, platforms, and so many other things:
|
||||
|
||||
<center style={{ marginBottom: "1rem" }}></center>
|
||||
|
||||
Anubis supports Chrome 75 and newer. I wanted to reduce the support range to not have to deal with Chrome that old (the feature difference between Chrome 155 and Chrome 75 is [absolutely massive](https://caniuse.com/?compare=chrome+75,chrome+155&compareCats=all)), but there are a lot of smartphones, smart TVs, and other electronic devices running Android out there that are just marooned on Chrome that old with _no path to upgrade it_. As a result, I gotta target Chrome 75 for features, but out of an abundance of caution and to make sure that things are generally compatible with browsers older than Chrome 75 (eg: old iOS releases), I target my JavaScript to Chrome 66 as an abundance of caution.
|
||||
|
||||
I haven't been able to test with iOS or Android versions of the same vintage as Chrome 75, so a lot of this is aspirational backwards compatibility. I sure hope it's good enough\!
|
||||
|
||||
### The host -> guest WASM ABI
|
||||
|
||||
When you're doing this kind of work, you're effectively writing an operating system kernel that makes the WebAssembly guests run as processes. Any calls you pass to the WebAssembly guest are effectively system calls into the host. Normally I'd love to be able to reuse the [WebAssembly Component Model](https://component-model.bytecodealliance.org/introduction.html) so that a lot of the "hard part" is done for me. WebAssembly Components make you define your calls in packages that contain interfaces with functions in worlds.
|
||||
|
||||
Here's an example of the kind of WebAssembly Interface Types world Anubis would need:
|
||||
|
||||
```wit
|
||||
// theoretical/wit/proof-of-work.wit
|
||||
package techaro:anubis;
|
||||
|
||||
interface update-ui {
|
||||
// update the UI with the current nonce every 1024 iterations.
|
||||
update-nonce: func(u32);
|
||||
}
|
||||
|
||||
interface proof-of-work {
|
||||
// possible ways the computation can go wrong.
|
||||
enum error {
|
||||
no-error,
|
||||
input-too-big,
|
||||
cant-find-solution,
|
||||
computed-different-result,
|
||||
}
|
||||
|
||||
// write up to 4096 bytes of challenge data to the challenge buffer,
|
||||
// if the user tries to write more then throw an error.
|
||||
write-data: func(data: list<u8>) -> result<u32, error>;
|
||||
|
||||
// read the generated result
|
||||
read-result: func() -> list<u8>;
|
||||
|
||||
// write to the verification buffer, if the user tries to write more
|
||||
// than the buffer supports throw an error.
|
||||
write-verification: func(data: list<u8>) -> error;
|
||||
|
||||
// grind at the right hash in a loop and return the nonce that passes
|
||||
// validation to send to the server.
|
||||
anubis-work: func(difficulty: u32, initial-nonce: u32, difficulty: u32, iterand: u32) -> result<u32, error>;
|
||||
|
||||
// validate that running the proof of work function on the data buffer
|
||||
// with the given nonce results in the same output that the client
|
||||
// calculated.
|
||||
anubis-validate: func(difficulty: u32, nonce: u32) -> result<bool, error>;
|
||||
}
|
||||
|
||||
world anubis {
|
||||
import update-ui;
|
||||
export proof-of-work;
|
||||
}
|
||||
```
|
||||
|
||||
If this worked (I wrote this all out in one go based on how the current handcrafted ABI works and have not tested it, sorry), this would describe the shape of the API that we need for doing the proof of work operations. At the time I wrote the API/ABI that Anubis uses, the main tool for generating the server-side bindings for WebAssembly Component Model stuff in Go [gravity](https://github.com/arcjet/gravity) didn't support passing records (structs) or bytestrings (`list<u8>` or `Vec<u8>` / `[]byte`) from the host to the guest. As such, I had to do it by hand.
|
||||
|
||||
### API design
|
||||
|
||||
So given that we can't do it the "right way", we have to do it the "bad way". Also given that no matter what I pick for this I'm going to be "wrong", I just decided to treat the WebAssembly modules as dynamic libraries that just happen to use WebAssembly as an implementation detail. There only needs to be three buffers that are read from / written to, so let's just focus around those:
|
||||
|
||||
1. The data buffer: up to 4096 bytes of challenge data. This is 4096 bytes so that it can (hopefully) land in its own 4Ki machine page. This is the only variable-length buffer in the setup, so it needs two calls:
|
||||
1. `data_ptr() -> *const u8`: return the pointer to the data buffer in WASM linear memory. This is used as the base address for copying data into the guest.
|
||||
2. `set_data_length(len: u32)`: update the globally mutable "data length" variable to signal to the guest how much data was actually written into the data buffer. The combination of these two calls lets you treat that global data buffer as a slice.
|
||||
2. The result buffer: a challenge-defined buffer that usually has about 32 bytes of data. This is read out of the guest's linear memory when the challenge is done processing.
|
||||
1. `result_hash_ptr() -> *const u8`: return the pointer to the result buffer in WASM linear memory. This is used as the base address for reading out of the guest.
|
||||
2. `result_hash_size() -> usize`: return the length of the result buffer (a compile time constant based on the needs of the challenge, but the runtime can't know that).
|
||||
3. The verification buffer: a challenge-defined buffer that usually has about 32 bytes of data. This is written into when the server is validating a challenge.
|
||||
1. `verification_hash_ptr() -> *const u8`: return the pointer to the result buffer in WASM linear memory. This is used as the base address for reading out of the guest.
|
||||
2. `verification_hash_size() -> usize`: return the length of the result buffer (a compile time constant based on the needs of the challenge, but the runtime can't know that).
|
||||
|
||||
Challenge modules also expose two entrypoints:
|
||||
|
||||
1. `anubis_work`: the main entrypoint for browsers. Given the data loaded into the challenge buffer, hash it in a tight loop until you get a solution that matches the difficulty.
|
||||
2. `anubis_verify`: the main entrypoint for the server. Given the data loaded into the challenge and verification buffers, ensuring that one run through the hashing function produces a result that both meets the difficulty demands and exactly matches what the client sent.
|
||||
|
||||
Challenge modules also import `anubis.anubis_update_nonce` from the environment so that they can periodically report their hash rate back to the frontend. This allows users to see a progress bar based on how long it should take to finish the process.
|
||||
|
||||
This works enough for now. It'll be interesting to see how this falls short in the real world\!
|
||||
|
||||
## The ride never ends
|
||||
|
||||
Honestly, the first bit of this took a few days at most. Most of the hard work was making sure that pointers, offsets, and whatnot were all wired up correctly so that the browser worked the same way as the server. My experience building and messing around with [many](https://github.com/Xe/olin) [WebAssembly](https://github.com/Xe/pahi) [runtimes](https://xeiaso.net/talks/unix-philosophy-logical-extreme-wasm/) and [egregious hacks](https://xeiaso.net/talks/wazero-lightning-2023/) meant that making it was really easy for me.
|
||||
|
||||
The devil came out in the details. Here are all the things that came up while I was working on this. All of these problems added up is the sole reason that this took a year instead of a week.
|
||||
|
||||
### SIMD means speed in my dispatch
|
||||
|
||||
Early on in development I found out that WebAssembly has a [SIMD extension](https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/SIMD). SIMD stands for [Single Instruction Multiple Data](https://en.wikipedia.org/wiki/Single_instruction,_multiple_data) and is a family of instructions that let you do operations on multiple values at a time. This gives programmers data-level parallelism (this is distinct from multi-threading) so that things like hash calculations and MP3 decoding can be done faster than they would be if each operation had to be its own instruction.
|
||||
|
||||
[CanIUse considers WebAssembly SIMD to be "baseline"](https://caniuse.com/wasm-simd) (supported by browsers newer than Chrome 91), but I have a lower version bound of Chrome 75\. However the benefits from SIMD on mobile devices are _so drastic_ that it's worth having two builds of the WebAssembly code: one with SIMD and one without it. In the browser it dispatches which version to use by using [wasm-feature-detect](https://www.npmjs.com/package/wasm-feature-detect) to probe WebAssembly functionality by trying to parse/run trivial minimal programs that exercise those features.
|
||||
|
||||
Hopefully I don't need to add [an additional build](https://github.com/TecharoHQ/anubis/blob/4578023de7b631537e3a43d89b1998e802beb7e0/web/js/algorithms/wasm.ts#L58-L62) into this process, but there is nothing in the tooling that would prevent it\!
|
||||
|
||||
### The birth and death of Yavascript
|
||||
|
||||
One of the big things that blocked this shipping for so long was not having an escape hatch of some kind to allow clients that disable WebAssembly by policy to get through the gate. In my experience most clients don't have JavaScript enabled but WebAssembly disabled, however there are a few notable usecases that forced my hand: iOS [Lockdown mode](https://support.apple.com/en-us/105120) and GrapheneOS' [Vanadium](https://discuss.grapheneos.org/d/4196-webassembly-on-vanadium)'s default configuration. This combination of factors means that there would need to be another implementation of the proof of work code in JavaScript that would actually execute the number crunching.
|
||||
|
||||
I don't want to make another implementation of the proof of work function (the entire point of this is to only have _one_ implementation\!) so while I was browsing around I came across the legendary talk [The Birth & Death of JavaScript](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript) and got a horrible idea. What if you just compiled the WebAssembly to JavaScript? Would that even work? It's "just" turning one Turing machine into another, right? How would it fare in practice?
|
||||
|
||||
Turns out I'm not the first person to think about this\! The team behind [binaryen](https://github.com/WebAssembly/binaryen) have made this escape hatch in the form of [wasm2js](https://github.com/WebAssembly/binaryen/blob/main/src/tools/wasm2js.cpp) which takes WebAssembly binaries and produces moderately cromulent JavaScript in response. One of the main downsides is that the generated binaries tend to be rather large.
|
||||
|
||||
For example consider this simple WebAssembly module that exposes a function that adds two numbers together:
|
||||
|
||||
```
|
||||
(module
|
||||
(func $add (param $lhs i32) (param $rhs i32) (result i32)
|
||||
local.get $lhs
|
||||
local.get $rhs
|
||||
i32.add)
|
||||
(export "add" (func $add))
|
||||
)
|
||||
```
|
||||
|
||||
Seems simple enough, right? Here's the JavaScript that generates:
|
||||
|
||||
```javascript
|
||||
function asmFunc(imports) {
|
||||
var Math_imul = Math.imul;
|
||||
var Math_fround = Math.fround;
|
||||
var Math_abs = Math.abs;
|
||||
var Math_clz32 = Math.clz32;
|
||||
var Math_min = Math.min;
|
||||
var Math_max = Math.max;
|
||||
var Math_floor = Math.floor;
|
||||
var Math_ceil = Math.ceil;
|
||||
var Math_trunc = Math.trunc;
|
||||
var Math_sqrt = Math.sqrt;
|
||||
function $0($0_1, $1) {
|
||||
$0_1 = $0_1 | 0;
|
||||
$1 = $1 | 0;
|
||||
return ($0_1 + $1) | 0 | 0;
|
||||
}
|
||||
|
||||
return {
|
||||
add: $0,
|
||||
};
|
||||
}
|
||||
|
||||
var retasmFunc = asmFunc({});
|
||||
export var add = retasmFunc.add;
|
||||
```
|
||||
|
||||
As you can imagine, this only gets [progressively worse](https://anubis.techaro.lol/.within.website/x/cmd/anubis/static/js/worker/wasm2js.mjs) as you end up making the Rust standard library get compiled from WASM to JavaScript, and even worse when you actually get hashing functions into the mix. The end result is probably very optimized when you run it through a JIT, but given that this runs on an interpreter it's probably gonna be slow no matter what I do.
|
||||
|
||||
Sorry\! I tried\!
|
||||
|
||||
### How I found the first compiler bug in my career
|
||||
|
||||
This ended up working fairly well in testing, but I tried building it in GitHub Actions and ran into an issue. I noticed that wasm2js was [packaged in Ubuntu](https://manpages.ubuntu.com/manpages/resolute/man1/wasm2js.1.html) and that the version in Fedora worked fine but the version in Ubuntu did not and threw an obscure error message about not understanding the tail call extension that Rust was using for some reason.
|
||||
|
||||
I ended up bisecting versions of binaryen by downloading a tarball, building it from source, and then seeing if the result of running it on the Anubis WebAssembly modules worked in a browser. I ended up selecting Binaryen version 128, the newest version at the time. It was new enough that most of [the distributions that package Anubis](https://repology.org/project/anubis-anti-crawler/versions) don't have that version of Binaryen packaged.
|
||||
|
||||
However I didn't want to make my life more complicated by having some kind of conditional compilation step that would effectively tell end users "sorry, the admin is using an unofficial build that just so happens to not support your browser, please complain to them" because they'll just end up complaining to me. In my experience the kinds of people who run this exact combination of circumstances also tend to be the kind of people that have a wide variance in the level of kindness they display to the authors of open source programs that happen to be in their way. So I needed an escape hatch that would _force_ build systems to use _the exact version_ that I use in my builds.
|
||||
|
||||
Then inspiration hit me as if Apollo himself sniped me from the heavens. We're dealing with WebAssembly here right? What's stopping us from just compiling the WebAssembly to JS tool to WebAssembly with some kind of reproducible build, committing that blob to the repo, and then moving on with life?
|
||||
|
||||
I ended up [finding a bug in LLVM](https://github.com/llvm/llvm-project/issues/204883) around how it was iterating over exception handling blocks by the compiler iterating over them in machine pointer order. As a result each build would drift by about 29 bytes per build:
|
||||
|
||||
```diff
|
||||
i32.load offset=4 ;; 28 02 04
|
||||
i32.const 6 ;; 41 06
|
||||
i32.ne ;; 47
|
||||
br_if 0 ;; 0d 00
|
||||
- try_table (catch_all_ref 8) ;; 1f 40 01 03 08
|
||||
+ try_table (catch_all_ref 4) ;; 1f 40 01 03 04
|
||||
+ try_table (catch_all_ref 9) ;; 1f 40 01 03 09
|
||||
local.get 2 ;; 20 02
|
||||
i32.const 32 ;; 41 20
|
||||
i32.add ;; 6a
|
||||
local.set 3 ;; 21 03
|
||||
local.get 2 ;; 20 02
|
||||
i32.const 56 ;; 41 38
|
||||
i32.add ;; 6a
|
||||
local.get 1 ;; 20 01
|
||||
i32.const 8 ;; 41 08
|
||||
i32.add ;; 6a
|
||||
call 17461 ;; 10 b5 88 81 80 00
|
||||
local.set 4 ;; 21 04
|
||||
end ;; 0b
|
||||
- try_table (catch_all_ref 4) ;; 1f 40 01 03 04
|
||||
local.get 3 ;; 20 03
|
||||
local.get 4 ;; 20 04
|
||||
```
|
||||
|
||||
This is what lead me to write [I hate compilers](https://xeiaso.net/notes/2026/anubis-wasm-vendor-binary/) as a combination blogpost/cry for help which made me realize this was actually an LLVM bug. I didn't instantly lean towards it being an LLVM bug until I figured out that disabling ASLR (via `setarch --addr-no-randomize`) made the results consistent on the same host within the same boot.
|
||||
|
||||
Honestly this is the first time in my career I've ever run into a compiler bug like this. When I do a lot of my work I usually work under the assumption that the compiler is bug-free and that my inputs are wrong somehow. As such, even thinking it could possibly be an LLVM bug was just outside of the realm of possibility for me.
|
||||
|
||||
Once that LLVM bug got fixed and a new version of [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) with that fix got released, I was off to the races, updated my build of wasm-opt/wasm2js, made my build scripts run it with [wasmtime](https://wasmtime.dev/) (alongside a wazero-based fallback process that would be slower, but did work enough) and everything worked out. Every time Anubis builds the WebAssembly in CI it uses the version of wasm-opt and wasm2js that ships in the repo to ensure that everything is as byte-for-byte deterministic as possible.
|
||||
|
||||
Your build tools can't differ from my build tools if I ship you the build tools I use.
|
||||
|
||||
### Okay, but will it work on Ukrainian Smart TVs?
|
||||
|
||||
Then we get into the other big problem that made this difficult: browser testing. One of the most common failure modes of Anubis is that someone uses some browser that I don't test in CI and then things don't work with it. I'm tired of installing 50 different browsers on several machines to test things and I have gone through so many throwaway VMs that I'm sure it's reduced the lifetime of my SSD.
|
||||
|
||||
:::note Aside
|
||||
|
||||
Yes, I really have been testing Anubis by hand in god knows how many browsers. Why do you think it takes so long to tag new releases?
|
||||
|
||||
:::
|
||||
|
||||
I built a harness that I call "chromesweep" that lets me spawn many Googles Chrome (term c.f. Attorneys General, et.al) in their default configuration to try and hit a version of Anubis listening over HTTPS. Getting this far meant making a library of all of these browser versions. I've put that library up on Github at [TecharoHQ/gubal](https://github.com/TecharoHQ/gubal) in case it's useful for you.
|
||||
|
||||
One of the other big problems I ran into while getting browser testing working was making sure that my Googles Chrome strictly stay within the bounds of my Kubernetes cluster's network. Chrome this old is actively radioactive and I want to treat it like the security threat it is. As such, I set up a strict [NetworkPolicy](https://kubernetes.io/docs/concepts/services-networking/network-policies/) to only allow it to access the Anubis instance under test and make DNS queries. I also wrap each Chrome pod in a microVM with [Kata containers](https://katacontainers.io/) as an additional layer of security.
|
||||
|
||||
:::note Aside
|
||||
|
||||
It honestly terrifies me to think that I am putting more effort into securing these Googles Chrome than [big AI companies are putting into securing their AI agent testing infrastructure](https://collusion.wiki/). It literally doesn't take much to put a big dent into securing things! The current state of our industry boggles the mind. All I want is for Techaro's [FelonyBench](https://www.felonybench.com/) score to remain at 0, is that too much to ask?
|
||||
|
||||
:::
|
||||
|
||||
I also rigged the browser testing infrastructure up to a single slash command in GitHub pull requests. Doing it makes my office very warm so I try to avoid doing it when possible. This works well enough that it lets me move on to the next stage and has already caught something that lead to building all the JavaScript with the `--chrome66` flag.
|
||||
|
||||

|
||||
|
||||
I wonder if this is yet another case where making infrastructure for Anubis could result in that infrastructure alone being its own viable tech product. I run into a lot of those.
|
||||
|
||||
### Yo dawg, heard you liked compiling
|
||||
|
||||
In the process of doing that automated browser testing I found out that Chrome 75 had a weird error pop up when it tried to compile Anubis' WASM to native code:
|
||||
|
||||
```
|
||||
CompileError: WebAssembly.compile(): Compiling function
|
||||
#4:\"_RINvMs0_NtNtNtNtCsdl5sGgnNXvY_3std3sys4sync4on...\" failed:
|
||||
expected table index 0, found 128 @+664
|
||||
```
|
||||
|
||||
This also caused failures up to Chrome 100, so this signaled to me that something I was doing with my "strict MVP" build of Anubis' WASM wasn't in fact sticking to just the MVP features of WebAssembly. It turns out that the function referenced (probably somewhere in [std::sync::Once](https://doc.rust-lang.org/std/sync/struct.Once.html)? I probably should have traced it down to the exact bit) was in the standard library. This surprised me because I assumed that building Rust code with CPU features selected would apply that to everything, including the standard library, right?
|
||||
|
||||
No, turns out that when you download the [`rust-std` component](https://rust-lang.github.io/rustup/concepts/components.html) in [rustup](https://rustup.rs/), that doesn't just download the standard library. To aid in cross compilation and I guess to avoid disk space waste, the Rust standard library is precompiled. This surprised me as Go typically has you recompile the standard library (and runtime for that matter) when doing normal builds and cross compilation.
|
||||
|
||||
:::note Aside
|
||||
|
||||
The actual issue here is that the stdlib function in question was compiled down to use [reference types](https://bytecodealliance.org/articles/reference-types-in-wasmtime), which made [`call_indirect`](https://webassembly.github.io/spec/core/exec/instructions.html#xref-syntax-instructions-syntax-instr-control-mathsf-call-indirect-x-y) references get stored as a table index instead of what MVP WebAssembly would put there. Chrome tried to read a null byte, got not a null byte, and then understandably exploded.
|
||||
|
||||
:::
|
||||
|
||||
I looked into the process involved for rebuilding the standard library twice: once with only MVP wasm features enabled and once with an "all yes config" like usual. Based on [some research I did](https://wiki.osdev.org/Porting_Rust_standard_library) this seemed like a massive pain.
|
||||
|
||||
However, I had gone through that effort to build reproducible WASI versions of wasm2js and wasm-opt. [wasm-opt](https://github.com/WebAssembly/binaryen#tools) is a tool that lets you take compiled WebAssembly modules, optimize them, and more importantly remove features from them so they can run in older browsers. After a bit of hacking to make sure that the tools were able to run properly, I set up a Claude Opus / GLM 5.2 loop to fuzz various wasm-opt flags and make sure Chrome 75 could parse the output. I ended up with these flags:
|
||||
|
||||
```shell
|
||||
# Chrome shipped sign-ext and mutable-globals in 74, bulk-memory and
|
||||
# nontrapping-fptoint in 75, multivalue in 85 and simd in 91.
|
||||
baseline_features="-mvp --enable-sign-ext --enable-mutable-globals \
|
||||
--enable-bulk-memory --enable-nontrapping-float-to-int"
|
||||
simd128_features="${baseline_features} --enable-multivalue --enable-simd"
|
||||
```
|
||||
|
||||
This strips away all the other WebAssembly features from the build like unwanted paint (the `-mvp` flag means "disable everything not in the original MVP definition of WebAssembly"). I think that it'd be safe-ish to enable reference types in the SIMD build (they were added before Chrome added SIMD), but it's not hurting anything to remove them so I'll just let cowardice win here. Either way, I threw the results into chromesweep and got a successful response, so win\! If/when this comes to bite me I'll try and improve it.
|
||||
|
||||
## Things that probably need to be fixed at some point but I want to see what's on fire in practice first, you know?
|
||||
|
||||
I'm pretty sure that this work isn't _perfect_, but at some point you gotta cut your losses, ship it, and then see where things fail to prioritize perfecting it. These issues include but are not limited to:
|
||||
|
||||
- The wasm2js flow doesn't currently have a way to update the progress bar with its `update_nonce` import stubbed out. I have no idea how to properly wire that up with the constraints of my runtime, but I'm sure I can figure it out eventually.
|
||||
- The WebAssembly that's shipped with this flow is ridiculously performant. This may mean you need to adjust the difficulty to compensate for this. Oops\! Sorry\!
|
||||
- This is better on mobile phones, but I'm working on a mobile request classifier that will use a combination of IP address reputation, TLS fingerprinting, and other signals to determine if a request is from a phone and give it the appropriate amount of grace. This is hard. Please contact me if you have ideas on how to make my current prototype better.
|
||||
- I need some way to dynamically rotate out challenge programs at runtime instead of just at compile time when I work on Anubis. Eventually I hope to have this pull WebAssembly files and supporting bundles from OCI/Docker registries, but I need to do a lot more experimentation with this before I can conclude how good/bad of an idea this is.
|
||||
|
||||
Overall though, I'm hopeful that most of the worst parts of this can be solved. It would be nice if I didn't have to work what amounts to two full time jobs.
|
||||
|
||||
## Ad astra per aspera
|
||||
|
||||
I'm pretty sure that this is stable enough to ship as off-by-default in Anubis v1.28.0: [Wuk Lamat](https://ffxiv.consolegameswiki.com/wiki/Wuk_Lamat). Based on the feedback I get from administrators and users, I'll enable it in the default configuration in Anubis v1.29.0.
|
||||
|
||||
I hope this look into how Anubis is developed can give you ideas as to the scale and challenge involved. Making something like this is tireless and thankless work and it's really weird to see people talk about it in the same breath as Cloudflare or AWS' WAF.
|
||||
|
||||
Have a good day all!
|
||||
|
||||
:::note Aside
|
||||
|
||||
AI was not used in the production of the prose of this article. I have my draft as [a Google Doc](https://docs.google.com/document/d/1n-KE0M3gvXXmkWVRy-stT0pWHrz0u0aApaOastqwNEM/edit?tab=t.cknmv81px79i#heading=h.bh5cic8vnftr) so you can see exactly where and when I typed every word myself. The only use of AI was Claude Opus to help me make the visual bit/nibble diagram.
|
||||
|
||||
:::
|
||||
|
After Width: | Height: | Size: 32 KiB |
@@ -13,6 +13,243 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<!-- This changes the project to: -->
|
||||
|
||||
## v1.28.2: Wuk Lamat Echo 2
|
||||
|
||||
- Add Catalan (ca) localization.
|
||||
- Allow Renovate in git clients for github/gitlab api endpoint.
|
||||
- Bump minimum Go version to 1.27.3 in light of eMudhra (fixes CVE-2026-111943).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Add `utils/cmd/botgenerate` for automatically updating crawler IP ranges. Also apply the updates.
|
||||
- Do not reject with `400 Bad Request` a request whose `Content-Type` is `multipart/form-data` but whose body is empty, including when the content length is unknown (`-1`, for example a chunked request). Reverse proxies that strip the body for auth subrequests (for example nginx' `auth_request`) still forward the original `Content-Type`, which made `prepareChallengeForm` fail and answer with a spurious 400.
|
||||
- Reject requests with no `User-Agent` header or an empty `User-Agent` header via `(data)/bots/spec-violations.yaml`.
|
||||
- Accept GeoIP2 ISP databases for ASN lookups and GeoLite2 City databases for country lookups.
|
||||
- Fix concurrent WASM challenge validation failures by instantiating transient modules anonymously, allowing the existing four-slot verifier concurrency limit to work as intended.
|
||||
|
||||
## v1.28.1: Wuk Lamat Echo 1
|
||||
|
||||
- Revert systemd isolation change that worked fine in testing but failed in prod.
|
||||
|
||||
## v1.28.0: Wuk Lamat
|
||||
|
||||
This release adds WebAssembly based proof of work checks to Anubis. They are documented in the [Proof of Work (WebAssembly)](https://anubis.techaro.lol/docs/admin/configuration/challenges/wasm) page. This uses Rust code compiled to WebAssembly to run proof of work code. When browsers support SIMD, the WASM will use hardware acceleration.
|
||||
|
||||
When clients are configured to disable WebAssembly, Anubis falls back to a pure JavaScript implementation of the WebAssembly-based check logic. As clients that disable WebAssembly usually disable the JavaScript JIT (the thing that makes JavaScript fast), this makes checks slower.
|
||||
|
||||
Additionally due to complicated facts and circumstances involving it being complicated to pass the messages from the wasm2js world back to JavaScript, the progress bar will not update while a wasm2js check is running. This is a known issue and will be fixed in a later release.
|
||||
|
||||
The difficulty values for the WebAssembly based checks are going to be much greater than the equivalent difficulty values for the JavaScript based checks. Generally these count the number of leading _bits_ that much match instead of the number of leading _nibbles_ that must match. Here's a rough translation table:
|
||||
|
||||
| `fast` difficulty | `argon2id` difficulty | `sha256` difficulty | `hashx` difficulty |
|
||||
| :---------------- | :-------------------- | :------------------ | :----------------- |
|
||||
| `4` | `4` | `16` | `15` |
|
||||
| `2` | `2` | `8` | `7` |
|
||||
| `6` | `6` | `24` | `20` |
|
||||
|
||||
As I'm not certain this will work fine out of the box for a few edge cases, I have disabled these new challenge methods by default. I will enable the new methods by default in a future version after they have been sufficiently tested.
|
||||
|
||||
- Use node.js for running wasm in CI.
|
||||
- Fix [GHSA-5gwm-367w-7fgj](https://github.com/TecharoHQ/anubis/security/advisories/GHSA-5gwm-367w-7fgj), which allowed attackers that control the PTR records for their IP addresses to bypass Anubis via setting multiple PTR records pointing to various search engines.
|
||||
- Replace Thoth with [GeoIP databases](./admin/geoip.mdx). GeoIP databases are configured in the `geoip` block.
|
||||
- Thoth functionality has been removed. `THOTH_URL`, `THOTH_TOKEN`, and `THOTH_INSECURE` are now deprecated environment variables that will log a warning upon startup.
|
||||
- ASN description values now use the Maxmind values instead of the values that Thoth returned. This may impact your fail2ban rules.
|
||||
- Native packages now create an `anubis` group and assign all Anubis instances permissions to `/var/lib/anubis`.
|
||||
- Fix the original-referer cookie not being affected by the `COOKIE_PREFIX` setting ([#1977](https://github.com/TecharoHQ/anubis/pull/1977))
|
||||
- Default to the simplified explanation to avoid people misinterpreting words. `USE_SIMPLIFIED_EXPLANATION` is now deprecated.
|
||||
- Add Portuguese (Portugal) (`pt-PT`) localization.
|
||||
- Add documentation for the [Headless Browser Detection](./admin/configuration/challenges/extensions/headless.mdx) extension and the [Soteria](./admin/configuration/challenges/) challenge methods exclusive to BotStopper.
|
||||
- Add DYNAMIC_COOKIE_SUFFIX setting for toggling the dynamically generated cookie suffix [#1992](https://github.com/TecharoHQ/anubis/pull/1992)
|
||||
- Retry a missing challenge verification cookie once per client before reporting that cookies are disabled, allowing browsers affected by transient cookie loss during navigation to recover without creating an infinite challenge loop ([#1916](https://github.com/TecharoHQ/anubis/issues/1916)).
|
||||
- Use a bundled version of `wasm2js` in order to make the WebAssembly proof of work checks run in non-wasm environments.
|
||||
- Make the bundled `wasm2js`/`wasm-opt` WebAssembly modules build reproducibly and fix the build on arm64.
|
||||
- Add the concept of [Challenge Extensions](./admin/configuration/challenges/extensions/index.mdx) and add the sample [css-load](./admin/configuration/challenges/extensions/css-load.mdx) extension.
|
||||
- Fix `npm run test:integration` so the Playwright suite can connect to browsers and Firefox can reach the test server again.
|
||||
- Add weighing rule for [Cloudflare Kitesurf](https://blog.cloudflare.com/kitesurf/). Kitesurf doesn't currently support Cookies, but it might in the future.
|
||||
- Improved Norwegian Nynorsk localization.
|
||||
- Stop clearing the authorization cookie when a challenged request did not send one. A subresource request that starts before the challenge is passed but finishes after it no longer deletes the cookie that `pass-challenge` just issued ([#1314](https://github.com/TecharoHQ/anubis/issues/1314)).
|
||||
- Fix proof of work worker spawning fallback logic to properly detect Content-Security-Policy failures and fall back to the older logic that fans out to one request per hardware core ([#1864](https://github.com/TecharoHQ/anubis/issues/1864)).
|
||||
- [Content-Security-Policy advice](./admin/configuration/content-security-policy.mdx) has been added to the documentation.
|
||||
- Passthru `Host` header as `X-Forwarded-Host` in Open Graph requests so backends can dispatch based on host.
|
||||
- Detect and block trivial attempts at [domain fronting](https://en.wikipedia.org/wiki/Domain_fronting) as bots have been starting to use that to try and turn web applications or HTTP servers into open proxies.
|
||||
- Add [HyperAgent](https://github.com/hyperbrowserai/HyperAgent/issues/91) to the headless browsers block rule.
|
||||
- Fix Dutch localization typo in the "go home" link.
|
||||
- WASM challenges now share watchdog, CSP, and defer fixes from v1.27.0.
|
||||
- WASM challenge workers now report errors to the challenge page instead of failing silently.
|
||||
- Add prebuilt binaries for NetBSD on amd64 and arm64.
|
||||
- Fix WASM build scripts on macOS, which has ancient coreutils that lacks features present on GNU+Linux.
|
||||
- Consolidate the purejs and webcrypto workers into one sha256 browser worker to avoid code duplication.
|
||||
- Rename X-Real-Ip to X-Real-I**P** in challenge metadata.
|
||||
- Fix client-supplied `X-Anubis-*` header spoofing
|
||||
- Log "challenge accepted" at INFO level when challenge is accepted, providing challenge lifecycle observability at quieter log levels than DEBUG.
|
||||
- Fix `npm run test:integration` and the Playwright CI step, which were pinned to `playwright@1.61.1` while `go.mod`'s `mxschmitt/playwright-go` had already been bumped to a client expecting protocol 1.62.x, causing every Playwright-driven test to fail with a version mismatch.
|
||||
- Restore the original `Referer` header on the request forwarded to the target after a challenge is passed, so server-side logs and analytics no longer see the internal challenge page as the referrer. Add an opt-in `--preserve-referer-query-param` flag that also appends `utm_source`/`utm_medium` query parameters to the post-challenge redirect for client-side analytics tools (e.g. Plausible) that read query parameters instead of `document.referrer`, which cannot be corrected from the server side ([#1596](https://github.com/TecharoHQ/anubis/issues/1596)).
|
||||
- Clarify getChallenge failure response and cite related log entry.
|
||||
- Share redirect validation between challenge completion and subrequest authentication. Reject ambiguous URL forms before checking allowed domains.
|
||||
- Respond with the configured `DENY` status code instead of HTTP 500 when a challenged client is rejected for not advertising gzip support, and log that rejection at `INFO` instead of `ERROR`. The rejection is deliberate, so it no longer shows up in 5xx rates or as a server fault. The log message text is unchanged, but fail2ban filters that match on the `ERROR` level need updating ([#1009](https://github.com/TecharoHQ/anubis/issues/1009)).
|
||||
- Anubis now can use dynamic IP lists from providers like OpenAI or Google instead of static IP lists.
|
||||
|
||||
### Small security fixes
|
||||
|
||||
As part of a continuous security posture, the following issues were identified and remediated:
|
||||
|
||||
- Challenge validation for WASM based checks could fail open when users pass specifically crafted invalid input.
|
||||
- WASM challenges may only have four in-flight validations at once per process, the rest will wait in line.
|
||||
- Challenge solutions are now strictly bound to the issuing rule.
|
||||
- Path policies now prevent path traversal bypasses in some edge cases.
|
||||
- Duplicate header values are now consistently handled across edge cases.
|
||||
- Forwarded URI paths are evaluated separately from query strings.
|
||||
- Disallow clients from sending their JA4H value by using the Set header verb instead of Add.
|
||||
- Avoid a panic when parsing IPv6 answers from DNSBL hits in edge cases.
|
||||
- Avoid caching negative hits from DNSBL servers.
|
||||
- CDNs and middleware are now instructed to NOT cache Anubis challenge, completion, forward-auth, and error pages.
|
||||
- When a dynamic IP list updates to a list that has no entries, keep using the previous entry instead of deleting all IP list contents from memory.
|
||||
- Reject short HS512 secrets.
|
||||
- Restrict honeypot log permissions.
|
||||
- Handle malformed client IP addresses safely.
|
||||
- Fix concurrent TLS SNI handling in edge cases.
|
||||
- DNSBL hits are now cached correctly, even when the result is no entry found.
|
||||
|
||||
## v1.27.0: Moenbryda Wilfsunnwyn
|
||||
|
||||
Anubis v1.27.0 adds Windows Server support, automatically renames cookies based on settings to avoid infinite challenge loops, adds two new localizations, and more.
|
||||
|
||||
### Breaking change: cookie names are dynamically created based on cookie settings
|
||||
|
||||
Anubis tries to avoid breaking changes as much as possible, but sometimes we have to make them for the sake of the users. This is technically a breaking change in something that is not part of the public API of Anubis; but some administrators rely heavily on cookie names in advanced configurations.
|
||||
|
||||
It seems that browsers store cookies disambiguated with their options. This means you can have multiple cookies named the same but with different options. Browsers will send these cookies to the server without the list of options. This means that changing any cookie settings requires you to change `COOKIE_PREFIX`, creating a new "cookie epoch" that will set things properly.
|
||||
|
||||
In order to be more robust, Anubis will automatically change cookie names based on the cookie settings. For example, the default configuration creates cookies named `techaro.lol-anubis-auth-347ddb4a`.
|
||||
|
||||
Without this change, changing _any_ cookie setting without every client clearing their cookies causes challenges to become an infinite loop of thrashing, making it appear that Anubis "blocked" them.
|
||||
|
||||
If this becomes onerous in practice for administrators of HAProxy and other advanced setups that rely on cookie names, we will add an escape hatch in the policy file.
|
||||
|
||||
### Windows Server support (beta)
|
||||
|
||||
Anubis now publishes `.msi` packages, allowing administrators to install and run Anubis on Windows Server. Please read the [Windows Server page](./admin/environments/windows.mdx) for more information.
|
||||
|
||||
This support is beta-grade as the Anubis team does not have a lot of experience with developing software for Windows Server. Feedback is more than welcome.
|
||||
|
||||
Please let us know how it works for you!
|
||||
|
||||
### Pre-release docker images no longer populate the `latest` tag
|
||||
|
||||
Due to a misconfiguration of the GitHub Action [docker/metadata-action](https://github.com/docker/metadata-action), pre-release Docker images previously populated the `:latest` tag. This means that administrators that expected the `:latest` tag to result in a stable release of Anubis got a prerelease version suddenly when they ran automatic updates.
|
||||
|
||||
If administrators want to opt-in to the prerelease build track of Anubis for more frequent access to new features, they can use the `:pre` tag:
|
||||
|
||||
```yaml
|
||||
image: ghcr.io/techarohq/anubis:pre
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
- Allow importing bot policy rules [using wildcard matching](./admin/configuration/import.mdx#importing-many-files-at-once) ([#1815](https://github.com/TecharoHQ/anubis/issues/1815)).
|
||||
- Add support for JSON sources to iplist2rule ([#1833](https://github.com/TecharoHQ/anubis/pull/1833))
|
||||
- Make the honeypot feature log detected addresses to the disk every minute when `honeypot.ip_log_file` is set. See the [IP address logging](./admin/honeypot/overview.mdx#ip-address-logging) section for more information.
|
||||
- Add standard library rules for making Dillo less threatening to Anubis and [document how to enable them](./admin/faq.mdx#how-do-i-allow-small-internet-browsers-like-dillo-netsurf-and-pale-moon-to-bypass-anubis).
|
||||
|
||||
#### Crawlers
|
||||
|
||||
- Allow [Arquivo.pt](https://arquivo.pt), the Portuguese web archive, by default via its crawling network.
|
||||
- Add `(data)/bots/lyrenth.yaml` snippet that denies [Lyrenth](https://lyrenth.com/bot)'s `AIWebIndex` crawler and `AIWebIndex-Agent` on-demand fetcher by user agent and by their [published IP ranges](https://www.lyrenth.com/bot/ip-ranges.json). This is imported by `(data)/bots/_deny-pathological.yaml`.
|
||||
- Updates Alibaba cloud IP list ([#1813](https://github.com/TecharoHQ/anubis/pull/1813))
|
||||
- Updates Googlebot IP list ([#1812](https://github.com/TecharoHQ/anubis/pull/1812))
|
||||
- Updates IP list for DuckDuckBot ([#1810](https://github.com/TecharoHQ/anubis/pull/1810))
|
||||
- Update Huawei Cloud IP list ([#1814](https://github.com/TecharoHQ/anubis/pull/1814))
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix bot policy imports to not require pedantically correct YAML formatting when using wildcard matching.
|
||||
- JavaScript served by the `fast` challenge is loaded using [`defer`](https://www.w3schools.com/tags/att_script_defer.asp) instead of `async` ([#1782](https://github.com/TecharoHQ/anubis/issues/1782)).
|
||||
- Amend default [Lightpanda](https://lightpanda.io/) rule to match current behaviour, add smoke test to ensure it keeps working ([#1822](https://github.com/TecharoHQ/anubis/issues/1822)).
|
||||
- Fix a panic when a request asks for the undetermined language tag, such as `Accept-Language: und` ([#1776](https://github.com/TecharoHQ/anubis/issues/1776)).
|
||||
- Allow user agents that start with capital-G `Git` in `(data)/clients/git.yaml`.
|
||||
- Enabled the Partitioned flag on cookies by default ([#1701](https://github.com/TecharoHQ/anubis/issues/1701)).
|
||||
- Fix Windows MSI builds on prerelease tags such as `v1.27.0-pre1`.
|
||||
- Bump AI-robots.txt to version 1.47.
|
||||
|
||||
### i18n
|
||||
|
||||
- Add Basque (eu) localization.
|
||||
- Update Bulgarian locale ([#1708](https://github.com/TecharoHQ/anubis/pull/1708))
|
||||
- Add Croatian (hr) localization.
|
||||
|
||||
## v1.26.2: Papalymo Totolymo: Echo 2
|
||||
|
||||
- Automatically verify correct parsing of everything in `(data)`. While doing post-release checks on v1.26.1, I discovered that I incorrectly merged `(data)/services/updown.yaml` in such a way that it became syntactically invalid. This has been mended and multiple layers of CI have been put into place to make sure that `(data)` entries are syntactically and semantically valid.
|
||||
|
||||
## v1.26.1: Papalymo Totolymo: Echo 1
|
||||
|
||||
- Fix support for semicolon-delimited query parameters that was dropped when moving from [net/http/httputil#ReverseProxy](https://pkg.go.dev/net/http/httputil#ReverseProxy).Director (deprecated) to net/http/httputil#ReverseProxy.Rewrite. This re-enables support for upstreams like gitweb ([#1763](https://github.com/TecharoHQ/anubis/issues/1763)). A functional test has been added to ensure this does not repeat.
|
||||
|
||||
### Challenge page robustness
|
||||
|
||||
The challenge page can now survive transient failures, reduces the number of requests it makes to the Anubis app, and adds exponential backoff with retries to counteract an overwhelmed server being unable to serve any assets.
|
||||
|
||||
Previously if any request for JavaScript assets failed, the entire challenge attempt failed and users were forced to manually refresh the page, which is a bit of a bad user experience. This was made worse when the load balancer does not support HTTP/2, did not have resumable sessions enabled, and was implemented with Apache httpd pre-fork; making each asset fetch do its own TCP/TLS handshake. Under periods of heavy load such that TCP/TLS handshakes timed out, this made Anubis unable to fetch assets consistently or even made in-progress challenge attempts fail, which made challenges impossible to pass.
|
||||
|
||||
This has been fixed in a few ways:
|
||||
|
||||
- Fetch operations now retry with [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) in hopes that they will eventually be able to get through when the server is less stressed.
|
||||
- Attempting to fetch the `main.mjs` script now has fallback watchdog logic that periodically re-attempts to load the script.
|
||||
- Worker source code is fetched _once_ and then loaded into workers with a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instead of having each worker do an independent fetch of the worker source code.
|
||||
- Individual workers can now die without making the entire challenge attempt fail. Surviving workers will cover the rest of the nonce space.
|
||||
- When worker construction fails, already running proof of work workers are terminated instead of staying active as headless unmonitored infinite loops.
|
||||
- Proof of work failures are now exposed as untranslated real errors. Browsers signal script load failures with real Events so the challenge failure page now shows a useful message.
|
||||
|
||||
## v1.26.0: Papalymo Totolymo
|
||||
|
||||
- Add option to [disable the honeypot](./admin/policies.mdx#honeypot-configuration).
|
||||
- Add `(data)/clients/google-user-triggered-fetchers.yaml` snippet that allows Google-owned user-triggered fetchers (Google Translate's website translation proxy, Google Read Aloud, Google Messages link previews) by their [published IP ranges](https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers-google.json), fixing the infinite challenge loop for visitors using Google Translate ([#444](https://github.com/TecharoHQ/anubis/issues/444))
|
||||
- Update QwantBot remote addresses range with latest value
|
||||
- Migrate check-spelling workflow config to [cspell](https://cspell.org/)
|
||||
- Add [Anubis Kubernetes Operator](https://github.com/eznix86/anubis-kubernetes-operator/) to the docs ([#1675](https://github.com/TecharoHQ/anubis/pull/1675)).
|
||||
- Bump Playwright browser tooling to 1.61.1 and playwright-go to v0.6100.0.
|
||||
- Add FreeBSD/Windows binaries to the yeetfile.
|
||||
- Add systemd system extensions to the yeetfile.
|
||||
- Set an explicit esbuild `--target=chrome66` so modern syntax (e.g. optional chaining) is transpiled down. This lowers the minimum supported browser from Chrome 80 to Chrome 66.
|
||||
- Patch [GHSA-6wcg-mqvh-fcvg](https://github.com/TecharoHQ/anubis/security/advisories/GHSA-6wcg-mqvh-fcvg) by containing subrequest logic to Anubis instances in subrequest mode.
|
||||
- Implement robot9001 style delays on the honeypot feature so that the first hit takes 1 millisecond, the second takes 2, etc.
|
||||
- Move metrics server configuration to [the policy file](./admin/policies.mdx#metrics-server).
|
||||
- Expose [pprof endpoints](https://pkg.go.dev/net/http/pprof) on the metrics listener to enable profiling Anubis in production.
|
||||
- fix: prevent nil pointer panic in challenge validation when threshold rules match during PassChallenge (#1463)
|
||||
- Instruct reverse proxies to not cache error pages.
|
||||
- Fixed mixed tab/space indentation in Caddy documentation code block
|
||||
- Improve error messages and fix broken REDIRECT_DOMAINS link in docs ([#1193](https://github.com/TecharoHQ/anubis/issues/1193))
|
||||
- Add Bulgarian locale ([#1394](https://github.com/TecharoHQ/anubis/pull/1394))
|
||||
- Fixed case-sensitivity mismatch in geoipchecker.go
|
||||
- Use [Go's native version stamping](https://michael.stapelberg.ch/posts/2026-04-05-stamp-it-all-programs-must-report-their-version/) instead of a handrolled variant.
|
||||
- Fix CEL internal errors when iterating `headers`/`query` map wrappers by implementing map iterators for `HTTPHeaders` and `URLValues` ([#1465](https://github.com/TecharoHQ/anubis/pull/1465)).
|
||||
- Enable [metrics serving via TLS](./admin/policies.mdx#tls), including [mutual TLS (mTLS)](./admin/policies.mdx#mtls).
|
||||
- Enable [HTTP basic auth](./admin/policies.mdx#http-basic-authentication) for the metrics server.
|
||||
- Fix a bug in the dataset poisoning maze that could allow denial of service [#1580](https://github.com/TecharoHQ/anubis/issues/1580).
|
||||
- Add config option to add ASN to logs/metrics.
|
||||
- Log weight when issuing challenge.
|
||||
- Block x.ai's crawler for code review training.
|
||||
- Gate pprof endpoints behind `metrics.debug` in the policy file.
|
||||
- Limit naive honeypot r9k delay to one second.
|
||||
- Fix an obscure case where adding query values to a subrequest match could cause an invalid rule match when using path based matching for protected resources.
|
||||
- Anubis now requires Go 1.26 to build.
|
||||
- Fix an edge case where load average expression values could nil pointer dereference when Anubis just started up.
|
||||
- Fix an obscure case where Anubis in subrequest mode could allow redirects to invalid domains with strange instructions.
|
||||
- Fix `path_regex` and CEL `path` rules not matching when using Traefik `forwardAuth` middleware. Anubis now checks `X-Forwarded-Uri` (Traefik) in addition to `X-Original-URI` (nginx) when resolving the request path in subrequest mode ([#1628](https://github.com/TecharoHQ/anubis/issues/1628)).
|
||||
- Validate bounds in the CEL `randInt` helper so non-positive or platform-overflowing arguments surface a typed CEL error instead of an evaluator panic.
|
||||
- Fix a race in the bbolt store where the asynchronous cleanup scheduled by an expired read could delete a value that had just been refreshed; the delete now only fires when the key still carries the same expired generation it observed.
|
||||
- Marginally increase the performances of requests processing
|
||||
- Marginally improve the performances of PoW validation
|
||||
- Marginally improve the performances of challenges generation/display
|
||||
- Significantly improve the performances of the gzip middleware
|
||||
- Significantly improve the performances of the PoW validation
|
||||
- Add trimpath option to artifact builds
|
||||
- Add COOKIE_HTTP_ONLY option to set the HttpOnly flag on Anubis cookies
|
||||
- Improve the performances of rules validation
|
||||
- Only compute the JA4H fingerprint when a policy references the `X-Http-Fingerprint-JA4H` header, taking it off the hot path for configurations that don't use it ([#834](https://github.com/TecharoHQ/anubis/pull/834)).
|
||||
- Migrate the target reverse proxy off the deprecated `httputil.ReverseProxy.Director` to `Rewrite` for Go 1.26 compatibility, preserving the inbound `Host` and `X-Forwarded-*`/`Forwarded` headers.
|
||||
- The bbolt storage backend no longer writes its freelist to disk on every commit and now uses the faster hashmap freelist. This can significantly reduce write overhead with the tradeoff that the freelist needs to be rebuilt in memory on a database open. Change works with existing databases.
|
||||
|
||||
## v1.25.0: Necron
|
||||
|
||||
Hey all,
|
||||
@@ -406,7 +643,7 @@ Anubis now is able to store things persistently [in memory](./admin/policies.mdx
|
||||
|
||||
Anubis now supports localized responses. Locales can be added in [lib/localization/locales/](https://github.com/TecharoHQ/anubis/tree/main/lib/localization/locales). This release includes support for the following languages:
|
||||
|
||||
- [Brazilian Portugese](https://github.com/TecharoHQ/anubis/pull/726)
|
||||
- [Brazilian Portuguese](https://github.com/TecharoHQ/anubis/pull/726)
|
||||
- [Chinese (Simplified)](https://github.com/TecharoHQ/anubis/pull/774)
|
||||
- [Chinese (Traditional)](https://github.com/TecharoHQ/anubis/pull/759)
|
||||
- English
|
||||
@@ -878,7 +1115,7 @@ Livia sas Junius: Echo 2
|
||||
|
||||
Livia sas Junius: Echo 1
|
||||
|
||||
- Set the `X-Real-Ip` header based on the contents of `X-Forwarded-For`
|
||||
- Set the `X-Real-IP` header based on the contents of `X-Forwarded-For`
|
||||
[#62](https://github.com/TecharoHQ/anubis/issues/62)
|
||||
|
||||
## v1.14.0
|
||||
|
||||
@@ -13,7 +13,6 @@ If you want to use Anubis but organizational policies prevent you from using the
|
||||
In the near future this will expand to:
|
||||
|
||||
- A private challenge implementation that does advanced fingerprinting to check if the client is a genuine browser or not
|
||||
- Advanced fingerprinting via [Thoth-based advanced checks](./thoth.mdx)
|
||||
|
||||
In order to sign up for BotStopper, please do one of the following:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: When using Caddy with Gitea/Forgejo
|
||||
---
|
||||
|
||||
Gitea/Forgejo relies on the reverse proxy setting the `X-Real-Ip` header. Caddy does not do this out of the gate. Modify your Caddyfile like this:
|
||||
Gitea/Forgejo relies on the reverse proxy setting the `X-Real-IP` header. Caddy does not do this out of the gate. Modify your Caddyfile like this:
|
||||
|
||||
```python
|
||||
ellenjoe.int.within.lgbt {
|
||||
@@ -12,7 +12,7 @@ ellenjoe.int.within.lgbt {
|
||||
# diff-add
|
||||
reverse_proxy http://localhost:3000 {
|
||||
# diff-add
|
||||
header_up X-Real-Ip {remote_host}
|
||||
header_up X-Real-IP {remote_host}
|
||||
# diff-add
|
||||
}
|
||||
# ...
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"label": "Challenge Extensions",
|
||||
"position": 10,
|
||||
"link": null
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# CSS Loading
|
||||
|
||||
This extension asserts that a client is able to load CSS from the server. It works by sending instructions to import a test route and then ensures that the client actually hits that route.
|
||||
|
||||
## Configuration
|
||||
|
||||
Add it to an `extensions` block in an existing `challenge` definition:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: mild-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight > 0
|
||||
- weight < 10
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: sha256
|
||||
difficulty: 8
|
||||
report_as: 8
|
||||
extensions:
|
||||
- css-load
|
||||
```
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: Headless Browser Detection
|
||||
---
|
||||
|
||||
import EnterpriseOnly from "@site/src/components/EnterpriseOnly";
|
||||
|
||||
<EnterpriseOnly link="../../../botstopper/" />
|
||||
|
||||
BotStopper can run basic headless browser detection on challenge pages. This detector is a small proprietary bit of code that examines browsers for signs of automation tooling. Before the client submits a challenge, the detector sends a report to BotStopper. This report is used in a few ways:
|
||||
|
||||
- If the report contains any hard signals, the challenge fails no matter what the browser submitted. This catches many careless implementations of browser automation tooling.
|
||||
- If any component request for any part of the detector module contains unexpected changes (IE: User-Agent strings changing mid detection), the challenge fails.
|
||||
|
||||
## Enabling the extension
|
||||
|
||||
To enable headless browser detection, add `headless` to the `extensions` list of a challenge:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: sha256
|
||||
difficulty: 16
|
||||
extensions:
|
||||
- headless
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
This detection process requires the execution of JavaScript and WebAssembly in user browsers. There is currently no way to mitigate this requirement and a no-JS mode for this detector is not currently planned. Please adjust your deployment expectations around this fact.
|
||||
|
||||
:::
|
||||
|
||||
## Caveats to keep in mind
|
||||
|
||||
This challenge extension relies on many _subtle_ behaviors of browser behaviour. You **MUST** keep these caveats in mind when deploying this extension:
|
||||
|
||||
- Your site **MUST** be served over HTTPS. All of the component assets for this extension are precompressed with [Brotli](https://developer.mozilla.org/en-US/docs/Glossary/Brotli_compression). Browsers do not accept plaintext server responses that are compressed with Brotli.
|
||||
- Your reverse proxy or CDN **MUST** send all the headers that clients sent **unaltered**, including but not limited to the `User-Agent` string, client hints headers, and any `Accept-*` headers.
|
||||
- If BotStopper sees any discrepancies between what it expects to see from browsers and what browsers actually return, the challenge will fail.
|
||||
- The detector adds about 35Ki to challenge pages served to browsers.
|
||||
- The detector uses the `eval` JavaScript function. If your `Content-Security-Policy` header on the challenge page blocks `unsafe-eval`, none of the detection probes will work.
|
||||
|
||||
## CEL variables
|
||||
|
||||
This extension exposes an expression variable:
|
||||
|
||||
| Name | Type | Description |
|
||||
| :--------------------------- | :---- | :------------------------------------------------------------------ |
|
||||
| `headlessNetworkHardReports` | int32 | The stored hard reports for the network associated with the client. |
|
||||
|
||||
### `headlessNetworkHardReports`
|
||||
|
||||
As headless browsers fail checks, the IPv4/IPv6 minimum routable prefix associated with that failure is stored in BotStopper's store. This can be used to give clients from those networks more difficult challenges as a deterrence method. For example:
|
||||
|
||||
```yaml
|
||||
bots:
|
||||
- name: headless-network
|
||||
action: CHALLENGE
|
||||
expression: headlessNetworkHardReports >= 3
|
||||
challenge:
|
||||
algorithm: soteria # A difficult challenge for most hardware
|
||||
difficulty: 20
|
||||
```
|
||||
|
||||
Headless network hard reports will expire after 24 hours by default. This may be configured with the headless extension flags.
|
||||
|
||||
## Flags
|
||||
|
||||
| Flag / environment variable | Default | Value |
|
||||
| :------------------------------------------------ | :------ | :---------------------------------------------------------------------- |
|
||||
| `--headless-network-ttl` / `HEADLESS_NETWORK_TTL` | `24h` | The time that BotStopper keeps the count of hard reports for a network. |
|
||||
|
||||
This will be replaced with a configuration file value in the near future.
|
||||
|
||||
## Metrics
|
||||
|
||||
This extension exposes metrics that may be useful for internal dashboards:
|
||||
|
||||
- `botstopper_headless_reports_total{result}`: The number of reports for each result, broken down by reason.
|
||||
- `botstopper_headless_signal_hits_total{signal}`: The number of hits for each signal.
|
||||
- `botstopper_headless_refusals_total{reason}`: The number of challenges that failed because of the detector by reason (such as `missing`, `assets`, `hard`, and `error`).
|
||||
|
||||
## Methodology flaws
|
||||
|
||||
Headless browsers are constantly evolving to evade these kinds of checks. This will need to become a dynamically updating component of BotStopper. Additionally, many of the checks involved with this are sent by the client as there is no way for the server to determine these values without getting them from the client. Clients may lie.
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: Challenge Extensions
|
||||
position: 0
|
||||
---
|
||||
|
||||
Challenge Extensions are extra conditions you can layer on top of existing challenges. This allows Anubis to assert more behaviour from clients without having to modify existing challenge implementations.
|
||||
|
||||
To enable extensions on an existing challenge, add it to the `extensions` field under your challenge definition:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: mild-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight > 0
|
||||
- weight < 10
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: sha256
|
||||
difficulty: 8
|
||||
report_as: 8
|
||||
extensions:
|
||||
- css-load
|
||||
```
|
||||
|
||||
This will augment the [sha256 challenge](../wasm.mdx#sha256) with the [`css-load`](./css-load.mdx) extension.
|
||||
|
||||
Extensions are designed to be very cheap and easy to add to existing challenges and can be useful for evading bypass/detection logic for Anubis solving scripts.
|
||||
@@ -0,0 +1,73 @@
|
||||
# Soteria (WebAssembly, SIMD)
|
||||
|
||||
import EnterpriseOnly from "@site/src/components/EnterpriseOnly";
|
||||
|
||||
<EnterpriseOnly link="../../botstopper/" />
|
||||
|
||||
[Soteria](https://github.com/Xe/soteria) is an experimental dynamic challenge implementation abusing SIMD instructions in WebAssembly to run four challenge programs at once. All challenge programs are synthesized on the fly akin to RandomX, but re-synthesizes the challenge program every so often to be more forgiving to less powerful hardware. Clients that do not have WebAssembly support or support for WebAssembly SIMD operations cannot run this challenge method. Please take this into consideration when planning your deployment.
|
||||
|
||||
As an additional bit of grace granted to less powerful hardware, Soteria cuts the challenge difficulty and complexity when the client is explicitly a mobile phone.
|
||||
|
||||
## Configuration
|
||||
|
||||
Soteria scales exponentially based on the difficulty configured in the policy file. Here are examples for light, medium, and hard challenges:
|
||||
|
||||
### Light challenge
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: soteria
|
||||
difficulty: 14
|
||||
extensions:
|
||||
- headless
|
||||
```
|
||||
|
||||
### Moderate challenge
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: soteria
|
||||
difficulty: 17
|
||||
extensions:
|
||||
- headless
|
||||
```
|
||||
|
||||
### Hard challenge
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: soteria
|
||||
difficulty: 20
|
||||
extensions:
|
||||
- headless
|
||||
```
|
||||
|
||||
## Technical notes
|
||||
|
||||
An upcoming blogpost will go into detail about how Soteria works in detail, but here are the highlights:
|
||||
|
||||
- Soteria VM operations are run against four copies of synthesized challenge programs at once using SIMD operations to eke all performance out of mobile phone hardware possible.
|
||||
- The Soteria VM is based on a [Very Long Instruction Word](https://en.wikipedia.org/wiki/Very_long_instruction_word) architecture, enabling optimizations specific to that instruction set type.
|
||||
- As clients calculate four programs at once, they are required to submit four solutions which are chained in order to prevent challenge program reuse.
|
||||
- Requests classified as being from mobile phones have the difficulty and solution complexity cut drastically in order to be equitable to them. Soteria's architecture should be amenable to phones already, but this additional bit of grace will help make sure of it.
|
||||
@@ -0,0 +1,94 @@
|
||||
# Proof of Work (WebAssembly)
|
||||
|
||||
Anubis supports using [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly) to speed up proof of work validation. Proof of work functions as a randomized delay to prevent clients from overwhelming your server with traffic. All WebAssembly proof of work functions are written in Rust.
|
||||
|
||||
:::note
|
||||
|
||||
When clients are configured to disable WebAssembly, Anubis falls back to a pure JavaScript implementation of the WebAssembly-based check logic. As clients that disable WebAssembly usually disable the JavaScript JIT (the thing that makes JavaScript fast), this makes checks slower.
|
||||
|
||||
Additionally due to complicated facts and circumstances involving it being complicated to pass the messages from the wasm2js world back to JavaScript, the progress bar will not update while a wasm2js check is running. This is a known issue and will be fixed in a later release.
|
||||
|
||||
:::
|
||||
|
||||
## Implementations
|
||||
|
||||
Anubis offers the following WebAssembly proof of work functions:
|
||||
|
||||
- [argon2id](#argon2id) (via the [`argon2id`](https://docs.rs/argon2/latest/argon2/) crate)
|
||||
- [hashx](#hashx) (via the [`hashx`](https://docs.rs/hashx/latest/hashx/index.html) crate)
|
||||
- [sha256](#sha256) (via the [`sha2`](https://docs.rs/sha2/latest/sha2/) crate)
|
||||
|
||||
:::note
|
||||
|
||||
The difficulty values for the WebAssembly based checks are going to be much greater than the equivalent difficulty values for the [JavaScript based checks](./proof-of-work.mdx). Generally these count the number of leading _bits_ that much match instead of the number of leading _nibbles_ that must match. Here's a rough translation table:
|
||||
|
||||
| `fast` difficulty | `argon2id` difficulty | `sha256` difficulty | `hashx` difficulty |
|
||||
| :---------------- | :-------------------- | :------------------ | :----------------- |
|
||||
| `4` | `4` | `16` | `15` |
|
||||
| `2` | `2` | `8` | `7` |
|
||||
| `6` | `6` | `24` | `20` |
|
||||
|
||||
:::
|
||||
|
||||
## `argon2id`
|
||||
|
||||
Uses the memory-hard [Argon2](https://en.wikipedia.org/wiki/Argon2) key derivation function as a hashing algorithm. This uses a large fixed-size memory region in order to make brute-force attacks computationally expensive.
|
||||
|
||||
Usage:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: argon2id
|
||||
difficulty: 6
|
||||
```
|
||||
|
||||
## `hashx`
|
||||
|
||||
Uses the ASIC-resistant [hashx](https://github.com/tevador/hashx) as the proof of work function. This is resistant to GPU and ASIC attacks. In practice this means that users need to be using a standards-compliant browser to pass the challenge.
|
||||
|
||||
Usage:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: hashx
|
||||
difficulty: 16
|
||||
```
|
||||
|
||||
## `sha256`
|
||||
|
||||
Uses [SHA-256](https://en.wikipedia.org/wiki/SHA-2) as the proof of work function.
|
||||
|
||||
:::note
|
||||
|
||||
This is included mostly as a fallback for usecases that specifically require this hashing function. There are known tools that solve this particular challenge. Prefer [`argon2id`](#argon2id) or [`hashx`](#hashx) unless you know what you are doing and have a very specific usecase in mind.
|
||||
|
||||
:::
|
||||
|
||||
Usage:
|
||||
|
||||
```yaml
|
||||
thresholds:
|
||||
- name: moderate-suspicion
|
||||
expression:
|
||||
all:
|
||||
- weight >= 10
|
||||
- weight < 20
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
algorithm: sha256
|
||||
difficulty: 16
|
||||
```
|
||||
@@ -0,0 +1,42 @@
|
||||
# Content-Security-Policy advice
|
||||
|
||||
Many web server configuration guides recommend setting a strict [Content-Security-Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) on your web applications in order to avoid [Cross-Site-Scripting (XSS)](https://en.wikipedia.org/wiki/Cross-site_scripting) from being able to affect your services. The way Anubis works can conflict with some common CSP settings that many guides and web applications enforce out of the gate.
|
||||
|
||||
:::warning
|
||||
|
||||
Browsers cache the contents of `Content-Security-Policy` headers for a very long time. Please be sure to test any of these changes on staging domains before deploying changes to production.
|
||||
|
||||
:::
|
||||
|
||||
The most strict yet correct CSP for Anubis looks like this (reformatted for readability):
|
||||
|
||||
```text
|
||||
default-src 'none';
|
||||
script-src 'self' 'unsafe-inline';
|
||||
style-src 'self' 'unsafe-inline';
|
||||
img-src 'self';
|
||||
font-src 'self' data:;
|
||||
connect-src 'self';
|
||||
worker-src 'self' blob:;
|
||||
base-uri 'none';
|
||||
form-action 'self';
|
||||
```
|
||||
|
||||
This is an overly strict CSP and you **will** need to edit this as it **will** interfere with the normal operation of many web applications, especially ones that include resources from remote destinations to function (EG: the image CDN for a social media network).
|
||||
|
||||
Breaking it down:
|
||||
|
||||
| Setting | Justification |
|
||||
| :--------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `default-src 'none'` | Blocks every kind of subresource load unless specified below. This denies by default. This setting alone is likely to break web applications. |
|
||||
| `script-src 'self'` | Anubis checks that load JavaScript from the server via the `<script>` tag needs to be allowed to load JavaScript from the server. |
|
||||
| `script-src 'unsafe-inline'` | Anubis has fallback behaviour to make sure that JavaScript loaded from `<script>` tags actually gets loaded. Browsers don't expose errors for servers returning non-JavaScript responses when trying to load JavaScript programs, so Anubis embeds a small inline JavaScript program that makes sure the JavaScript actually gets loaded from the server and retries with exponential backoff in case it fails. |
|
||||
| `style-src 'unsafe-inline'` | Anubis has some critical parts of its CSS embedded directly into the challenge page. This setting also triggers the use of the HTML `style="..."` attribute and JavaScript `DOMElement.style` properties. This is required for Anubis to function as it triggers success/failure message visibility and styling. |
|
||||
| `style-src 'self'` | Anubis loads CSS from the server. Not loading CSS from the server may make Anubis think that a client is a bot. |
|
||||
| `img-src 'self'` | Anubis loads its image resources from the server. Not loading these images from the server may make Anubis think the client is a bot. |
|
||||
| `font-src data:` | Anubis embeds fonts into its stylesheet so that errant scrapers think the Anubis challenge page is a legitimate webpage. |
|
||||
| `connect-src 'self'` | Anubis pre-fetches worker source and translation locales from the server. |
|
||||
| `worker-src blob:` | Anubis pre-fetches worker source to avoid fanning out a request for every hardware thread to read that worker source. If this is not set, Anubis falls back to the expensive fanning out requests for every hardware thread. |
|
||||
| `worker-src 'self'` | In fallback scenarios, Anubis loads worker source by fanning out requests per hardware thread to load the same JavaScript source. Disabling this makes the JavaScript code not load, which causes Anubis' frontend code to throw an error. |
|
||||
| `base-uri 'none'` | Restricts the URLs allowed in [HTML `<base>` elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base). Anubis does not use this HTML element. |
|
||||
| `form-action 'self'` | Controls where `<form>` actions may go. Anubis does not use HTML forms, but your web application might. |
|
||||
@@ -140,7 +140,7 @@ So given an HTTP request like this:
|
||||
GET /index.php?title=Index&action=history HTTP/1.1
|
||||
User-Agent: Mozilla/5.0 Gecko/20100101 Firefox/137.0
|
||||
Host: wiki.int.techaro.lol
|
||||
X-Real-Ip: 8.8.8.8
|
||||
X-Real-IP: 8.8.8.8
|
||||
```
|
||||
|
||||
Anubis would return a challenge because all of those conditions are true.
|
||||
|
||||
@@ -17,6 +17,42 @@ bots:
|
||||
- import: (data)/meta/default-config.yaml
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
The `(data)` pseudo-folder corresponds to a copy of the [`data`](https://github.com/TecharoHQ/anubis/tree/main/data) as of the time Anubis was compiled. If you want to dump a copy of the `(data)` folder out of your Anubis binary, run this command:
|
||||
|
||||
```sh
|
||||
anubis --extract-resources ./var/anubis-resources
|
||||
```
|
||||
|
||||
This will extract the contents of the `(data)` folder compiled into your copy of Anubis as well as the contents of static filesystem used for web assets. For example:
|
||||
|
||||
```
|
||||
$ tree -L 2 ./var/anubis-resources/
|
||||
./var/anubis-resources/
|
||||
├── data
|
||||
│ ├── apps
|
||||
│ ├── botPolicies.yaml
|
||||
│ ├── bots
|
||||
│ ├── clients
|
||||
│ ├── common
|
||||
│ ├── crawlers
|
||||
│ ├── meta
|
||||
│ └── services
|
||||
└── static
|
||||
├── img
|
||||
├── js
|
||||
├── locales
|
||||
├── robots.txt
|
||||
└── testdata
|
||||
```
|
||||
|
||||
The contents of the `static` folder are not subject to any backwards compatibility promises and may change at any time without warning.
|
||||
|
||||
Replace assets in the `static` folder using reverse proxy configuration at your peril, as doing so may break challenge verification logic.
|
||||
|
||||
:::
|
||||
|
||||
Of note, a bot rule can either have inline bot configuration or import a bot config snippet. You cannot do both in a single bot rule.
|
||||
|
||||
```yaml
|
||||
@@ -37,6 +73,71 @@ config.BotOrImport: rule definition is invalid, you must set either bot rules or
|
||||
|
||||
Paths can either be prefixed with `(data)` to import from the [the data folder in the Anubis source tree](https://github.com/TecharoHQ/anubis/tree/main/data) or anywhere on the filesystem. If you don't have access to the Anubis source tree, check /usr/share/docs/anubis/data or in the tarball you extracted Anubis from.
|
||||
|
||||
## Importing many files at once
|
||||
|
||||
If you want to import policies from many files at once, the import path can contain [wildcards](<https://en.wikipedia.org/wiki/Glob_(programming)>). Wildcard matches let you add rules by dropping a file into a folder instead of editing your main configuration file every time.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
bots:
|
||||
# Every rule file in the (data)/crawlers folder.
|
||||
- import: (data)/crawlers/*.yaml
|
||||
# Every rule file you put in /etc/anubis/known-good.
|
||||
- import: /etc/anubis/known-good/*.yaml
|
||||
```
|
||||
|
||||
### Supported wildcards
|
||||
|
||||
Anubis uses the Go standard library function [`filepath.Match`](https://pkg.go.dev/path/filepath#Match) for matching. It supports four wildcards:
|
||||
|
||||
| Wildcard | Matches | Example |
|
||||
| :------- | :---------------------------------- | :------------------------------------------------------------------------------------- |
|
||||
| `*` | Any run of characters in one folder | `crawlers/*.yaml` matches `crawlers/kagibot.yaml`, but not `crawlers/eu/kagibot.yaml`. |
|
||||
| `?` | Exactly one character | `??-allow.yaml` matches `00-allow.yaml` and `xe-allow.yaml`, but not `1-allow.yaml`. |
|
||||
| `[0-9]` | One character from a set or range | `[0-9][0-9]-*.yaml` matches `00-monitoring.yaml`, but not `xe-monitoring.yaml`. |
|
||||
| `[^0-9]` | One character not in a set or range | `[^0-9]*.yaml` matches `xe.yaml`, but not `00-xe.yaml`. |
|
||||
|
||||
Use [this Go playground link](https://go.dev/play/p/Q2qayrjZw4A) to test pattern matches.
|
||||
|
||||
### Matched files load in natural sort order
|
||||
|
||||
Anubis matches requests top to bottom, similar to Apache's `DENY, ALLOW` ACL. Anubis uses the first rule that matches the request exactly. A rule that loads early can shadow a rule that loads later.
|
||||
|
||||
When Anubis loads files imported with a wildcard match, it sorts the files in [natural sort order](https://en.wikipedia.org/wiki/Natural_sort_order). To control the order rules are loaded, put a number at the beginning of each filename:
|
||||
|
||||
```text
|
||||
/etc/anubis/known-good/
|
||||
├── 00-allow-monitoring.yaml
|
||||
├── 01-allow-git-clients.yaml
|
||||
├── 02-allow-techaro-ci-bot.yaml
|
||||
└── 10-weigh-everything-else.yaml
|
||||
```
|
||||
|
||||
Natural sort compares numbers numerically and words alphabetically. This makes `02-deny.yaml` load before `10-deny.yaml`.
|
||||
|
||||
:::tip
|
||||
|
||||
Make sure your indentation is consistent across all files matched in a single import statement. Format your YAML files with [yq](https://github.com/mikefarah/yq) or configure your editor to format YAML files when you save.
|
||||
|
||||
:::
|
||||
|
||||
### Errors from wildcard imports
|
||||
|
||||
A wildcard import that fails stops Anubis at startup. These are the common causes:
|
||||
|
||||
| Error | Cause |
|
||||
| :------------------------------------------------- | :---------------------------------------------------------------------------------------- |
|
||||
| `glob pattern matched no files` | The pattern matched nothing. Check the folder, the file extension, and the syntax. |
|
||||
| `can't parse (data)/*: read apps/: is a directory` | The pattern matched a folder. End the pattern with `.yaml` so that it only matches files. |
|
||||
| `can't parse ...: yaml: line N: ...` | One of the matched files is not a top level list, or its indentation is wrong. |
|
||||
|
||||
Patterns that match no files result in errors. The message names the pattern that failed:
|
||||
|
||||
```text
|
||||
glob pattern matched no files: "(data)/bots/*.yml", note that recursive wildcards ("**") and alternation ("{yaml,yml}") are not supported
|
||||
```
|
||||
|
||||
## Importing the default configuration
|
||||
|
||||
If you want to base your configuration off of the default configuration, import `(data)/meta/default-config.yaml`:
|
||||
@@ -82,7 +183,9 @@ This lets you import an entire ruleset at once:
|
||||
- import: (data)/bots/us-ai-scraper.yaml
|
||||
```
|
||||
|
||||
Use this with care, you can easily get yourself into a state where Anubis recursively imports things for eternity if you are not careful. The best way to use this is to make a "root import" named `_everything.yaml` or `_allow-good.yaml` so they sort to the top. Name your meta-imports after the main verb they are enforcing so that you can glance at the configuration file and understand what it's doing.
|
||||
Use this with care, you can easily get yourself into a state where Anubis recursively imports things for eternity if you are not careful.
|
||||
|
||||
If you need to import many files, please consider using [glob matching](#importing-many-files-at-once) instead.
|
||||
|
||||
## Writing snippets
|
||||
|
||||
@@ -96,38 +199,3 @@ Here is an example snippet that allows [IPv6 Unique Local Addresses](https://en.
|
||||
remote_addresses:
|
||||
- fc00::/7
|
||||
```
|
||||
|
||||
## Extracting Anubis' embedded filesystem
|
||||
|
||||
You can always extract the list of rules embedded into the Anubis binary with this command:
|
||||
|
||||
```text
|
||||
anubis --extract-resources=static
|
||||
```
|
||||
|
||||
This will dump the contents of Anubis' embedded data to a new folder named `static`:
|
||||
|
||||
```text
|
||||
static
|
||||
├── apps
|
||||
│ └── gitea-rss-feeds.yaml
|
||||
├── botPolicies.json
|
||||
├── botPolicies.yaml
|
||||
├── bots
|
||||
│ ├── ai-catchall.yaml
|
||||
│ ├── cloudflare-workers.yaml
|
||||
│ ├── headless-browsers.yaml
|
||||
│ └── us-ai-scraper.yaml
|
||||
├── common
|
||||
│ ├── allow-private-addresses.yaml
|
||||
│ └── keep-internet-working.yaml
|
||||
└── crawlers
|
||||
├── bingbot.yaml
|
||||
├── duckduckbot.yaml
|
||||
├── googlebot.yaml
|
||||
├── internet-archive.yaml
|
||||
├── kagibot.yaml
|
||||
├── marginalia.yaml
|
||||
├── mojeekbot.yaml
|
||||
└── qwantbot.yaml
|
||||
```
|
||||
@@ -31,40 +31,3 @@ impressum:
|
||||
|
||||
<!-- ... -->
|
||||
```
|
||||
|
||||
If you are subscribed to and using [advanced classification features](../thoth.mdx), be sure to disclose the following:
|
||||
|
||||
```html
|
||||
<h2>Techaro Anubis</h2>
|
||||
|
||||
<p>
|
||||
This website uses a service called
|
||||
<a href="https://anubis.techaro.lol">Anubis</a> by
|
||||
<a href="https://techaro.lol">Techaro</a> to filter malicious traffic. Anubis
|
||||
requires the use of browser cookies to ensure that web clients are running
|
||||
conformant software. Anubis also may report the following data to Techaro to
|
||||
improve service quality:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
IP address (for purposes of matching against geo-location and BGP autonomous
|
||||
systems numbers), which is stored in-memory and not persisted to disk.
|
||||
</li>
|
||||
<li>
|
||||
Unique browser fingerprints (such as HTTP request fingerprints and
|
||||
encryption system fingerprints), which may be stored on Techaro's side for a
|
||||
period of up to one month.
|
||||
</li>
|
||||
<li>
|
||||
HTTP request metadata that may include things such as the User-Agent header
|
||||
and other identifiers.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
This data is processed and stored for the legitimate interest of combatting
|
||||
abusive web clients. This data is encrypted at rest as much as possible and is
|
||||
only decrypted in memory for the purposes of fulfilling requests.
|
||||
</p>
|
||||
```
|
||||
@@ -70,6 +70,8 @@ The cache expiration time is controlled by `OG_EXPIRY_TIME`.
|
||||
|
||||
When `OG_CACHE_CONSIDER_HOST` is enabled, Anubis will include the host in the cache key for Open Graph tags. This ensures that tags are cached separately for different hosts.
|
||||
|
||||
When fetching the target, Anubis forwards the visitor's original host as `X-Forwarded-Host`, mirroring what the normal proxy path sends. This lets backends that resolve their site from that header (e.g. WordPress multisite behind per-instance origin vhosts) serve the correct tags even when `--target-host` is set.
|
||||
|
||||
## Example
|
||||
|
||||
Here is an example of how to configure Open Graph tags in your Anubis setup:
|
||||
|
||||
@@ -70,9 +70,10 @@ Assuming you are protecting `anubistest.techaro.lol`, you need the following ser
|
||||
|
||||
# These headers need to be set or else Anubis will
|
||||
# throw an "admin misconfiguration" error.
|
||||
RequestHeader set "X-Real-Ip" expr=%{REMOTE_ADDR}
|
||||
RequestHeader set "X-Real-IP" expr=%{REMOTE_ADDR}
|
||||
RequestHeader set X-Forwarded-Proto "https"
|
||||
RequestHeader set "X-Http-Version" "%{SERVER_PROTOCOL}s"
|
||||
RequestHeader set "X-TLS-SNI-Name" "%{SSL_TLS_SNI}s"
|
||||
|
||||
ProxyPreserveHost On
|
||||
|
||||
|
||||
@@ -62,9 +62,10 @@ yourdomain.example.com {
|
||||
tls your@email.address
|
||||
|
||||
reverse_proxy http://anubis:3000 {
|
||||
header_up X-Real-Ip {remote_host}
|
||||
header_up X-Http-Version {http.request.proto}
|
||||
}
|
||||
header_up X-Real-IP {remote_host}
|
||||
header_up X-Http-Version {http.request.proto}
|
||||
header_up X-TLS-SNI-Name {tls_server_name}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
import CodeBlock from "@theme/CodeBlock";
|
||||
|
||||
To use Anubis with HAProxy, you have two variants:
|
||||
- simple - stick Anubis between HAProxy and your application backend (simple)
|
||||
- perfect if you only have a single application in general
|
||||
- advanced - force Anubis challenge by default and route to the application backend by HAProxy if the challenge is correct
|
||||
- useful for complex setups
|
||||
- routing can be done in HAProxy
|
||||
- define ACLs in HAProxy for domains, paths etc which are required/excluded regarding Anubis
|
||||
- HAProxy 3.0 recommended
|
||||
|
||||
- simple - stick Anubis between HAProxy and your application backend (simple)
|
||||
- perfect if you only have a single application in general
|
||||
- advanced - force Anubis challenge by default and route to the application backend by HAProxy if the challenge is correct
|
||||
- useful for complex setups
|
||||
- routing can be done in HAProxy
|
||||
- define ACLs in HAProxy for domains, paths etc which are required/excluded regarding Anubis
|
||||
- HAProxy 3.0 or above recommended
|
||||
|
||||
## Simple Variant
|
||||
|
||||
@@ -48,6 +49,8 @@ This simply enables SSL offloading, sets some useful and required headers and ro
|
||||
|
||||
Due to the fact that HAProxy can decode JWT, we are able to verify the Anubis token directly in HAProxy and route the traffic to the specific backends ourselves.
|
||||
|
||||
Mind that rule logic to allow Git HTTP and other legit bot traffic to bypass is delegated from Anubis to HAProxy then. If required, you should implement any whitelisting in HAProxy using `acl_anubis_ignore` yourself.
|
||||
|
||||
In this example are three applications behind one HAProxy frontend. Only App1 and App2 are secured via Anubis; App3 is open for everyone. The path `/excluded/path` can also be accessed by anyone.
|
||||
|
||||
```mermaid
|
||||
@@ -83,6 +86,7 @@ import advancedAnubis from "!!raw-loader!./haproxy/advanced-config.env";
|
||||
<CodeBlock language="bash">{advancedAnubis}</CodeBlock>
|
||||
|
||||
It's important to use `HS512_SECRET` which HAProxy understands. Please replace `<SECRET-HERE>` with your own secret string (alphanumerical string with 128 characters recommended).
|
||||
Setting `DYNAMIC_COOKIE_SUFFIX` to `false` is required from Anubis v1.28 as HAProxy can only use a specific cookie name.
|
||||
|
||||
You can set Anubis to force a challenge for every request using the following policy file:
|
||||
|
||||
|
||||
@@ -12,4 +12,3 @@ status_codes:
|
||||
thresholds: []
|
||||
|
||||
dnsbl: false
|
||||
|
||||
@@ -7,5 +7,6 @@ METRICS_BIND=:9090
|
||||
# target is irrelevant here, backend routing happens in HAProxy
|
||||
TARGET=http://0.0.0.0
|
||||
HS512_SECRET=<SECRET-HERE>
|
||||
COOKIE_DYNAMIC_DOMAIN=True
|
||||
COOKIE_DYNAMIC_DOMAIN=true
|
||||
POLICY_FNAME=/etc/anubis/challenge-any.yml
|
||||
DYNAMIC_COOKIE_SUFFIX=false
|
||||
@@ -8,6 +8,8 @@ frontend FE-multiple-applications
|
||||
|
||||
# set X-Real-IP header required for Anubis
|
||||
http-request set-header X-Real-IP "%[src]"
|
||||
# set TLS SNI name for Anubis
|
||||
http-request set-header X-TLS-SNI-Name %[ssl_fc_sni]
|
||||
|
||||
# redirect HTTP to HTTPS
|
||||
http-request redirect scheme https code 301 unless { ssl_fc }
|
||||
@@ -37,6 +39,7 @@ frontend FE-multiple-applications
|
||||
use_backend BE-anubis if acl_anubis_required !acl_anubis_ignore !{ var(txn.srcip),digest(sha256),hex,lower,strcmp(txn.anubis_jwt_res) eq 0 }
|
||||
use_backend BE-anubis if acl_anubis_required !acl_anubis_ignore !{ cook(techaro.lol-anubis-auth),jwt_verify(txn.anubis_jwt_alg,"<SECRET-HERE>") -m int 1 }
|
||||
|
||||
# everything below this line is for good traffic only
|
||||
# custom routing in HAProxy
|
||||
use_backend BE-app1 if { hdr(host) -i "app1.example.com" }
|
||||
use_backend BE-app2 if { hdr(host) -i "app2.example.com" }
|
||||
@@ -54,6 +57,6 @@ backend BE-app3
|
||||
mode http
|
||||
server app3-server 127.0.0.1:5000
|
||||
|
||||
BE-anubis
|
||||
backend BE-anubis
|
||||
mode http
|
||||
server anubis /run/anubis/default.sock
|
||||
@@ -8,6 +8,8 @@ frontend FE-application
|
||||
|
||||
# set X-Real-IP header required for Anubis
|
||||
http-request set-header X-Real-IP "%[src]"
|
||||
# set TLS SNI name for Anubis
|
||||
http-request set-header X-TLS-SNI-Name %[ssl_fc_sni]
|
||||
|
||||
# redirect HTTP to HTTPS
|
||||
http-request redirect scheme https code 301 unless { ssl_fc }
|
||||
@@ -17,6 +19,6 @@ frontend FE-application
|
||||
# route to Anubis backend by default
|
||||
default_backend BE-anubis-application
|
||||
|
||||
BE-anubis-application
|
||||
backend BE-anubis-application
|
||||
mode http
|
||||
server anubis /run/anubis/default.sock
|
||||
@@ -32,7 +32,7 @@ flowchart LR
|
||||
An --> B
|
||||
```
|
||||
|
||||
Anubis is lightweight enough that you should be able to have many instances of it running without many problems. If this is a concern for you, please check out [ingress-anubis](https://github.com/jaredallard/ingress-anubis?ref=anubis.techaro.lol).
|
||||
Anubis is lightweight enough that you should be able to have many instances of it running without many problems. If this is a concern for you, please check out [ingress-anubis](https://github.com/jaredallard/ingress-anubis?ref=anubis.techaro.lol) or [anubis-kubernetes-operator](https://github.com/eznix86/anubis-kubernetes-operator/?ref=anubis.techaro.lol)
|
||||
|
||||
This example makes the following assumptions:
|
||||
|
||||
@@ -60,8 +60,8 @@ containers:
|
||||
env:
|
||||
- name: "BIND"
|
||||
value: ":8080"
|
||||
- name: "DIFFICULTY"
|
||||
value: "4"
|
||||
- name: "POLICY_FNAME"
|
||||
value: "/data/cfg/botPolicy.yaml"
|
||||
- name: ED25519_PRIVATE_KEY_HEX
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
@@ -77,6 +77,10 @@ containers:
|
||||
value: "true"
|
||||
- name: "OG_EXPIRY_TIME"
|
||||
value: "24h"
|
||||
volumeMounts:
|
||||
- name: bot-policy
|
||||
mountPath: /data/cfg
|
||||
readOnly: true
|
||||
resources:
|
||||
limits:
|
||||
cpu: 750m
|
||||
@@ -96,6 +100,21 @@ containers:
|
||||
type: RuntimeDefault
|
||||
```
|
||||
|
||||
Challenge difficulty is no longer set with a `DIFFICULTY` environment variable. It lives in the [bot policy file](../policies.mdx) (for example a per-challenge `difficulty` value), which the container above reads from `/data/cfg/botPolicy.yaml`. Create it as a ConfigMap and mount it at the pod level:
|
||||
|
||||
```
|
||||
kubectl create configmap bot-policy \
|
||||
--namespace default \
|
||||
--from-file=botPolicy.yaml=./botPolicy.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- name: bot-policy
|
||||
configMap:
|
||||
name: bot-policy
|
||||
```
|
||||
|
||||
Then add a Service entry for Anubis:
|
||||
|
||||
```yaml
|
||||
@@ -115,18 +134,69 @@ spec:
|
||||
Then point your Ingress to the Anubis port:
|
||||
|
||||
```yaml
|
||||
rules:
|
||||
rules:
|
||||
- host: git.xeserv.us
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: "/"
|
||||
backend:
|
||||
service:
|
||||
name: git
|
||||
port:
|
||||
# diff-remove
|
||||
name: http
|
||||
# diff-add
|
||||
name: anubis
|
||||
- pathType: Prefix
|
||||
path: "/"
|
||||
backend:
|
||||
service:
|
||||
name: git
|
||||
port:
|
||||
# diff-remove
|
||||
name: http
|
||||
# diff-add
|
||||
name: anubis
|
||||
```
|
||||
|
||||
## Envoy Gateway
|
||||
|
||||
If you are using envoy-gateway, the `X-Real-IP` header is not set by default, but Anubis does require it. You can resolve this by adding the header, either on the specific `HTTPRoute` where Anubis is listening, or on the `ClientTrafficPolicy` to apply it to any number of Gateways:
|
||||
|
||||
HTTPRoute:
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: app-route
|
||||
spec:
|
||||
hostnames: ["app.domain.tld"]
|
||||
parentRefs:
|
||||
- name: envoy-external
|
||||
namespace: network
|
||||
sectionName: https
|
||||
rules:
|
||||
- backendRefs:
|
||||
- identifier: *app
|
||||
port: anubis
|
||||
filters:
|
||||
- type: RequestHeaderModifier
|
||||
requestHeaderModifier:
|
||||
set:
|
||||
- name: X-Real-IP
|
||||
value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
|
||||
```
|
||||
|
||||
Applying to any number of Gateways:
|
||||
|
||||
```yaml
|
||||
apiVersion: gateway.envoyproxy.io/v1alpha1
|
||||
kind: ClientTrafficPolicy
|
||||
metadata:
|
||||
name: envoy
|
||||
spec:
|
||||
headers:
|
||||
earlyRequestHeaders:
|
||||
set:
|
||||
- name: X-Real-IP
|
||||
value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
|
||||
clientIPDetection:
|
||||
xForwardedFor:
|
||||
trustedCIDRs:
|
||||
- 10.96.0.0/16 # Cluster pod CIDR
|
||||
targetSelectors: # These will apply to all Gateways
|
||||
- group: gateway.networking.k8s.io
|
||||
kind: Gateway
|
||||
```
|
||||
@@ -46,7 +46,7 @@ import anubisTest from "!!raw-loader!./nginx/server-anubistest-techaro-lol.conf"
|
||||
|
||||
You can copy the `location /` block into a separate file named something like `conf-anubis.inc` and then include it inline to other `server` blocks:
|
||||
|
||||
import anubisInclude from "!!raw-loader!./nginx/conf-anubis.inc";
|
||||
import anubisInclude from "!!raw-loader!./nginx/conf-anubis.conf";
|
||||
|
||||
<CodeBlock language="nginx">{anubisInclude}</CodeBlock>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# /etc/nginx/conf-anubis.inc
|
||||
|
||||
# Forward to anubis
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-TLS-SNI-Name $ssl_server_name;
|
||||
proxy_pass http://anubis;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# /etc/nginx/conf-anubis.inc # Forward to anubis location / { proxy_set_header
|
||||
Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://anubis; }
|
||||
@@ -24,6 +24,7 @@ server {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Http-Version $server_protocol;
|
||||
proxy_set_header X-TLS-SNI-Name $ssl_server_name;
|
||||
proxy_pass http://anubis;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ services:
|
||||
- traefik.http.routers.web.tls=false
|
||||
|
||||
anubis:
|
||||
image: ghcr.io/techarohq/anubis:main
|
||||
image: ghcr.io/techarohq/anubis:latest
|
||||
environment:
|
||||
# Telling Anubis, where to listen for Traefik
|
||||
- BIND=:8080
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
id: windows
|
||||
title: Windows
|
||||
---
|
||||
|
||||
import RandomKey from "@site/src/components/RandomKey";
|
||||
|
||||
Anubis supports running on Windows as a native system service as of v1.27.0. In order to get started, download the MSI from [the releases page](https://github.com/TecharoHQ/anubis/releases) and run it. By default it installs to `C:\Program Files\Techaro\Anubis` and registers a service named `Anubis`.
|
||||
|
||||
:::note
|
||||
|
||||
Anubis is provided as both an amd64 (x64) and arm64 (Aarch64) executable. The amd64 MSI has been tested the most and is known to work. If you have trouble with the arm64 MSI, please [file a bug](https://github.com/TecharoHQ/anubis/issues).
|
||||
|
||||
:::
|
||||
|
||||
## First-time setup
|
||||
|
||||
By default installing Anubis does not start the `Anubis` service. This is intentional so that you may [customize Anubis' settings](../installation.mdx) and [configure your policy file](../policies.mdx). By default, the installer creates the following files in `%ProgramData%` (typically: `C:\ProgramData`):
|
||||
|
||||
| File | Purpose |
|
||||
| ------------: | :---------------------------------------------------------- |
|
||||
| `anubis.env` | Environment variable [Anubis settings](../installation.mdx) |
|
||||
| `anubis.yaml` | Anubis [policy settings](../policies.mdx) |
|
||||
|
||||
Of note, you **MUST** set an ed25519 private key in `anubis.env` with `ED25519_PRIVATE_KEY_HEX`:
|
||||
|
||||
```sh
|
||||
# Signing key, exactly 64 hexadecimal characters. If this is not set, Anubis
|
||||
# generates a random key at every start, which invalidates every outstanding
|
||||
# challenge whenever the service restarts. Set it before going to production.
|
||||
# ED25519_PRIVATE_KEY_HEX=
|
||||
```
|
||||
|
||||
To generate an ed25519 private key, you can use this PowerShell invocation:
|
||||
|
||||
```powershell
|
||||
[Convert]::ToHexString([System.Security.Cryptography.RandomNumberGenerator]::GetBytes(32)).ToLower()
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
If you are using a legacy environment where only PowerShell 5.1 is available, use this invocation instead:
|
||||
|
||||
```powershell
|
||||
$bytes = New-Object byte[] 32
|
||||
[System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($bytes)
|
||||
[System.BitConverter]::ToString($bytes).Replace('-','').ToLower()
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
Alternatively here is a key generated by your browser:
|
||||
|
||||
<RandomKey />
|
||||
|
||||
Once you have configured Anubis to your liking, start it with PowerShell:
|
||||
|
||||
```powershell
|
||||
Start-Service Anubis
|
||||
```
|
||||
|
||||
And automatically start it on boot with `Set-Service`:
|
||||
|
||||
```powershell
|
||||
Set-Service Anubis -StartupType Automatic
|
||||
```
|
||||
|
||||
### Choosing an install location
|
||||
|
||||
Due to facts and circumstances surrounding how the Anubis installer MSI is created, there is no easy way to graphically pick an install folder for Anubis files. Instead you will need to manually set the `INSTALLDIR` variable with `msiexec`:
|
||||
|
||||
```powershell
|
||||
msiexec /i anubis-1.26.2-windows-amd64.msi INSTALLDIR="D:\Anubis"
|
||||
```
|
||||
|
||||
This is planned to be fixed at a future date or prioritized sooner if an enterprise customer contracts an immediate fix.
|
||||
|
||||
:::note
|
||||
|
||||
Changing the installation directory **DOES NOT** change where configuration files are written to and read from. The configuration files will always be in `%ProgramData%\Techaro\Anubis`.
|
||||
|
||||
:::
|
||||
|
||||
### Silent installs
|
||||
|
||||
To install Anubis silently, pass `/qn` to `msiexec`:
|
||||
|
||||
```powershell
|
||||
msiexec /i anubis-1.26.2-windows-amd64.msi /qn INSTALLDIR="D:\Anubis"
|
||||
```
|
||||
|
||||
## Administration notes
|
||||
|
||||
Anubis was designed for Unix-like systems and as such there are some warts that you should be aware of before deploying it in production.
|
||||
|
||||
### Service account
|
||||
|
||||
The `Anubis` service runs as the [virtual account](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-service-accounts#virtual-accounts) `NT SERVICE\Anubis`. Windows creates it automatically when the service is installed and removes it when it is uninstalled. There is no password to manage and nothing to create by hand.
|
||||
|
||||
The installer grants this virtual account rights on `%ProgramData%\Techaro\Anubis` so it can read its configuration, write its logs, and do other actions critical for Anubis to function. Please do not mess with these permissions. If you (or whoever you contract for compliance) feel that you need to, please file a bug to explain your usecase.
|
||||
|
||||
### Logging
|
||||
|
||||
Typically Windows services write logs to the Event Viewer. Anubis generates a lot more logs in typical operation than the Event Viewer was designed to handle, so by default it writes all its logs to these three files in `%ProgramData%\Techaro\Anubis`:
|
||||
|
||||
| File | Purpose |
|
||||
| ---------------------: | :------------------------------------------------------------------------------------------------------ |
|
||||
| `anubis.log` | All normal Anubis logs. This file will automatically be rotated out as it fills with data and ages out. |
|
||||
| `anubis-bootstrap.log` | Any log messages generated during installation or upgrades. |
|
||||
| `anubis-startup.log` | Any Anubis logs generated during early startup _before_ the main logging system is initialized. |
|
||||
|
||||
### Upgrading
|
||||
|
||||
Installing a newer Anubis MSI over an older install removes the old service before creating the new one. If the service was running, the installer starts it again once the new files are in place. This causes a short interruption while the service is stopped, replaced, and restarted. Please plan upgrades for a maintenance window if that matters to you and your users.
|
||||
|
||||
The service's start type is not preserved when upgrades are performed. It is always reset to manual start. Make sure to re-configure Anubis to start on boot after an upgrade:
|
||||
|
||||
```powershell
|
||||
Set-Service Anubis -StartupType Automatic
|
||||
```
|
||||
|
||||
### IIS
|
||||
|
||||
To configure Anubis on IIS, consult [this guide for more information](https://rentry.co/anubis-on-iis).
|
||||
@@ -0,0 +1,13 @@
|
||||
# Frequently Asked Questions
|
||||
|
||||
## How do I allow small internet browsers like Dillo, NetSurf, and Pale Moon to bypass Anubis?
|
||||
|
||||
Small internet browsers are easy for Anubis to identify. Anubis ships rules that decrease [request weight](./policies.mdx#request-weight) for these browsers to give them easier challenges. To import all small internet browsers at once, load the standard rule:
|
||||
|
||||
```yaml
|
||||
bots:
|
||||
# ...
|
||||
- import: (data)/clients/small-internet-browsers/*.yaml
|
||||
```
|
||||
|
||||
These policies will let users of these browsers through without having to solve expensive challenges.
|
||||
@@ -0,0 +1,106 @@
|
||||
# GeoIP lookups
|
||||
|
||||
As of version 1.28.0, Anubis supports looking up client geographic information using [Maxmind GeoLite databases](https://www.maxmind.com/en/geolite-free-ip-geolocation-data). This can help you easily filter unwanted traffic and apply service quality tiers based on the geographic location of the client.
|
||||
|
||||
## Configuration
|
||||
|
||||
GeoIP databases are configured in the `geoip` block of policy files. If you have them already downloaded to `/var/lib/GeoIP`, you can load them into Anubis with this `geoip` block:
|
||||
|
||||
```yaml
|
||||
geoip:
|
||||
asn:
|
||||
path: /var/lib/GeoIP/GeoLite2-ASN.mmdb
|
||||
country:
|
||||
path: /var/lib/GeoIP/GeoLite2-Country.mmdb
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
Anubis memory-maps these files when opening them. Please ensure that any automatic update (eg via a `geoipupdate` cronjob) does an atomic replace by renaming the new file over the existing one instead of overwriting the file. Overwriting a memory-mapped GeoIP database can and will cause runtime corruption which may result in spectacular issues, none of which are bugs in Anubis.
|
||||
|
||||
:::
|
||||
|
||||
### ASN log association
|
||||
|
||||
If you want to log the [ASN of clients](<https://en.wikipedia.org/wiki/Autonomous_system_(Internet)>), make sure you at least load the `ASN` database and configure the `logging` block:
|
||||
|
||||
```yaml
|
||||
logging:
|
||||
sink: stdio
|
||||
asn: true
|
||||
|
||||
geoip:
|
||||
asn:
|
||||
path: /var/lib/GeoIP/GeoLite2-ASN.mmdb
|
||||
```
|
||||
|
||||
### Automatic updates
|
||||
|
||||
If you have a subscription to Maxmind, Anubis can automatically update GeoIP data based on a set interval:
|
||||
|
||||
```yaml
|
||||
geoip:
|
||||
asn:
|
||||
path: /var/lib/anubis/GeoLite2-ASN.mmdb
|
||||
country:
|
||||
path: /var/lib/anubis/GeoLite2-Country.mmdb
|
||||
auto_update:
|
||||
account_id: 123456
|
||||
license_key_env: MAXMIND_LICENSE_KEY
|
||||
interval: 24h # if not set, this is the default
|
||||
```
|
||||
|
||||
Please ensure that your Maxmind API key is set in the `MAXMIND_LICENSE_KEY` environment variable. Please also ensure that Anubis has write permissions to the place you want to store GeoIP databases. If you aren't sure how big you should make the storage folder, please default to 4 gigabytes until your testing lets you come up with a better size.
|
||||
|
||||
If you have an internal Maxmind mirror, you can set that URL with the `endpoint` key:
|
||||
|
||||
```yaml
|
||||
geoip:
|
||||
asn:
|
||||
path: /data/geoip/GeoLite2-ASN.mmdb
|
||||
country:
|
||||
path: /data/geoip/GeoLite2-Country.mmdb
|
||||
auto_update:
|
||||
account_id: 123456
|
||||
license_key_env: MAXMIND_LICENSE_KEY
|
||||
interval: 72h
|
||||
endpoint: https://geoip-mirror.internal.example.com
|
||||
```
|
||||
|
||||
## `asn` and `geoip` filtering
|
||||
|
||||
When companies link their backbone infrastructure to the Internet, they do so via a [BGP Autonomous System](<https://en.wikipedia.org/wiki/Autonomous_system_(Internet)>), denoted by a number (the Autonomous System Number or ASN). Every IP address on the Internet is owned by an ASN with a 1:1 lookup that does not change very frequently.
|
||||
|
||||
Anubis uses GeoIP databases to automatically tag requests via their ASN or country of origin. For example, here's how you add 10 weight points to requests from Cloudflare, Huawei Cloud, and Alibaba Cloud:
|
||||
|
||||
```yaml
|
||||
- name: aggressive-asns-without-functional-abuse-contact
|
||||
action: WEIGH
|
||||
asns:
|
||||
match:
|
||||
- 13335 # Cloudflare
|
||||
- 136907 # Huawei Cloud
|
||||
- 45102 # Alibaba Cloud
|
||||
weight:
|
||||
adjust: 10
|
||||
```
|
||||
|
||||
You can look up details for [AS13335](https://bgp.tools/as/13335) or any of these other top offenders on [bgp.tools](https://bgp.tools).
|
||||
|
||||
In extreme cases, an administrator may have to take action against an entire country. This is not an ideal circumstance, but sometimes reality forces their hands and the administrators just want to sleep at night.
|
||||
|
||||
For example, to add 10 weight points to requests from Brazil and China:
|
||||
|
||||
```yaml
|
||||
- name: countries-with-aggressive-scrapers
|
||||
action: WEIGH
|
||||
geoip:
|
||||
countries:
|
||||
- BR
|
||||
- CN
|
||||
- VN
|
||||
weight:
|
||||
adjust: 10
|
||||
```
|
||||
|
||||
Use this with care.
|
||||
@@ -17,6 +17,22 @@ In this limited preview state, Anubis generates pages using [spintax](https://ou
|
||||
|
||||
This should be fairly transparent to humans that this is pseudoprofound anti-content and is a signal to click away.
|
||||
|
||||
## fail2ban implications
|
||||
|
||||
This works by adding an entry point to the honeypot maze in every page like this:
|
||||
|
||||
```html
|
||||
<script type="ignore">
|
||||
<a
|
||||
href="/.within.website/x/cmd/anubis/api/honeypot/<uuid>/init"
|
||||
>
|
||||
Don't click me
|
||||
</a>
|
||||
</script>
|
||||
```
|
||||
|
||||
Any hits that match the URL `^/.within.website/x/cmd/anubis/api/honeypot/.*` are _malicious_ and should be blocked. A spec-compliant HTML parser will not parse this link, so any parser that does and visits it is categorically in the wrong.
|
||||
|
||||
## Plans
|
||||
|
||||
Future versions of this feature will allow for more customization. In the near future this will be configurable via the following mechanisms:
|
||||
@@ -37,4 +53,25 @@ Right now Anubis assigns 30 weight points if the following criteria are met:
|
||||
- A client's User-Agent has been observed in the dataset poisoning maze at least 25 times.
|
||||
- The network-clamped IP address (/24 for IPv4 and /48 for IPv6) has been observed in the dataset poisoning maze at least 25 times.
|
||||
|
||||
Additionally, when any given client by both User-Agent and network-clamped IP address has been observed, Anubis will emit log lines warning about it so that administrative action can be taken up to and including [filing abuse reports with the network owner](/blog/2025/file-abuse-reports).
|
||||
When any given client by both User-Agent and network-clamped IP address has been observed, Anubis will emit log lines warning about it so that administrative action can be taken up to and including [filing abuse reports with the network owner](/blog/2025/file-abuse-reports).
|
||||
|
||||
### IP address logging
|
||||
|
||||
Anubis' honeypot feature can log IP addresses to a file. These logs let you configure fail2ban pipelines or integrate with other software to block bot traffic (eg: Panorama).
|
||||
|
||||
To use this feature:
|
||||
|
||||
- Anubis must have access to storage it can write to.
|
||||
- The backing filesystem must support writes, seeking, and truncation.
|
||||
- The Anubis user must have write permissions to the log file.
|
||||
|
||||
Configure this log file in the `honeypot` section of your [policy file](../policies.mdx):
|
||||
|
||||
```yaml
|
||||
honeypot:
|
||||
enabled: true
|
||||
implementation: naive
|
||||
ip_log_file: /data/anubis/honeypot.addrs
|
||||
```
|
||||
|
||||
Anubis collects the IP addresses that hit the honeypot feature continuously and buffers them into memory. Anubis writes collected IP addresses every minute or when Anubis collects 32 kilobytes of addresses, whichever happens first. Once the file gets bigger than 64 kilobytes, the file is reset to avoid infinite growth.
|
||||
@@ -39,6 +39,7 @@ Anubis is shipped in the Docker repo [`ghcr.io/techarohq/anubis`](https://github
|
||||
| Tag | Meaning |
|
||||
| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `latest` | The latest [tagged release](https://github.com/TecharoHQ/anubis/releases), if you are in doubt, start here. |
|
||||
| `pre` | The latest prerelease of Anubis. These releases will soon become full tagged releases. |
|
||||
| `v<version number>` | The Anubis image for [any given tagged release](https://github.com/TecharoHQ/anubis/tags) |
|
||||
| `main` | The current build on the `main` branch. Only use this if you need the latest and greatest features as they are merged into `main`. |
|
||||
|
||||
@@ -66,46 +67,48 @@ Currently the following settings are configurable via the policy file:
|
||||
|
||||
Anubis uses these environment variables for configuration:
|
||||
|
||||
| Environment Variable | Default value | Explanation |
|
||||
| :----------------------------- | :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ASSET_LOOKUP_HEADER` | unset | <EO /> If set, use the contents of this header in requests when looking up custom assets in `OVERLAY_FOLDER`. See [Header-based overlay dispatch](./botstopper.mdx#header-based-overlay-dispatch) for more details. |
|
||||
| `BASE_PREFIX` | unset | If set, adds a global prefix to all Anubis endpoints (everything starting with `/.within.website/x/anubis/`). For example, setting this to `/myapp` would make Anubis accessible at `/myapp/` instead of `/`. This is useful when running Anubis behind a reverse proxy that routes based on path prefixes. |
|
||||
| `BIND` | `:8923` | The network address that Anubis listens on. For `unix`, set this to a path: `/run/anubis/instance.sock` |
|
||||
| `BIND_NETWORK` | `tcp` | The address family that Anubis listens on. Accepts `tcp`, `unix` and anything Go's [`net.Listen`](https://pkg.go.dev/net#Listen) supports. |
|
||||
| `CHALLENGE_TITLE` | unset | <EO /> If set, override the translation stack to show a custom title for challenge pages such as "Making sure your connection is secure!". See [Customizing messages](./botstopper.mdx#customizing-messages) for more details. |
|
||||
| `COOKIE_DOMAIN` | unset | The domain the Anubis challenge pass cookie should be set to. This should be set to the domain you bought from your registrar (EG: `techaro.lol` if your webapp is running on `anubis.techaro.lol`). See this [stackoverflow explanation of cookies](https://stackoverflow.com/a/1063760) for more information.<br/><br/>Note that unlike `REDIRECT_DOMAINS`, you should never include a port number in this variable. |
|
||||
| `COOKIE_DYNAMIC_DOMAIN` | false | If set to true, automatically set cookie domain fields based on the hostname of the request. EG: if you are making a request to `anubis.techaro.lol`, the Anubis cookie will be valid for any subdomain of `techaro.lol`. |
|
||||
| `COOKIE_EXPIRATION_TIME` | `168h` | The amount of time the authorization cookie is valid for. |
|
||||
| `CUSTOM_REAL_IP_HEADER` | unset | If set, Anubis will read the client's real IP address from this header, and set it in `X-Real-IP` header. |
|
||||
| `COOKIE_PARTITIONED` | `false` | If set to `true`, enables the [partitioned (CHIPS) flag](https://developers.google.com/privacy-sandbox/cookies/chips), meaning that Anubis inside an iframe has a different set of cookies than the domain hosting the iframe. |
|
||||
| `COOKIE_PREFIX` | `anubis-cookie` | The prefix used for browser cookies created by Anubis. Useful for customization or avoiding conflicts with other applications. |
|
||||
| `COOKIE_SECURE` | `true` | If set to `true`, enables the [Secure flag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies#block_access_to_your_cookies), meaning that the cookies will only be transmitted over HTTPS. If Anubis is used in an unsecure context (plain HTTP), this will be need to be set to false |
|
||||
| `COOKIE_SAME_SITE` | `None` | Controls the cookie’s [`SameSite` attribute](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value). Allowed: `None`, `Lax`, `Strict`, `Default`. `None` permits cross-site use but modern browsers require it to be **Secure**—so if `COOKIE_SECURE=false` or you serve over plain HTTP, use `Lax` (recommended) or `Strict` or the cookie will be rejected. `Default` uses the Go runtime’s `SameSiteDefaultMode`. `None` will be downgraded to `Lax` automatically if cookie is set NOT to be secure. |
|
||||
| `DIFFICULTY` | `4` | The difficulty of the challenge, or the number of leading zeroes that must be in successful responses. |
|
||||
| `DIFFICULTY_IN_JWT` | `false` | If set to `true`, adds the `difficulty` field into JWT claims, which indicates the difficulty the token has been generated. This may be useful for statistics and debugging. |
|
||||
| `ED25519_PRIVATE_KEY_HEX` | unset | The hex-encoded ed25519 private key used to sign Anubis responses. If this is not set, Anubis will generate one for you. This should be exactly 64 characters long. **Required when using persistent storage backends** (like bbolt) to ensure challenges survive service restarts. When running multiple instances on the same base domain, the key must be the same across all instances. See below for details. |
|
||||
| `ED25519_PRIVATE_KEY_HEX_FILE` | unset | Path to a file containing the hex-encoded ed25519 private key. Only one of this or its sister option may be set. **Required when using persistent storage backends** (like bbolt) to ensure challenges survive service restarts. When running multiple instances on the same base domain, the key must be the same across all instances. |
|
||||
| `ERROR_TITLE` | unset | <EO /> If set, override the translation stack to show a custom title for error pages such as "Something went wrong!". See [Customizing messages](./botstopper.mdx#customizing-messages) for more details. |
|
||||
| `JWT_RESTRICTION_HEADER` | `X-Real-IP` | If set, the JWT is only valid if the current value of this header matches the value when the JWT was created. You can use it e.g. to restrict a JWT to the source IP of the user using `X-Real-IP`. |
|
||||
| `METRICS_BIND` | `:9090` | The network address that Anubis serves Prometheus metrics on. See `BIND` for more information. |
|
||||
| `METRICS_BIND_NETWORK` | `tcp` | The address family that the Anubis metrics server listens on. See `BIND_NETWORK` for more information. |
|
||||
| `OG_EXPIRY_TIME` | `24h` | The expiration time for the Open Graph tag cache. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OG_PASSTHROUGH` | `false` | If set to `true`, Anubis will enable Open Graph tag passthrough. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OG_CACHE_CONSIDER_HOST` | `false` | If set to `true`, Anubis will consider the host in the Open Graph tag cache key. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OVERLAY_FOLDER` | unset | <EO /> If set, treat the given path as an [overlay folder](./botstopper.mdx#custom-images-and-css), allowing you to customize CSS, fonts, images, and add other assets to BotStopper deployments. |
|
||||
| `POLICY_FNAME` | unset | The file containing [bot policy configuration](./policies.mdx). See the bot policy documentation for more details. If unset, the default bot policy configuration is used. |
|
||||
| `PUBLIC_URL` | unset | The externally accessible URL for this Anubis instance, used for constructing redirect URLs (e.g., for Traefik forwardAuth). Leave it unset when Anubis terminates traffic directly (sidecar/standalone deployments) or redirect building will fail with `redir=null`. |
|
||||
| `REDIRECT_DOMAINS` | unset | Comma-separated list of domain names that Anubis should allow redirects to when passing a challenge. See [Redirect Domain Configuration](./configuration/redirect-domains) for more details. |
|
||||
| `SERVE_ROBOTS_TXT` | `false` | If set `true`, Anubis will serve a default `robots.txt` file that disallows all known AI scrapers by name and then additionally disallows every scraper. This is useful if facts and circumstances make it difficult to change the underlying service to serve such a `robots.txt` file. |
|
||||
| `SLOG_LEVEL` | `INFO` | The log level for structured logging. Valid values are `DEBUG`, `INFO`, `WARN`, and `ERROR`. Set to `DEBUG` to see all requests, evaluations, and detailed diagnostic information. |
|
||||
| `SOCKET_MODE` | `0770` | _Only used when at least one of the `*_BIND_NETWORK` variables are set to `unix`._ The socket mode (permissions) for Unix domain sockets. |
|
||||
| `STRIP_BASE_PREFIX` | `false` | If set to `true`, strips the base prefix from request paths when forwarding to the target server. This is useful when your target service expects to receive requests without the base prefix. For example, with `BASE_PREFIX=/foo` and `STRIP_BASE_PREFIX=true`, a request to `/foo/bar` would be forwarded to the target as `/bar`. |
|
||||
| `TARGET` | `http://localhost:3923` | The URL of the service that Anubis should forward valid requests to. Supports Unix domain sockets, set this to a URI like so: `unix:///path/to/socket.sock`. |
|
||||
| `USE_REMOTE_ADDRESS` | unset | If set to `true`, Anubis will take the client's IP from the network socket. For production deployments, it is expected that a reverse proxy is used in front of Anubis, which pass the IP using headers, instead. |
|
||||
| `USE_SIMPLIFIED_EXPLANATION` | false | If set to `true`, replaces the text when clicking "Why am I seeing this?" with a more simplified text for a non-tech-savvy audience. |
|
||||
| `USE_TEMPLATES` | false | <EO /> If set to `true`, enable [custom HTML template support](./botstopper.mdx#custom-html-templates), allowing you to completely rewrite how BotStopper renders its HTML pages. |
|
||||
| `WEBMASTER_EMAIL` | unset | If set, shows a contact email address when rendering error pages. This email address will be how users can get in contact with administrators. |
|
||||
| `XFF_STRIP_PRIVATE` | `true` | If set, strip private addresses from `X-Forwarded-For` headers. To unset this, you must set `XFF_STRIP_PRIVATE=false` or `--xff-strip-private=false`. |
|
||||
| Environment Variable | Default value | Explanation |
|
||||
| :---------------------------------------- | :---------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ASSET_LOOKUP_HEADER` | unset | <EO /> If set, use the contents of this header in requests when looking up custom assets in `OVERLAY_FOLDER`. See [Header-based overlay dispatch](./botstopper.mdx#header-based-overlay-dispatch) for more details. |
|
||||
| `BASE_PREFIX` | unset | If set, adds a global prefix to all Anubis endpoints (everything starting with `/.within.website/x/anubis/`). For example, setting this to `/myapp` would make Anubis accessible at `/myapp/` instead of `/`. This is useful when running Anubis behind a reverse proxy that routes based on path prefixes. |
|
||||
| `BIND` | `:8923` | The network address that Anubis listens on. For `unix`, set this to a path: `/run/anubis/instance.sock` |
|
||||
| `BIND_NETWORK` | `tcp` | The address family that Anubis listens on. Accepts `tcp`, `unix` and anything Go's [`net.Listen`](https://pkg.go.dev/net#Listen) supports. |
|
||||
| `CHALLENGE_TITLE` | unset | <EO /> If set, override the translation stack to show a custom title for challenge pages such as "Making sure your connection is secure!". See [Customizing messages](./botstopper.mdx#customizing-messages) for more details. |
|
||||
| `COOKIE_DOMAIN` | unset | The domain the Anubis challenge pass cookie should be set to. This should be set to the domain you bought from your registrar (EG: `techaro.lol` if your webapp is running on `anubis.techaro.lol`). See this [stackoverflow explanation of cookies](https://stackoverflow.com/a/1063760) for more information.<br/><br/>Note that unlike `REDIRECT_DOMAINS`, you should never include a port number in this variable. |
|
||||
| `COOKIE_DYNAMIC_DOMAIN` | false | If set to true, automatically set cookie domain fields based on the hostname of the request. EG: if you are making a request to `anubis.techaro.lol`, the Anubis cookie will be valid for any subdomain of `techaro.lol`. |
|
||||
| `COOKIE_EXPIRATION_TIME` | `168h` | The amount of time the authorization cookie is valid for. |
|
||||
| `CUSTOM_REAL_IP_HEADER` | unset | If set, Anubis will read the client's real IP address from this header, and set it in `X-Real-IP` header. |
|
||||
| `COOKIE_PARTITIONED` | `false` | If set to `true`, enables the [partitioned (CHIPS) flag](https://developers.google.com/privacy-sandbox/cookies/chips), meaning that Anubis inside an iframe has a different set of cookies than the domain hosting the iframe. |
|
||||
| `COOKIE_PREFIX` | `anubis-cookie` | The prefix used for browser cookies created by Anubis. Useful for customization or avoiding conflicts with other applications. |
|
||||
| `COOKIE_HTTP_ONLY` | `false` | If set to `true`, enables the [HttpOnly flag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies#block_access_to_your_cookies), meaning that the cookies will only be readable by the server. |
|
||||
| `COOKIE_SECURE` | `true` | If set to `true`, enables the [Secure flag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies#block_access_to_your_cookies), meaning that the cookies will only be transmitted over HTTPS. If Anubis is used in an unsecure context (plain HTTP), this will be need to be set to false |
|
||||
| `COOKIE_SAME_SITE` | `None` | Controls the cookie’s [`SameSite` attribute](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value). Allowed: `None`, `Lax`, `Strict`, `Default`. `None` permits cross-site use but modern browsers require it to be **Secure**—so if `COOKIE_SECURE=false` or you serve over plain HTTP, use `Lax` (recommended) or `Strict` or the cookie will be rejected. `Default` uses the Go runtime’s `SameSiteDefaultMode`. `None` will be downgraded to `Lax` automatically if cookie is set NOT to be secure. |
|
||||
| `DIFFICULTY` | `4` | The difficulty of the challenge, or the number of leading zeroes that must be in successful responses. |
|
||||
| `DIFFICULTY_IN_JWT` | `false` | If set to `true`, adds the `difficulty` field into JWT claims, which indicates the difficulty the token has been generated. This may be useful for statistics and debugging. |
|
||||
| `DYNAMIC_COOKIE_SUFFIX` | `true` | If set to `true`, generates a suffix for cookie names based on current cookie settings. Leaving it `true` is recommended to [circumvent infinite loops](https://github.com/TecharoHQ/anubis/releases/tag/v1.27.0). Disabling this feature is only required when needing to work with a specific cookie name (e.g. in the [HAProxy advanced config](./environments/haproxy.mdx#advanced-variant)). |
|
||||
| `ED25519_PRIVATE_KEY_HEX` | unset | The hex-encoded ed25519 private key used to sign Anubis responses. If this is not set, Anubis will generate one for you. This should be exactly 64 characters long. **Required when using persistent storage backends** (like bbolt) to ensure challenges survive service restarts. When running multiple instances on the same base domain, the key must be the same across all instances. See below for details. |
|
||||
| `ED25519_PRIVATE_KEY_HEX_FILE` | unset | Path to a file containing the hex-encoded ed25519 private key. Only one of this or its sister option may be set. **Required when using persistent storage backends** (like bbolt) to ensure challenges survive service restarts. When running multiple instances on the same base domain, the key must be the same across all instances. |
|
||||
| `ERROR_TITLE` | unset | <EO /> If set, override the translation stack to show a custom title for error pages such as "Something went wrong!". See [Customizing messages](./botstopper.mdx#customizing-messages) for more details. |
|
||||
| `JWT_RESTRICTION_HEADER` | `X-Real-IP` | If set, the JWT is only valid if the current value of this header matches the value when the JWT was created. You can use it e.g. to restrict a JWT to the source IP of the user using `X-Real-IP`. |
|
||||
| `METRICS_BIND` | `:9090` | The legacy configuration value for the network address that Anubis serves Prometheus metrics on. Please migrate this to [the policy file](./policies.mdx#metrics-server) as soon as possible. |
|
||||
| `METRICS_BIND_NETWORK` | `tcp` | The legacy configuration value for the address family that Anubis serves Prometheus metrics on. Please migrate this to [the policy file](./policies.mdx#metrics-server) as soon as possible. |
|
||||
| `OG_EXPIRY_TIME` | `24h` | The expiration time for the Open Graph tag cache. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OG_PASSTHROUGH` | `false` | If set to `true`, Anubis will enable Open Graph tag passthrough. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OG_CACHE_CONSIDER_HOST` | `false` | If set to `true`, Anubis will consider the host in the Open Graph tag cache key. Prefer using [the policy file](./configuration/open-graph.mdx) to configure the Open Graph subsystem. |
|
||||
| `OVERLAY_FOLDER` | unset | <EO /> If set, treat the given path as an [overlay folder](./botstopper.mdx#custom-images-and-css), allowing you to customize CSS, fonts, images, and add other assets to BotStopper deployments. |
|
||||
| `POLICY_FNAME` | unset | The file containing [bot policy configuration](./policies.mdx). See the bot policy documentation for more details. If unset, the default bot policy configuration is used. |
|
||||
| `PUBLIC_URL` | unset | The externally accessible URL for this Anubis instance, used for constructing redirect URLs (e.g., for Traefik forwardAuth). Leave it unset when Anubis terminates traffic directly (sidecar/standalone deployments) or redirect building will fail with `redir=null`. |
|
||||
| `REDIRECT_DOMAINS` | unset | Comma-separated list of domain names that Anubis should allow redirects to when passing a challenge. See [Redirect Domain Configuration](./configuration/redirect-domains.mdx) for more details. |
|
||||
| `SERVE_ROBOTS_TXT` | `false` | If set `true`, Anubis will serve a default `robots.txt` file that disallows all known AI scrapers by name and then additionally disallows every scraper. This is useful if facts and circumstances make it difficult to change the underlying service to serve such a `robots.txt` file. |
|
||||
| `SLOG_LEVEL` | `INFO` | The log level for structured logging. Valid values are `DEBUG`, `INFO`, `WARN`, and `ERROR`. Set to `DEBUG` to see all requests, evaluations, and detailed diagnostic information. |
|
||||
| `SOCKET_MODE` | `0770` | _Only used when at least one of the `*_BIND_NETWORK` variables are set to `unix`._ The socket mode (permissions) for Unix domain sockets. |
|
||||
| `STRIP_BASE_PREFIX` | `false` | If set to `true`, strips the base prefix from request paths when forwarding to the target server. This is useful when your target service expects to receive requests without the base prefix. For example, with `BASE_PREFIX=/foo` and `STRIP_BASE_PREFIX=true`, a request to `/foo/bar` would be forwarded to the target as `/bar`. |
|
||||
| `TARGET` | `http://localhost:3923` | The URL of the service that Anubis should forward valid requests to. Supports Unix domain sockets, set this to a URI like so: `unix:///path/to/socket.sock`. |
|
||||
| `USE_REMOTE_ADDRESS` | unset | If set to `true`, Anubis will take the client's IP from the network socket. For production deployments, it is expected that a reverse proxy is used in front of Anubis, which pass the IP using headers, instead. |
|
||||
| `USE_SIMPLIFIED_EXPLANATION` (deprecated) | true | If set to `true`, replaces the text when clicking "Why am I seeing this?" with a more simplified text for a non-tech-savvy audience. |
|
||||
| `USE_TEMPLATES` | false | <EO /> If set to `true`, enable [custom HTML template support](./botstopper.mdx#custom-html-templates), allowing you to completely rewrite how BotStopper renders its HTML pages. |
|
||||
| `WEBMASTER_EMAIL` | unset | If set, shows a contact email address when rendering error pages. This email address will be how users can get in contact with administrators. |
|
||||
| `XFF_STRIP_PRIVATE` | `true` | If set, strip private addresses from `X-Forwarded-For` headers. To unset this, you must set `XFF_STRIP_PRIVATE=false` or `--xff-strip-private=false`. |
|
||||
|
||||
<details>
|
||||
<summary>Advanced configuration settings</summary>
|
||||
|
||||
@@ -117,6 +117,96 @@ remote_addresses:
|
||||
- 100.64.0.0/10
|
||||
```
|
||||
|
||||
## Metrics server
|
||||
|
||||
Anubis includes support for [Prometheus-style metrics](https://prometheus.io/docs/introduction/overview/), allowing systems administrators to monitor Anubis' performance and effectiveness. This is a separate HTTP server with metrics, health checking, and debug routes.
|
||||
|
||||
Anubis' metrics server is configured with the `metrics` block in the configuration file:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
```
|
||||
|
||||
If you want to bind metrics to a Unix socket, make sure to set the network to `unix` and add a socket mode:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: "/tmp/anubis_metrics.sock"
|
||||
network: unix
|
||||
socketMode: "0700" # must be a string
|
||||
```
|
||||
|
||||
### Debug routes
|
||||
|
||||
Anubis' metrics server supports [pprof](https://pkg.go.dev/runtime/pprof), the Go standard library tool for profiling Go applications. This is very useful for debugging how Anubis works in the wild with regards to CPU, multicore, and RAM usage. pprof is very powerful and can expose command line arguments as part of the debugging setup (inside Google, everything is done with command line flags).
|
||||
|
||||
Prior versions of Anubis exposed pprof endpoints on all TCP bindhosts by default. This means that machines with incorrectly configured firewalls can expose command line arguments to the public internet in the right conditions.
|
||||
|
||||
In order to enable pprof profiling endpoints on the Metrics server, set the `debug` flag under the `metrics` block:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
|
||||
debug: true
|
||||
```
|
||||
|
||||
To err on the side of caution, this defaults to disabled. If this defaults migration breaks your configuration, please let us know in a ticket.
|
||||
|
||||
### TLS
|
||||
|
||||
If you want to serve the metrics server over TLS, use the `tls` block:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
|
||||
tls:
|
||||
certificate: /path/to/tls.crt
|
||||
key: /path/to/tls.key
|
||||
```
|
||||
|
||||
The certificate and key will automatically be reloaded when the respective files change.
|
||||
|
||||
### mTLS
|
||||
|
||||
If you want to validate requests to ensure that they use a client certificate signed by a certificate authority (mutual TLS or mTLS), set the `ca` value in the `tls` block:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
|
||||
tls:
|
||||
certificate: /path/to/tls.crt
|
||||
key: /path/to/tls.key
|
||||
ca: /path/to/ca.crt
|
||||
```
|
||||
|
||||
As it is not expected for certificate authority certificates to change often, the CA certificate will NOT be automatically reloaded when the respective file changes.
|
||||
|
||||
### HTTP basic authentication
|
||||
|
||||
Anubis' metrics server also supports setting HTTP basic auth as a lightweight protection against unauthorized users viewing metrics data. As the basic auth credentials are hardcoded in the configuration file, administrators SHOULD use randomly generated credentials, such as type-4 UUIDs or other high entropy strings. These credentials MUST NOT be sensitive or used to protect other high value systems.
|
||||
|
||||
Configure it with the `basicAuth` block under `metrics`:
|
||||
|
||||
```yaml
|
||||
metrics:
|
||||
bind: ":9090"
|
||||
network: "tcp"
|
||||
|
||||
basicAuth:
|
||||
username: azurediamond
|
||||
password: hunter2
|
||||
```
|
||||
|
||||
If you have Python installed, you can generate a high entropy password with `python -c 'import secrets; print(secrets.token_urlsafe(32))'`.
|
||||
|
||||
## Imprint / Impressum support
|
||||
|
||||
Anubis has support for showing imprint / impressum information. This is defined in the `impressum` block of your configuration. See [Imprint / Impressum configuration](./configuration/impressum.mdx) for more information.
|
||||
@@ -129,6 +219,7 @@ Anubis offers the following storage backends:
|
||||
|
||||
- [`memory`](#memory) -- A simple in-memory hashmap
|
||||
- [`bbolt`](#bbolt) -- An on-disk key/value store backed by [bbolt](https://github.com/etcd-io/bbolt), an embedded key/value database for Go programs
|
||||
- [`s3api`](#s3api) -- A network-backed storage layer backed by [object storage](https://en.wikipedia.org/wiki/Object_storage), specifically using the [S3 API](https://docs.aws.amazon.com/AmazonS3/latest/API/Type_API_Reference.html).
|
||||
- [`valkey`](#valkey) -- A remote in-memory key/value database backed by [Valkey](https://valkey.io/) (or another database compatible with the [RESP](https://redis.io/docs/latest/develop/reference/protocol-spec/) protocol)
|
||||
|
||||
If no storage backend is set in the policy file, Anubis will use the [`memory`](#memory) backend by default. This is equivalent to the following in the policy file:
|
||||
@@ -339,6 +430,7 @@ Anubis exposes the following logging settings in the policy file:
|
||||
| `level` | [log level](#log-levels) | `info` | The logging level threshold. Any logs that are at or above this threshold will be drained to the sink. Any other logs will be discarded. |
|
||||
| `sink` | string | `stdio`, `file` | The sink where the logs drain to as they are being recorded in Anubis. |
|
||||
| `parameters` | object | | Parameters for the given logging sink. This will vary based on the logging sink of choice. See below for more information. |
|
||||
| `asn` | bool | `true`, `false` | Add ASN information to logs/metrics. (Requires [GeoIP](./geoip.mdx) configuration) |
|
||||
|
||||
Anubis supports the following logging sinks:
|
||||
|
||||
@@ -393,6 +485,32 @@ logging:
|
||||
|
||||
When files are rotated out, the old files will be named after the rotation timestamp in [RFC 3339 format](https://www.rfc-editor.org/rfc/rfc3339).
|
||||
|
||||
:::note
|
||||
|
||||
If you are running Anubis in systemd via a native package, the default systemd unit settings are very restrictive and will forbid writing to folders in `/var/log`. In order to fix this, please make a [drop-in unit](https://www.flatcar.org/docs/latest/setup/systemd/drop-in-units/) like the following:
|
||||
|
||||
```text
|
||||
# /etc/systemd/anubis@instance-name.service.d/50-var-log-readwrite.conf
|
||||
[Service]
|
||||
ReadWritePaths=/run /var/log/anubis
|
||||
```
|
||||
|
||||
Once you write this to the correct place, reload the systemd configuration:
|
||||
|
||||
```text
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
And then restart Anubis:
|
||||
|
||||
```text
|
||||
sudo systemctl restart anubis@instance-name
|
||||
```
|
||||
|
||||
You may be required to make drop-ins for each Anubis instance depending on the facts and circumstances of your deployment.
|
||||
|
||||
:::
|
||||
|
||||
### `stdio` sink
|
||||
|
||||
By default, Anubis logs everything to the standard error stream of its process. This requires no configuration:
|
||||
@@ -404,6 +522,36 @@ logging:
|
||||
|
||||
If you use a service orchestration platform that does not capture the standard error stream of processes, you need to use a different logging sink.
|
||||
|
||||
## Honeypot configuration
|
||||
|
||||
Anubis has support for [dataset poisoning](./honeypot/overview.mdx). Out of the box this is enabled so that administrators can feed fail2ban pipelines. This works by adding an entry point to the honeypot maze in every page like this:
|
||||
|
||||
```html
|
||||
<script type="ignore">
|
||||
<a
|
||||
href="/.within.website/x/cmd/anubis/api/honeypot/<uuid>/init"
|
||||
>
|
||||
Don't click me
|
||||
</a>
|
||||
</script>
|
||||
```
|
||||
|
||||
Any hits that match the URL `^/.within.website/x/cmd/anubis/api/honeypot/.*` are _malicious_ and should be blocked. A spec-compliant HTML parser will not parse this link, so any parser that does and visits it is categorically in the wrong.
|
||||
|
||||
The following configuration options are supported:
|
||||
|
||||
```yaml
|
||||
## Honeypot configuration
|
||||
honeypot:
|
||||
## If not set, Anubis will assume you meant `true`.
|
||||
enabled: true
|
||||
## Currently the only supported method is the naive method.
|
||||
## See https://anubis.techaro.lol/docs/admin/honeypot/overview#implementation-notes for more information
|
||||
implementation: naive
|
||||
```
|
||||
|
||||
For more information about this feature, consult the [Dataset Poisoning](./honeypot/overview.mdx) page.
|
||||
|
||||
## Risk calculation for downstream services
|
||||
|
||||
In case your service needs it for risk calculation reasons, Anubis exposes information about the rules that any requests match using a few headers:
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
# Thoth-based advanced checks
|
||||
---
|
||||
title: Thoth-based advanced checks
|
||||
unlisted: true
|
||||
---
|
||||
|
||||
Status: Beta
|
||||
:::note
|
||||
|
||||
This page describes a service that has since been cancelled and is scheduled for removal from the codebase. Please use [GeoIP databases](./geoip.mdx) instead. Thoth will be reused for other things eventually.
|
||||
|
||||
:::
|
||||
|
||||
Status: Cancelled
|
||||
|
||||
Anubis instances are normally isolated. Each Anubis instance has its own configuration and exists in roughly its own world without any long term memory between requests. As threats, workarounds, and AI scraper toolchains evolve, administrators will need a way to get more up to date information faster than Anubis' release cycle.
|
||||
|
||||
|
||||
@@ -104,4 +104,4 @@ This ensures that the token has enough metadata to prove that the token is valid
|
||||
|
||||
## JWT signing
|
||||
|
||||
Anubis uses an ed25519 keypair to sign the JWTs issued when challenges are passed. Anubis will generate a new ed25519 keypair every time it starts. At this time, there is no way to share this keypair between instance of Anubis, but that will be addressed in future versions.
|
||||
Anubis uses an ed25519 keypair to sign the JWTs issued when challenges are passed. Anubis will generate a new ed25519 keypair every time it starts. At this time, there is no way to share this keypair between instances of Anubis, but that will be addressed in future versions.
|
||||
@@ -0,0 +1,132 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[INSERT CONTACT METHOD].
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
@@ -0,0 +1,161 @@
|
||||
# Contributing to Anubis
|
||||
|
||||
Anubis is a Web AI Firewall Utility (WAIFU) written in Go. This is security software, correctness and test coverage matters.
|
||||
|
||||
## Build & Run
|
||||
|
||||
Prerequisites:
|
||||
|
||||
- Go 1.27.3 or later.
|
||||
- Node.js (any supported LTS version).
|
||||
- Rust version 1.80 or later.
|
||||
- Optionally: Wasmtime
|
||||
- Optionally: binaryen version 130 (exact match).
|
||||
- esbuild, gzip, zstd, brotli, msitools
|
||||
|
||||
If you have [Homebrew](https://brew.sh) installed: install all development tools at once with `brew bundle`.
|
||||
|
||||
### Useful commands
|
||||
|
||||
```shell
|
||||
npm ci # install source-level dependencies
|
||||
npm run assets # build JS/CSS (required before any Go build/test)
|
||||
npm run build # assets + go build -> ./var/anubis
|
||||
npm run dev # assets + run locally with --use-remote-address
|
||||
npm run format # format all code to project standards
|
||||
```
|
||||
|
||||
When using `npm run dev`, Anubis runs on `http://localhost:8923` and points to `http://localhost:3000`. The documentation site listens on port `3000` by default.
|
||||
|
||||
## Testing
|
||||
|
||||
```shell
|
||||
# Run all unit tests (assets must be built first)
|
||||
npm run test
|
||||
|
||||
# Run integration tests with real browsers
|
||||
npm run test:integration
|
||||
|
||||
# Run a single test by name
|
||||
go test -run TestClampIP ./internal/
|
||||
|
||||
# Run a single test file's package
|
||||
go test ./lib/config/
|
||||
|
||||
# Run tests with verbose output
|
||||
go test -v -run TestBotValid ./lib/config/
|
||||
```
|
||||
|
||||
### Smoke tests
|
||||
|
||||
Anubis has functionality tests called smoke tests. Read more about them in the [smoke testing page](./smoke-tests.mdx).
|
||||
|
||||
## Linting
|
||||
|
||||
```shell
|
||||
go vet ./...
|
||||
go tool staticcheck ./...
|
||||
go tool govulncheck ./...
|
||||
```
|
||||
|
||||
## Code Generation
|
||||
|
||||
Anubis makes heavy use of code generation with `go generate` for HTML templating with [templ](https://templ.guide/), CSS optimization, and JavaScript building.
|
||||
|
||||
Run all code generation logic with `npm run assets`.
|
||||
|
||||
## Project Layout
|
||||
|
||||
Important folders:
|
||||
|
||||
- `cmd/anubis`: Main entrypoint for the project. Parses command line flags and starts listening over HTTP.
|
||||
- `lib/*`: The core library for Anubis and all of its features. This is internal code that is made public for ease of downstream consumption by [BotStopper](../admin/botstopper.mdx).<br/><br/>No API stability is guaranteed. Use at your own risk.
|
||||
- `internal/*`: Actual internal code that is private to the implementation of Anubis. If you need to use a package in this, please copy it out and manually vendor it in your own project.
|
||||
- `test/*`: [Smoke tests](./smoke-tests.mdx).
|
||||
- `web`: Frontend HTML templates.
|
||||
- `xess`: Frontend CSS framework and build logic.
|
||||
|
||||
## Code Style
|
||||
|
||||
Anubis is written in several programming languages. Please keep these guidelines in mind:
|
||||
|
||||
### Go
|
||||
|
||||
This project follows standard Go idioms. These include:
|
||||
|
||||
- The standard library is already a dependency. Use the standard library as much as possible.
|
||||
- Avoid package import aliases unless you have no other choice.
|
||||
- Use `go tool goimports` to format code. Run with `npm run format`.
|
||||
- Use sentinel errors as package-level variables prefixed with `Err` (such as `ErrImportIsInvalid`). Wrap errors with [`fmt.Errorf`](https://pkg.go.dev/fmt#Errorf)'s `%w` formatting verb. Compare against sentinel errors in tests with `errors.Is`.
|
||||
- Use [`log/slog`](https://pkg.go.dev/log/slog) for all logging. Use the local logger variable named `lg` or create it from the `Server` instance. Preload context with [`lg.With`](https://pkg.go.dev/log/slog#With).
|
||||
- Pass logger instances to functions as a variable right after the context argument.
|
||||
- Do not log messages with a level above `Debug` unless the condition being logged is important for administrators to know.
|
||||
- Administrators have configured fail2ban pipelines on Anubis' logging output. Keep this in mind when changing any aspect of any log line.
|
||||
- Be conservative in what you send but liberal in what you accept.
|
||||
- Use [table-driven tests](https://go.dev/wiki/TableDrivenTests) when writing test code.
|
||||
- Use [`t.Helper()`](https://pkg.go.dev/testing#T.Helper) in helper code (setup/teardown scaffolding).
|
||||
- Use [`t.Cleanup()`](https://pkg.go.dev/testing#T.Cleanup) to tear down per-test or per-suite scaffolding.
|
||||
|
||||
### Configuration parsing
|
||||
|
||||
The configuration file is the main interface administrators have into Anubis. Keep these things in mind when adding features to the configuration file:
|
||||
|
||||
- Return all configuration errors at once from validators (`Valid() error` methods that return many errors at once with `errors.Join`) so administrators can fix all their configuration problems at once.
|
||||
- Enumerations should use strong types with validation logic for parsing remote input.
|
||||
- All configuration values should have both `json` and `yaml` struct tags set.
|
||||
- Use pointer values for optional configuration values.
|
||||
|
||||
### TypeScript
|
||||
|
||||
Please follow these guidelines:
|
||||
|
||||
- Prefer writing all front-end code in TypeScript. It is mostly there to ensure that development is done correctly.
|
||||
- Try to avoid JavaScript features newer than Chrome 75 unless you have a polyfill for backwards compatibility.
|
||||
- Keep functions small.
|
||||
- Use `const` by default and `let` if values need to change.
|
||||
- Make the code as unambiguous as possible.
|
||||
|
||||
### HTML Templates
|
||||
|
||||
Anubis uses [templ](https://templ.guide) for generating HTML on the server.
|
||||
|
||||
- Running `go generate` or `npm run assets` must regenerate HTML templates.
|
||||
- Templates receive typed Go parameters.
|
||||
- Templates are for presentation only. Any business logic belongs in Go, not templ.
|
||||
|
||||
## Commit Messages
|
||||
|
||||
Commit messages follow the [**Conventional Commits**](https://www.conventionalcommits.org/en/v1.0.0/) format:
|
||||
|
||||
```text
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
**Types**: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
|
||||
|
||||
- Avoid breaking changes when possible. If you must introduce a breaking change, add `!` after the type/scope and include `BREAKING CHANGE:` with the reason for the breaking change in the bottom of your commit message.
|
||||
- Keep descriptions concise, imperative, lowercase, and without trailing punctuation.
|
||||
- All git commits must include a [Developer Certificate of Origin](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin). TL;DR: `git commit --signoff`.
|
||||
|
||||
Mark commits as closing or fixing issues in trailers. For example:
|
||||
|
||||
```text
|
||||
Closes: #1234
|
||||
Fixes: #1234
|
||||
Replaces: #1234
|
||||
Ref: TecharoHQ/yeet#4
|
||||
```
|
||||
|
||||
## PR Checklist
|
||||
|
||||
When you are ready to send your contribution as a pull request, please do the following:
|
||||
|
||||
- Add description of changes to the `[Unreleased]` section of `docs/docs/CHANGELOG.md`.
|
||||
- Add test cases for bug fixes and behavior changes.
|
||||
- Add a [smoke test](./smoke-tests.mdx) if applicable.
|
||||
- Run integration tests: `npm run test:integration`.
|
||||
- All commits must have [verified (signed) signatures](./signed-commits.md).
|
||||
@@ -1,8 +1,4 @@
|
||||
{
|
||||
"label": "Developer guides",
|
||||
"position": 50,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "Guides and suggestions to make Anubis development go smoothly for everyone."
|
||||
}
|
||||
"position": 50
|
||||
}
|
||||
@@ -1,13 +1,31 @@
|
||||
# AI Coding Policy
|
||||
|
||||
At some level it would be nice to be able to have the following AI coding policy from an ideological standpoint:
|
||||
The Anubis repository has `AGENTS.md` and `CLAUDE.md` files in it. These files are there to point AI agent tools at the [contribution guidelines](./CONTRIBUTING.md) and to add the following text to context windows:
|
||||
|
||||
> Anubis does not accept code made primarily with the use of agentic AI tools such as Claude Code, Gemini CLI, GitHub Copilot, Zed, OpenCode, or any other similar tools. Please do not use them when contributing to this repo.
|
||||
## Attribution Requirements
|
||||
|
||||
However, I'd be in violation by doing this because I have knowingly committed minor bits of code to the Anubis repo that were generated by AI tools (mostly things for smoke tests).
|
||||
AI agents must disclose what tool and model they are using in the "Assisted-by" commit footer:
|
||||
|
||||
As such, Anubis is taking more of a centrist approach with regards to AI coding tools: regardless of what tool you use to make contributions to Anubis, when you sign off your code, you are taking responsibility for what you commit. You are also expected to understand what you are changing, what the implications are, and all other relevant factors.
|
||||
```text
|
||||
Assisted-by: [Model Name] via [Tool Name]
|
||||
```
|
||||
|
||||
If you use AI coding tools for a majority of your committed work, you MUST disclose it with [the `Assisted-by` footer](https://xeiaso.net/notes/2025/assisted-by-footer/). The Anubis maintainers will be using tooling that looks for these footers and will prioritize scrutiny and level of attention appropriately.
|
||||
Example:
|
||||
|
||||
In order to ensure compliance with this policy, language has been placed in `AGENTS.md` and `CLAUDE.md` to entice AI coding tools to add these footers.
|
||||
```text
|
||||
Assisted-by: GLM 4.6 via Claude Code
|
||||
```
|
||||
|
||||
This is here intentionally so that low-effort AI agent use is detected. This makes AI agents tattle on themselves.
|
||||
|
||||
## Guidelines
|
||||
|
||||
If your use of AI agent tools is largely respectful of the fact that maintainers have limited time for review, you will likely not run into issues.
|
||||
|
||||
We kindly ask the following:
|
||||
|
||||
- Pull requests that contain commits with this metadata attached will have their reviews be deprioritized to make room for human authored work.
|
||||
- People that abuse the system with a flood of low-quality contributions ("AI slop") will be banned upon their first infraction.
|
||||
- Please understand the actions and implications of every contribution you make, regardless of what tools were used in its creation.
|
||||
- Please do not put direct AI agent output in documentation or error messages.
|
||||
- If you really are going to submit an AI-authored PR, please make sure that your code has sufficient test coverage. Look into skills such as [go-table-driven-tests](https://www.skills.sh/tigrisdata/skills/go-table-driven-tests).
|
||||
@@ -1,45 +1,55 @@
|
||||
---
|
||||
title: Building Anubis without Docker
|
||||
title: Packaging Anubis
|
||||
---
|
||||
|
||||
Anubis is a web application written in Go with components in JavaScript. Packaging it should be similar to other applications with the same constraints.
|
||||
|
||||
:::note
|
||||
|
||||
These instructions may work, but for right now they are informative for downstream packagers more than they are ready-made instructions for administrators wanting to run Anubis on their servers. Pre-made binary package support is being tracked in [#156](https://github.com/TecharoHQ/anubis/issues/156).
|
||||
Please do not sidestep the build logic shipped by Anubis. We assume that the build logic shipped by Anubis is run. Any deviations from the semantics of this build logic may result in bugs that we will be blamed for. Please make our lives easier by not reinventing the wheel.
|
||||
|
||||
:::
|
||||
|
||||
## Entirely from source
|
||||
|
||||
If you are doing a build entirely from source, here's what you need to do:
|
||||
In order to build a production-ready binary of Anubis, you need the following packages in your environment:
|
||||
|
||||
:::info
|
||||
- [Go](https://go.dev) at least version 1.27.3
|
||||
- [esbuild](https://esbuild.github.io/)
|
||||
- [Rust and Cargo](https://rust-lang.org) at least version 1.80 with the [wasm32-unknown-unknown](https://doc.rust-lang.org/rustc/platform-support/wasm32-unknown-unknown.html) target installed
|
||||
- [Node.JS & NPM](https://nodejs.org/en) (latest LTS)
|
||||
- `gzip`
|
||||
- `zstd`
|
||||
- `brotli`
|
||||
- Optionally: [Wasmtime](https://wasmtime.dev/) or [binaryen version 130](https://github.com/WebAssembly/binaryen/releases#release-version_130).
|
||||
|
||||
If you maintain a package for Anubis v1.15.x or older, you will need to update your package build. You may want to use one of the half-baked tarballs if your distro/environment of choice makes it difficult to use npm.
|
||||
:::note
|
||||
|
||||
The binaryen version match must be exact. If it is not met, then Anubis' build system will fall back to a bundled version. If neither Wasmtime or binaryen version 130 are installed, Anubis will fall back to using a bootstrap compiler to run these required tools.
|
||||
|
||||
:::
|
||||
|
||||
### Tools needed
|
||||
Anubis does not require a C compiler to build, meaning it is fully compatible with cross-compilation.
|
||||
|
||||
In order to build a production-ready binary of Anubis, you need the following packages in your environment:
|
||||
:::note
|
||||
|
||||
- [Go](https://go.dev) at least version 1.24 - the programming language that Anubis is written in
|
||||
- [esbuild](https://esbuild.github.io/) - the JavaScript bundler Anubis uses for its production JS assets
|
||||
- [Node.JS & NPM](https://nodejs.org/en) - manages some build dependencies
|
||||
- `gzip` - compresses production JS (part of coreutils)
|
||||
- `zstd` - compresses production JS
|
||||
- `brotli` - compresses production JS
|
||||
|
||||
To upgrade your version of Go without system package manager support, install `golang.org/dl/go1.24.2` (this can be done from any version of Go):
|
||||
To upgrade your version of Go without system package manager support, install `golang.org/dl/go1.27.3` (this can be done from any version of Go):
|
||||
|
||||
```text
|
||||
go install golang.org/dl/go1.24.2@latest
|
||||
go1.24.2 download
|
||||
go install golang.org/dl/go1.27.3@latest
|
||||
go1.27.3 download
|
||||
```
|
||||
|
||||
Then make a symbolic link from `go1.27.3` to `go` in your `$PATH`.
|
||||
|
||||
:::
|
||||
|
||||
### Install dependencies
|
||||
|
||||
```text
|
||||
make deps
|
||||
npm ci
|
||||
go mod download
|
||||
cargo fetch
|
||||
```
|
||||
|
||||
This will download Go and NPM dependencies.
|
||||
@@ -47,7 +57,7 @@ This will download Go and NPM dependencies.
|
||||
### Building static assets
|
||||
|
||||
```text
|
||||
make assets
|
||||
npm run assets
|
||||
```
|
||||
|
||||
This will build all static assets (CSS, JavaScript) for distribution.
|
||||
@@ -55,12 +65,10 @@ This will build all static assets (CSS, JavaScript) for distribution.
|
||||
### Building Anubis to the `./var` folder
|
||||
|
||||
```text
|
||||
make build
|
||||
npm run build
|
||||
```
|
||||
|
||||
From this point it is up to you to make sure that `./var/anubis` and `./var/robots2policy` end up in
|
||||
the right place. You may want to consult the `./run` folder for useful files such as a systemd unit
|
||||
and `anubis.env.default` file.
|
||||
From this point it is up to you to make sure that `./var/anubis` and `./var/robots2policy` end up in the right place. You may want to consult the `./run` folder for useful files such as a systemd unit and the `anubis.env.default` file. The default configuration file is in `./data/botPolicies.yaml`.
|
||||
|
||||
## "Pre-baked" tarball
|
||||
|
||||
@@ -77,7 +85,7 @@ When using this tarball, all you need to do is build `./cmd/anubis`:
|
||||
make prebaked-build
|
||||
```
|
||||
|
||||
Anubis will be built to `./var/anubis` and the robots2policy tool to `./var/robots2policy`.
|
||||
Anubis will be built to `./var/anubis` and the robots2policy tool to `./var/robots2policy`. Install these via your normal packaging process.
|
||||
|
||||
## Development dependencies
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
title: Code quality guidelines
|
||||
---
|
||||
|
||||
When submitting code to Anubis, please take the time to consider the fact that this project is security software. If things go bad, bots can pummel sites into oblivion. This is not ideal for uptime.
|
||||
|
||||
As such, code reviews will be a bit more strict than you have seen in other projects. This is not people trying to be mean, this is a side effect of taking the problem seriously.
|
||||
|
||||
When making code changes, try to do the following:
|
||||
|
||||
- If you're submitting a bugfix, add a test case for it
|
||||
- If you're changing the JavaScript, make sure the integration tests pass (`npm run test:integration`)
|
||||
|
||||
## Commit messages
|
||||
|
||||
Anubis follows the Go project's conventions for commit messages. In general, an ideal commit message should read like this:
|
||||
|
||||
```text
|
||||
path/to/folder: brief description of the change
|
||||
|
||||
If the change is subtle, has implementation consequences, or is otherwise
|
||||
not entirely self-describing: take the time to spell out why. If things
|
||||
are very subtle, please also amend the documentation accordingly
|
||||
```
|
||||
|
||||
The subject of a commit message should be the second half of the sentence "This commit changes the Anubis project to:". Here's a few examples:
|
||||
|
||||
- `disable DroneBL by default`
|
||||
- `port the challenge to WebAssembly`
|
||||
|
||||
The extended commit message is also your place to give rationale for a new feature. When maintainers are reviewing your code, they will use this to figure out if the burden from feature maintainership is worth the merge.
|
||||
@@ -0,0 +1,34 @@
|
||||
# Spellchecking
|
||||
|
||||
Anubis uses [CSpell](https://cspell.org/) to ensure words are spelled correctly. The project dictionary is at `.vscode/project-words.txt`.
|
||||
|
||||
## Manually testing spellchecking
|
||||
|
||||
To manually run spellchecking against the files you have modified before commit:
|
||||
|
||||
```sh
|
||||
npm run test:spelling
|
||||
```
|
||||
|
||||
## Adding words to the dictionary
|
||||
|
||||
To add a word to the project dictionary (eg: `${WORD}`), do the following:
|
||||
|
||||
### Append the word to the dictionary
|
||||
|
||||
```sh
|
||||
echo ${WORD} >> .vscode/project-words.txt
|
||||
```
|
||||
|
||||
### Sort the dictionary list
|
||||
|
||||
```sh
|
||||
npm run test:spelling:sort
|
||||
```
|
||||
|
||||
### Commit the results
|
||||
|
||||
```sh
|
||||
git add .vscode/project-words.txt
|
||||
git commit -sm "chore: spelling"
|
||||
```
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
title: Developer Guides
|
||||
---
|
||||
|
||||
Thank you for wanting to contribute to Anubis, the Web AI Firewall Utility that protects web applications from abusive scrapers! This guide is your cheat sheet to making sure your contributions meet standards and can be merged as soon as possible.
|
||||
|
||||
:::note
|
||||
|
||||
This program is mostly written by a single person in a basement in Canada. Sometimes issues and pull requests get missed. Please remember the human on the other end.
|
||||
|
||||
:::
|
||||
|
||||
## Links
|
||||
|
||||
- [AI coding policy](./ai-coding-policy.md)
|
||||
- [Code of Conduct](./CODE_OF_CONDUCT.md)
|
||||
- [Contribution guidelines](./CONTRIBUTING.md)
|
||||
- [Local development](./local-dev.md)
|
||||
- [Packaging Anubis](./building-anubis.md)
|
||||
- [Signed commits](./signed-commits.md)
|
||||
- [Smoke tests](./smoke-tests.mdx)
|
||||
- [Spellchecking](./cspell.md)
|
||||
@@ -17,6 +17,8 @@ Anubis requires the following tools to be installed to do local development:
|
||||
- [Go](https://go.dev) - the programming language that Anubis is written in
|
||||
- [esbuild](https://esbuild.github.io/) - the JavaScript bundler Anubis uses for its production JS assets
|
||||
- [Node.JS & NPM](https://nodejs.org/en) - manages some build dependencies
|
||||
- Optionally: [Wasmtime](https://wasmtime.dev/) - used to run the fallback vendored version of binaryen committed to this repository.
|
||||
- Optionally: [binaryen version 130](https://github.com/WebAssembly/binaryen/releases/tag/version_130) (exact match) - optimizes and compiles WebAssembly code so that it runs on all browsers Anubis supports.
|
||||
- `gzip` - compresses production JS (part of coreutils)
|
||||
- `zstd` - compresses production JS
|
||||
- `brotli` - compresses production JS
|
||||
@@ -64,27 +66,20 @@ DOCKER_REPO=registry.host/org/repo DOCKER_METADATA_OUTPUT_TAGS=registry.host/org
|
||||
|
||||
For more information, see [Building native packages is complicated](https://xeiaso.net/blog/2025/anubis-packaging/) and [#156: Debian, RPM, and binary tarball packages](https://github.com/TecharoHQ/anubis/issues/156).
|
||||
|
||||
Install `yeet`:
|
||||
|
||||
:::note
|
||||
|
||||
`yeet` will soon be moved to a dedicated TecharoHQ repository. This is currently done in a hacky way in order to get this ready for user feedback.
|
||||
|
||||
:::
|
||||
|
||||
```text
|
||||
go install within.website/x/cmd/yeet@v1.13.4
|
||||
```
|
||||
|
||||
Install the dependencies for Anubis:
|
||||
|
||||
```text
|
||||
npm ci
|
||||
go mod download
|
||||
```
|
||||
|
||||
Build the packages into `./var`:
|
||||
Build the static assets:
|
||||
|
||||
```text
|
||||
yeet
|
||||
npm run assets
|
||||
```
|
||||
|
||||
Build the packages into `./var/packages`:
|
||||
|
||||
```text
|
||||
go tool yeet --package-dest-dir ./var/packages
|
||||
```
|
||||
@@ -0,0 +1,112 @@
|
||||
# Smoke testing
|
||||
|
||||
Anubis has three types of tests:
|
||||
|
||||
1. Unit tests in `_test.go` files, which test individual parts of the Anubis code.
|
||||
2. Integration tests in package `internal/test`, which tests common scenarios that Anubis is used with.
|
||||
3. Smoke tests in `test`, which test server infrastructure commonly used with Anubis.
|
||||
|
||||
This guide helps you write a smoke test so you can make sure a given configuration is known to be supported because CI runs it constantly.
|
||||
|
||||
## What is a smoke test?
|
||||
|
||||
In Anubis, a smoke test is a folder with an executable file named `test.sh`. If the script returns exit code 0 (zero), it passed. If it returns any other exit code, it failed and is retried up to 10 (ten) times.
|
||||
|
||||
### Shell script (simple)
|
||||
|
||||
Here is an example smoke test that builds Anubis, points it to a simple HTTP endpoint, starts it up, and makes sure `curl` can reach that endpoint:
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env bash
|
||||
# test/example/test.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function cleanup() {
|
||||
pkill -P $$
|
||||
}
|
||||
|
||||
trap cleanup EXIT SIGINT
|
||||
|
||||
# Build static assets
|
||||
(cd ../.. && npm ci && npm run assets)
|
||||
|
||||
go tool anubis --help 2>/dev/null ||:
|
||||
|
||||
go run ../cmd/unixhttpd &
|
||||
|
||||
go tool anubis \
|
||||
--policy-fname ./anubis.yaml \
|
||||
--use-remote-address \
|
||||
--target=unix://$(pwd)/unixhttpd.sock &
|
||||
|
||||
backoff-retry node ./test.mjs
|
||||
```
|
||||
|
||||
```js
|
||||
// test.mjs
|
||||
|
||||
async function fetchData() {
|
||||
return fetch("http://localhost:8923/")
|
||||
.then((resp) => {
|
||||
if (resp.status !== 200) {
|
||||
throw new Error(`wanted status 200, got status: ${resp.status}`);
|
||||
}
|
||||
return resp;
|
||||
})
|
||||
.then((resp) => resp.text());
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const data = await fetchData();
|
||||
if (!data.includes("test.mjs")) {
|
||||
console.log(
|
||||
"HTML response did not include `test.mjs` file, meaning Anubis is blocking this test",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(data);
|
||||
console.log("All is well");
|
||||
process.exit(0);
|
||||
})();
|
||||
```
|
||||
|
||||
### Docker compose (complicated)
|
||||
|
||||
Some tests may require starting up infrastructure with `docker compose`. If this is the case, create a `docker-compose.yaml` file with the needed infrastructure and build the Anubis Docker image with `build_anubis_ko`:
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env bash
|
||||
# test/example/test.sh
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
export VERSION=$GITHUB_COMMIT-test
|
||||
export KO_DOCKER_REPO=ko.local
|
||||
|
||||
set -u
|
||||
|
||||
source ../lib/lib.sh
|
||||
|
||||
build_anubis_ko
|
||||
|
||||
docker compose up -d
|
||||
|
||||
backoff-retry node ./test.mjs
|
||||
```
|
||||
|
||||
## Registering the test in CI
|
||||
|
||||
All smoke tests are registered in matrix subjobs in `.github/workflows/smoke-tests.yml`. This allocates and uses a new CI worker per test. This appears slightly wasteful at first glance, however these tests are doing a lot of work that assumes port numbers in fiddly ways. It's easier to have dedicated machines for them than having to worry about sharing port numbers.
|
||||
|
||||
To add a test named `linear-search`:
|
||||
|
||||
```diff
|
||||
- healthcheck
|
||||
- i18n
|
||||
- lightpanda
|
||||
+ - linear-search
|
||||
- log-file
|
||||
- nginx
|
||||
- palemoon/amd64
|
||||
```
|
||||
@@ -32,11 +32,23 @@ Anubis is brought to you by sponsors and donors like:
|
||||
<a href="https://databento.com/?utm_source=anubis&utm_medium=sponsor&utm_campaign=anubis">
|
||||
<img src="/img/sponsors/databento-logo.webp" alt="Databento" height="64" />
|
||||
</a>
|
||||
<a href="https://spur.us/?utm_source=github&utm_medium=referral&utm_campaign=anubis-readme">
|
||||
<img src="/img/sponsors/spur-logo.webp" alt="Spur Intelligence" height="64" />
|
||||
</a>
|
||||
|
||||
<p>
|
||||
<a href="https://synthient.com/?utm_source=anubis">
|
||||
<img src="/img/sponsors/synthient-banner.webp" alt="Synthient" height="128" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
### Gold Tier
|
||||
|
||||
<a href="https://distrust.co?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/distrust-logo.webp" alt="Distrust" height="64" />
|
||||
<a href="https://www.unipromos.com/?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/unipromos.webp" alt="Uvensys" height="64" />
|
||||
</a>
|
||||
<a href="https://uvensys.de/?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/uvensys.webp" alt="Uvensys" height="64" />
|
||||
</a>
|
||||
<a href="https://about.gitea.com?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/gitea-logo.webp" alt="Gitea" height="64" />
|
||||
@@ -74,13 +86,22 @@ Anubis is brought to you by sponsors and donors like:
|
||||
height="64"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://fabulous.systems/">
|
||||
<a href="https://felsqualle.com">
|
||||
<img
|
||||
src="/img/sponsors/fabulous-systems.webp"
|
||||
alt="Cat eyes over the word Emma in a serif font"
|
||||
src="/img/sponsors/felsqualle-logo.webp"
|
||||
alt="The word felsqualle in dripping pixel-art letters"
|
||||
height="64"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://dd-wrt.com/">
|
||||
<img src="/img/sponsors/ddwrt-logo.webp" alt="embeDD GmbH" height="64" />
|
||||
</a>
|
||||
<a href="https://www.qwertiko.de?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/qwertiko-logo.webp" alt="Qwertiko" height="64" />
|
||||
</a>
|
||||
<a href="https://wenet.pl/?utm_campaign=github&utm_medium=referral&utm_content=anubis">
|
||||
<img src="/img/sponsors/wenet-logo.webp" alt="Wenet" height="64" />
|
||||
</a>
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -100,19 +121,19 @@ For live chat, please join the [Patreon](https://patreon.com/cadey) or join [Git
|
||||
|
||||
## Star History
|
||||
|
||||
<a href="https://www.star-history.com/#TecharoHQ/anubis&Date">
|
||||
<a href="https://www.star-history.com/?type=date&repos=TecharoHQ%2Fanubis">
|
||||
<picture>
|
||||
<source
|
||||
media="(prefers-color-scheme: dark)"
|
||||
srcSet="https://api.star-history.com/svg?repos=TecharoHQ/anubis&type=Date&theme=dark"
|
||||
srcset="https://api.star-history.com/chart?repos=TecharoHQ/anubis&type=date&theme=dark&legend=top-left&sealed_token=NijaGjH7lyOz9iUXAO-9vs88h2o0C6cmPKIfKSpvhUrnzP0KtL93_9gsGM0D66Miq8f1b9cynl8o1of6EhFiUQK-uBZqAQqxs6dhM8tcb5Q-YTicObjlrv5RpQUkEu0nVRJ6eoU208uQzm0yNfeOkMcBgvxqPmSVdoUTNB3wjfJodZlPzopX7oVp3aXO"
|
||||
/>
|
||||
<source
|
||||
media="(prefers-color-scheme: light)"
|
||||
srcSet="https://api.star-history.com/svg?repos=TecharoHQ/anubis&type=Date"
|
||||
srcset="https://api.star-history.com/chart?repos=TecharoHQ/anubis&type=date&legend=top-left&sealed_token=NijaGjH7lyOz9iUXAO-9vs88h2o0C6cmPKIfKSpvhUrnzP0KtL93_9gsGM0D66Miq8f1b9cynl8o1of6EhFiUQK-uBZqAQqxs6dhM8tcb5Q-YTicObjlrv5RpQUkEu0nVRJ6eoU208uQzm0yNfeOkMcBgvxqPmSVdoUTNB3wjfJodZlPzopX7oVp3aXO"
|
||||
/>
|
||||
<img
|
||||
alt="Star History Chart"
|
||||
src="https://api.star-history.com/svg?repos=TecharoHQ/anubis&type=Date"
|
||||
src="https://api.star-history.com/chart?repos=TecharoHQ/anubis&type=date&legend=top-left&sealed_token=NijaGjH7lyOz9iUXAO-9vs88h2o0C6cmPKIfKSpvhUrnzP0KtL93_9gsGM0D66Miq8f1b9cynl8o1of6EhFiUQK-uBZqAQqxs6dhM8tcb5Q-YTicObjlrv5RpQUkEu0nVRJ6eoU208uQzm0yNfeOkMcBgvxqPmSVdoUTNB3wjfJodZlPzopX7oVp3aXO"
|
||||
/>
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
@@ -1,24 +1,45 @@
|
||||
# Frequently Asked Questions
|
||||
|
||||
## Why can't you just put details about the proof of work challenge into the challenge page so I don't need to run JavaScript?
|
||||
## Why are challenge details not embedded into the human-readable part of challenge pages?
|
||||
|
||||
A common question is something along the lines of "why can't you give me a shell script to run the challenge on my laptop so that I don't have to enable JavaScript". Malware has been known to show an interstitial that [asks the user to paste something into their run box on Windows](https://www.malwarebytes.com/blog/news/2025/03/fake-captcha-websites-hijack-your-clipboard-to-install-information-stealers), which will then make that machine a zombie in a botnet.
|
||||
Many people have asked why the challenge details are not embedded into challenge pages so they do not have to run JavaScript. There are many instances where malware [asks the user to paste something into their run box on Windows](https://www.malwarebytes.com/blog/news/2025/03/fake-captcha-websites-hijack-your-clipboard-to-install-information-stealers). This malware adds your computer to a botnet, steal information, or encrypt all file contents for a ransom.
|
||||
|
||||
It would be in very bad taste to associate a security product such as Anubis with behavior similar to what malware uses. This would destroy user trust in the product and potentially result in reputational damage for the contributors. When at all possible, we want to avoid this happening.
|
||||
In order for Anubis' protection to be effective, Anubis must not give users instructions akin to this kind of malware. Anubis does not require user input and must function automatically via JavaScript. Anubis must not require users to paste code into terminals or run boxes to pass challenges.
|
||||
|
||||
Technically inclined users are easily able to understand how the proof of work check works by either reading the JavaScript on the page or [reading the source code of the JavaScript program](https://github.com/TecharoHQ/anubis/tree/main/web/js). Please note that the format of the challenges and the algorithms used to solve them are liable to change without notice and are not considered part of the public API of Anubis. When such a change occurs, this will break your workarounds.
|
||||
Technically inclined users are able to understand how the proof of work challenge works and write their own solver. The format of the challenges and algorithms used are liable to change without notice. Any details about challenges are not part of the public API of Anubis. When such a change occurs, those workarounds will break.
|
||||
|
||||
If [sufficient funding is raised](https://github.com/TecharoHQ/anubis/discussions/278), a browser extension that packages the proof of work checks and looks for Anubis challenge pages to solve them will be created.
|
||||
## Why does Anubis use Web Workers?
|
||||
|
||||
## Why does Anubis use [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to do its proof of work challenge?
|
||||
Anubis uses [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to execute challenge logic for two main reasons:
|
||||
|
||||
Anubis uses [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) to do its proof of work challenge for two main reasons:
|
||||
1. Browsers block the main rendering thread when JavaScript executes. The challenge logic comprises many blocking math operations. Executing challenge logic on the main thread can cause browsers to hang and not respond to user input. Running challenge logic in Web Workers fixes this.
|
||||
2. Web Workers enable executing JavaScript code across multiple CPU threads. Multithreading enables Anubis challenges to run in parallel across all system cores, making the challenge page complete as fast as possible. Anubis challenges scale horizontally because modern hardware advancements are mostly around parallelism.
|
||||
|
||||
1. The proof of work operation is a lot of serially blocking calls. If you do serially blocking calls in JavaScript, some browsers will hang and not respond to user input. This is bad user experience. Using a Web Worker allows the browser to do this computation in the background so your browser will not hang.
|
||||
2. Web Workers allow you to do multithreaded execution of JavaScript code. This lets Anubis run its checks in parallel across all your system cores so that the challenge can complete as fast as possible. In the last decade, most CPU advancements have come from making cores and code extremely parallel. Using Web Workers lets Anubis take advantage of your hardware as much as possible so that the challenge finishes as fast as possible.
|
||||
|
||||
If you use a browser extension such as [JShelter](https://jshelter.org/), you will need to [modify your JShelter configuration](./known-broken-extensions.md#jshelter) to allow Anubis' proof of work computation to complete.
|
||||
If you use a browser extension such as [JShelter](https://jshelter.org/), you will need to [modify settings](./known-broken-extensions.md#jshelter) to allow challenges to complete.
|
||||
|
||||
## Does Anubis mine Bitcoin?
|
||||
|
||||
No. Anubis does not mine Bitcoin or any other cryptocurrency.
|
||||
|
||||
## I disabled Just-in-time compilation in my browser. Why is Anubis slow?
|
||||
|
||||
Anubis challenges run many complicated math operations in a tight loop. [Just-in-time (JIT) compilation](https://en.wikipedia.org/wiki/Just-in-time_compilation) optimizes JavaScript execution by a significant degree. The JIT enables browsers to execute code as if it was natively written for your computer. Anubis' JavaScript challenges benefit from JIT complication, running much faster with the JIT enabled.
|
||||
|
||||
Without the JIT enabled, all JavaScript programs run through a slow interpreter. This slow interpreter translates single lines of JavaScript into many dozens of machine instructions instead of JIT-ing down to single machine instructions. It takes longer to emulate the JavaScript environment to add numbers than it does to have the JIT add the numbers directly.
|
||||
|
||||
Some users choose to disable the JIT as a security hardening measure. Depending on threat profiles, this may be a reasonable action. Keep in mind that disabling the browser feature that makes Anubis fast makes Anubis slow.
|
||||
|
||||
If you have disabled the JIT and find Anubis checks slow, please re-enable the JIT. There is no way for Anubis to work around you choosing to disable the browser feature that makes Anubis fast.
|
||||
|
||||
## What versions of browsers does Anubis support?
|
||||
|
||||
Anubis supports at least the following:
|
||||
|
||||
- Google Chrome/Chromium 75 and later
|
||||
- Mozilla Firefox 120 and later
|
||||
- Safari 10 and later
|
||||
- Pale Moon 33 and later
|
||||
|
||||
Anubis may support other browsers, but development prioritizes the above browsers. If you discover compatibility issues, please file a bug report with OS, browser, and hardware model number information.
|
||||
|
||||
If you work on a browser that does not work with Anubis and want us to automatically test it, please [submit a functional test](https://github.com/TecharoHQ/anubis/tree/main/test/palemoon/amd64) so that we know of failures instantly.
|
||||
@@ -2,7 +2,7 @@
|
||||
title: List of known browser extensions that can break Anubis
|
||||
---
|
||||
|
||||
This page contains a list of all of the browser extensions that are known to break Anubis' functionality and their associated GitHub issues, along with instructions on how to work around the issue.
|
||||
This page outlines browser extensions known to break Anubis' client code and workarounds.
|
||||
|
||||
## [JShelter](https://jshelter.org/)
|
||||
|
||||
@@ -12,21 +12,22 @@ This page contains a list of all of the browser extensions that are known to bre
|
||||
| GitHub issue | https://github.com/TecharoHQ/anubis/issues/25 |
|
||||
| Be aware of | [What are Web Workers, and what are the threats that I face?](https://jshelter.org/faq/#what-are-web-workers-and-what-are-the-threats-that-i-face) |
|
||||
|
||||
### Workaround steps (recommended):
|
||||
### Workaround 1
|
||||
|
||||
1. Click on the JShelter badge icon (typically in the toolbar next to your navigation bar; if you cannot locate the icon, see [this question](https://jshelter.org/faq/#can-i-see-a-jshelter-badge-icon-next-to-my-navigation-bar-i-want-to-interact-with-the-extension-easily-and-avoid-going-through-settings)).
|
||||
Disable WebWorker protection for the given site.
|
||||
|
||||
1. Click on the JShelter badge icon.
|
||||
2. Expand JavaScript Shield settings by clicking on the `Modify` button.
|
||||
3. Click on the `Detail tweaks of JS shield for this site` button.
|
||||
4. Click and drag the `WebWorker` slider to the left until `Remove` is replaced by the `Unprotected`.
|
||||
5. Refresh the page, for example, by clicking on the `Refresh page` button at the top of the JShelter pop up window.
|
||||
6. You might want to restore the Worker settings once you go through the challenge.
|
||||
4. Click and drag the `WebWorker` slider to the left, showing `Unprotected`.
|
||||
5. Refresh the page.
|
||||
|
||||
### Workaround steps (alternative if you do not want to dig in JShelter's pop up):
|
||||
### Workaround 2
|
||||
|
||||
1. Click on the JShelter badge icon (typically in the toolbar next to your navigation bar; if you cannot locate the icon, see [this question](https://jshelter.org/faq/#can-i-see-a-jshelter-badge-icon-next-to-my-navigation-bar-i-want-to-interact-with-the-extension-easily-and-avoid-going-through-settings)).
|
||||
1. Click on the JShelter badge icon.
|
||||
2. Expand JavaScript Shield settings by clicking on the `Modify` button.
|
||||
3. Choose "Turn JavaScript Shield off"
|
||||
4. Refresh the page, for example, by clicking on the `Refresh page` button at the top of the JShelter pop up window.
|
||||
4. Refresh the page.
|
||||
|
||||
:::note
|
||||
|
||||
@@ -34,7 +35,7 @@ Taking these actions will remove all protections of JavaScript Shield for all pa
|
||||
|
||||
:::
|
||||
|
||||
### Workaround steps (alternative if you do not like JShelter's pop up):
|
||||
### Workaround 3
|
||||
|
||||
1. Open JShelter extension settings
|
||||
2. Click on JS Shield details
|
||||
|
||||
@@ -38,10 +38,8 @@ This page contains a non-exhaustive list with all websites using Anubis.
|
||||
- https://squirreljme.cc/
|
||||
- https://superlove.sayitditto.net/
|
||||
- https://svnweb.freebsd.org/
|
||||
- https://trac.ffmpeg.org/
|
||||
- https://tumfatig.net/
|
||||
- https://wiki.archlinux.org/
|
||||
- https://wiki.dolphin-emu.org/
|
||||
- https://wiki.freepascal.org/
|
||||
- https://wiki.koha-community.org/
|
||||
- https://www.cfaarchive.org/
|
||||
@@ -53,6 +51,11 @@ This page contains a non-exhaustive list with all websites using Anubis.
|
||||
- https://bbs.archlinux32.org/
|
||||
- https://bugs.archlinux32.org/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>Dolphin Emulator</summary>
|
||||
- https://forums.dolphin-emu.org/
|
||||
- https://wiki.dolphin-emu.org/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>Duke University</summary>
|
||||
- https://repository.duke.edu/
|
||||
@@ -60,6 +63,11 @@ This page contains a non-exhaustive list with all websites using Anubis.
|
||||
- https://find.library.duke.edu/
|
||||
- https://nicholas.duke.edu/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>FFmpeg</summary>
|
||||
- https://git.ffmpeg.org/
|
||||
- https://trac.ffmpeg.org/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>Forschungszentrum Jülich</summary>
|
||||
- https://juser.fz-juelich.de/
|
||||
@@ -112,11 +120,9 @@ This page contains a non-exhaustive list with all websites using Anubis.
|
||||
- https://git.kernel.org/
|
||||
- https://lore.kernel.org/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>The United Nations</summary>
|
||||
- https://policytoolbox.iiep.unesco.org/
|
||||
</details>
|
||||
- <details>
|
||||
<summary>Valve Corporation</summary>
|
||||
- https://developer.valvesoftware.com/wiki/Main_Page
|
||||
- https://wiki.teamfortress.com/wiki/Main_Page
|
||||
- https://gitlab.steamos.cloud/
|
||||
</details>
|
||||
@@ -2,8 +2,8 @@
|
||||
title: Why is Anubis showing up on a website?
|
||||
---
|
||||
|
||||
You are seeing Anubis because the administrator of that website has set up [Anubis](https://github.com/TecharoHQ/anubis) to protect the server against the scourge of [AI companies aggressively scraping websites](https://thelibre.news/foss-infrastructure-is-under-attack-by-ai-companies/). This can and does cause downtime for the websites, which makes their resources inaccessible for everyone.
|
||||
Anubis shows up on a website because the administrator set up Anubis to protect their server. There are many abusive scrapers [destroying websites with too many requests](https://thelibre.news/foss-infrastructure-is-under-attack-by-ai-companies/), making servers collapse under the pressure. This causes downtime for the websites, making resources inaccessible for everyone.
|
||||
|
||||
Anubis is a compromise. Anubis uses a [proof-of-work](/docs/design/why-proof-of-work) scheme in the vein of [Hashcash](https://en.wikipedia.org/wiki/Hashcash), a proposed proof-of-work scheme for reducing email spam. The idea is that at individual scales the additional load is ignorable, but at mass scraper levels it adds up and makes scraping much more expensive.
|
||||
Anubis is a web application firewall that uses heuristics to discover suspect clients and present them a simple challenge. The idea behind these challenges is that they are easy to solve for individuals, but prohibitively expensive to solve en masse for abusive scraping.
|
||||
|
||||
Ultimately, this is a hack whose real purpose is to give a "good enough" placeholder solution so that more time can be spent on fingerprinting and identifying headless browsers (EG: via how they do font rendering) so that the challenge proof of work page doesn't need to be presented to users that are much more likely to be legitimate.
|
||||
Research and development continues such that Anubis shows challenge pages less often. Please keep updated with Anubis' development to learn more about the progress in this matter.
|
||||
@@ -74,6 +74,8 @@ bots:
|
||||
weight:
|
||||
adjust: -5
|
||||
|
||||
- import: (data)/clients/small-internet-browsers/*.yaml
|
||||
|
||||
# The weight thresholds for when to trigger individual challenges. Any
|
||||
# CHALLENGE will take precedence over this.
|
||||
#
|
||||
@@ -118,8 +120,8 @@ thresholds:
|
||||
# This challenge proves the client can run a webapp written with Preact.
|
||||
# The preact webapp simply loads, calculates the SHA-256 checksum of the
|
||||
# challenge data, and forwards that to the client.
|
||||
algorithm: preact
|
||||
difficulty: 1
|
||||
algorithm: sha256
|
||||
difficulty: 16
|
||||
- name: mild-proof-of-work
|
||||
expression:
|
||||
all:
|
||||
@@ -128,19 +130,23 @@ thresholds:
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
# https://anubis.techaro.lol/docs/admin/configuration/challenges/proof-of-work
|
||||
algorithm: fast
|
||||
difficulty: 2 # two leading zeros, very fast for most clients
|
||||
algorithm: argon2id
|
||||
difficulty: 4 # two leading zeros, very fast for most clients
|
||||
# For clients that are browser like and have gained many points from custom rules
|
||||
- name: extreme-suspicion
|
||||
expression: weight >= 30
|
||||
action: CHALLENGE
|
||||
challenge:
|
||||
# https://anubis.techaro.lol/docs/admin/configuration/challenges/proof-of-work
|
||||
algorithm: fast
|
||||
difficulty: 4
|
||||
algorithm: argon2id
|
||||
difficulty: 6
|
||||
|
||||
dnsbl: false
|
||||
|
||||
logging:
|
||||
sink: stdio
|
||||
level: "WARN"
|
||||
|
||||
impressum:
|
||||
footer: |
|
||||
This website is hosted by Techaro. If you have any complaints or notes about the service, please contact <a href="mailto:support@techaro.lol">support@techaro.lol</a> and we will assist you as soon as possible.
|
||||
@@ -202,3 +208,15 @@ store:
|
||||
backend: bbolt
|
||||
parameters:
|
||||
path: /xe/data/anubis/data.bdb
|
||||
|
||||
## Honeypot configuration
|
||||
honeypot:
|
||||
## If not set, Anubis will assume you meant `true`.
|
||||
enabled: true
|
||||
## Currently the only supported implementation is the naive method.
|
||||
## See https://anubis.techaro.lol/docs/admin/honeypot/overview#implementation-notes for more information
|
||||
implementation: naive
|
||||
## Setting ip_log_file makes Anubis log IP addresses that hit honeypot URLs to a file.
|
||||
## Anubis writes to this file either once per minute or after Anubis records 32
|
||||
## kilobytes of IP addresses, whichever happens first.
|
||||
#ip_log_file: ./var/honeypot.addrs
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1018 B |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 5.7 KiB |