antsilkv0.1
180 malicious requests blocked & counting

Security middleware
that installs in two lines.

antsilk sits in front of your FastAPI / Starlette / Litestar app and does the boring half of web security for you — rate limiting, IP threat-intel, and SQLi / XSS / path-traversal scanning on every request. Blocks land as structured events in a local SQLite ledger.

$ pip install antsilk
See how it worksStar on GitHub
< 1ms
p99 overhead
0
runtime deps
4
defense layers
98%
test coverage

Live ledger

Watch it block attacks in real time.

A live tail of antsilk's SQLite ledger, streamed from Supabase. Every row is a request that never reached a route handler.

window: Jul 17Jul 24

requests blocked

0live

aggregate hits recorded in antsilk's SQLite ledger

threat-intel
18
rate limit
25
SQL injection
32
XSS
26
path traversal
24
bad header
21
bad token
34
antsilk_events.db — tail -f403 / 429 · newest first
40d ago403GETthreat-intel/xmlrpc.php
40d ago403POSTbad token/api/webhook
40d ago403POSTbad token/api/webhook
40d ago403POSTbad token/api/webhook
41d ago403GETXSS/comment?msg=%3Cscript%3E
41d ago403GETbad header/
41d ago403GETSQL injection/search?q=%27%3B%20DROP%20TABLE
41d ago403POSTbad token/api/v1/orders
41d ago429POSTrate limit/api/search
41d ago403GETthreat-intel/wp-login.php
41d ago403GETbad header/admin

Install

Two lines. A real WAF on day one.

Install the package, add the middleware. Defaults are tuned to be safe in production from the very first request — 60 req/min per IP, threat-intel from FireHOL + Spamhaus, full pattern scanning.

1 · install
$ pip install antsilk

Zero runtime dependencies. Standard library only — nothing extra to audit, nothing to break your lockfile.

2 · wire it up
from fastapi import FastAPIfrom antsilk import AntsilkMiddleware app = FastAPI()app.add_middleware(AntsilkMiddleware)

Restart your server. Every incoming request is now inspected, rate-limited, and logged.

Defense layers

Four checks, one middleware, zero services.

Each request runs the gauntlet cheapest-check-first. The route never sees anything that fails. No external calls, no runtime dependencies.

403

IP threat-intel

Traffic from IPs on FireHOL Level 1 or Spamhaus DROP is dropped before it touches your route. Feeds refresh every 6 hours.

429

Rate limiting

Per-IP token bucket, 60 req/min by default. Absorbs credential-stuffing and scraper bursts without a Redis dependency.

403

Pattern scanner

SQLi, XSS and path-traversal regex over the URL, query string and non-UA headers. Tuned to catch the payloads scanners actually send.

403

Header sanity

Missing User-Agent, known scanner signatures (sqlmap, nikto, masscan, nmap) and malformed cookies get bounced structurally.

log

SQLite ledger

Every block writes a row — timestamp, IP, path, rule, severity, raw UA — to a local WAL-mode SQLite file. PII never leaves your host.

config

Per-route overrides

Webhooks skip rate limiting, chatbot endpoints skip the pattern scan, payment routes skip threat-intel — all via one RouteRule.

How it works

One pipeline, front of every route.

Internet
incoming traffic
AntsilkMiddleware< 1ms
threat-intelIP blocklists
rate limitertoken bucket
pattern scanSQLi · XSS · traversal
header checkUA · cookies
Route handlers
clean requests pass
events.db
blocks logged (SQLite)
01

Inspect every request

Threat-intel runs first because it's cheapest, then rate limit, then the regex scan over path / query / non-UA headers, then header sanity. The route never sees a blocked request.

02

Record what got stopped

Every block writes one row to a local SQLite ledger — timestamp, IP, path, rule, severity, status, raw User-Agent. Per-IP details stay on your host.

03

Carve out routes that need it

Webhooks bypass rate limiting, comment endpoints bypass the pattern scan, payment routes bypass threat-intel — each via a single RouteRule dataclass.

Stop shipping unprotected routes.

Add a real WAF to your ASGI app in the time it takes to read this sentence.

$ pip install antsilk
View on GitHub