Skip to main content

Nemesis Shield — Sentinel SDK for Python (web/API/LLM behavioral protection). Learn your app's normal behavior, then block off-baseline requests in enforce mode. ASGI/WSGI/Django middleware + OpenAI/Anthropic/LangChain LLM guards.

Project description

nemesis-shield — Python SDK

Native Python SDK for Nemesis Shield. Computes a privacy-preserving request sketch locally, learns your app's normal behavior, and — in enforce modeblocks off-baseline requests (auth bypass, path traversal, scanners, unusual methods) before your views ever run. Positive-security: this app only ever behaves in these ways. Zero dependencies (stdlib only). Fail-open: if Nemesis is unreachable, your app is unaffected.

pip install nemesis-shield

One line per framework

FastAPI / Starlette (ASGI)

from nemesis_shield.asgi import SentinelMiddleware
app.add_middleware(SentinelMiddleware, token=os.environ["NEMESIS_TOKEN"])

Flask / any WSGI app

from nemesis_shield.wsgi import SentinelWSGI
app.wsgi_app = SentinelWSGI(app.wsgi_app, token=os.environ["NEMESIS_TOKEN"])

Django — add to settings.py and set NEMESIS_TOKEN in the environment:

MIDDLEWARE = ["nemesis_shield.django.SentinelDjango", *MIDDLEWARE]

Raw / anything — use the client directly:

from nemesis_shield import build_sketch
from nemesis_shield.client import SentinelClient
c = SentinelClient(token=os.environ["NEMESIS_TOKEN"])
c.record(build_sketch(method="GET", path="/orders/42", authenticated=True, status=200))

Docs & links

Want more than the one-liner? Full per-framework code, options, and examples:

Framework Detailed guide & source
FastAPI / Starlette (ASGI) nemesis_shield/asgi.py
Flask / WSGI nemesis_shield/wsgi.py
Django nemesis_shield/django.py
Raw client nemesis_shield/client.py
LLM guard nemesis_shield/llm.py
Runnable examples python/tests

How enforcement works

  1. Learn — deploy in observe mode (default). Every request is recorded as a privacy-preserving request signature (method + route + params + auth — never bodies or secrets). Review and approve the learned behaviors in the console.
  2. Enforce — flip the app to enforce in the console. The SDK polls the compiled allow-list in the background, so no redeploy is needed — the console is the source of truth.
  3. Block — any request whose signature isn't in the approved allow-list (once a baseline exists), is explicitly blocked, or matches global threat intel, gets a 403 blocked_by_nemesis_shield before your app handles it. Everything approved passes untouched.

Verified end-to-end (learn → enforce → attack) on FastAPI, Flask, Django and raw: legitimate traffic passes (200) while auth bypass, BOLA, path traversal and scanner probes are blocked (403) and reported.

LLM protection

from nemesis_shield import analyze_llm
result = analyze_llm(prompt=prompt, system=system, response=response, tools=tools)

MIT © Autogon Inc.

Full coverage & safe-unlock

Mount it first / outermost so every route is inspected (not just API routes — attackers hit any path):

app.add_middleware(SentinelMiddleware, token=os.environ["NEMESIS_TOKEN"])  # ASGI; or wrap wsgi_app outermost

What's inspected (privacy-preserving): method + normalized route + query-param structure (names + kinds, never values) + auth flag + status. An off-baseline route, param structure, method, or auth state is blocked in enforce mode. Path-traversal segments normalize to {traversal}.

Safe-unlock (break-glass): the login/auth path is never blocked, so a still-learning baseline can't lock you out. Defaults: /login /signin /sign-in /auth /oauth /session /wp-login.php /wp-admin. Override:

export NEMESIS_SHIELD_BOOTSTRAP="/login,/admin,/healthz"

Verify coverage — in observe mode, hit a normal route, a param, and a scanner path, then confirm all three appear in the console (Activity / Behaviors):

curl -s "http://localhost:8080/" >/dev/null
curl -s "http://localhost:8080/search?q=shoes" >/dev/null
curl -s "http://localhost:8080/.env" >/dev/null   # shows up as an off-baseline behavior

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nemesis_shield-0.1.3.tar.gz (49.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nemesis_shield-0.1.3-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file nemesis_shield-0.1.3.tar.gz.

File metadata

  • Download URL: nemesis_shield-0.1.3.tar.gz
  • Upload date:
  • Size: 49.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.2

File hashes

Hashes for nemesis_shield-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b8ba99900e7daa936966f9f3b69f196848fda6461a204833eae2a462c9b47112
MD5 1110dac26aa2a7272daac4b8be93abe8
BLAKE2b-256 b760e1a206fb7f7686cb581242b6ad5f7fd960535537a89cf53efce4878fee32

See more details on using hashes here.

File details

Details for the file nemesis_shield-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nemesis_shield-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.2

File hashes

Hashes for nemesis_shield-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f786cd9ed521dcc6687fc81302b7536bba48a7833c28527096d1113ee6d25bef
MD5 6c2455ab1301bbb959dec023cc27fb03
BLAKE2b-256 90c573e9205a91bec30f4ad153fb32e8469b5d1dc8d91828f0a8408f138b6038

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page