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))

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.0.tar.gz (48.7 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.0-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nemesis_shield-0.1.0.tar.gz
  • Upload date:
  • Size: 48.7 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.0.tar.gz
Algorithm Hash digest
SHA256 1659b7ff2235a4de5b34113d98550c26be916414e00468435866258a9a684352
MD5 4fed402fe5eaf30a0579b00d1251761c
BLAKE2b-256 d37888202633dbd0a58c987bd5ab28552212205f030a4e4fce872a82f2de2e6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nemesis_shield-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aac1b172b96569ef02d135593a3dfd4b873d2b8da59eababb9784000d49cfcbf
MD5 ca8ee069d38a38ed1b842db4298dfffe
BLAKE2b-256 7fe1bacc893f1435d06ac949baf1765e9a22bb327a8e7445fbf245a9b2a33d32

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