Skip to main content

🛡️ Synapse Shield

Stop bots on your login and signup forms without showing your users a CAPTCHA.

A self-hosted, open-source alternative to Cloudflare Turnstile. It looks at how a visitor moves, taps and types, never at what they type.

PyPI CI Python 3.10–3.14 License: MIT Stars

🌐 English | 简体中文

How Synapse Shield works: the visitor uses the form, the SDK collects timing only, the server scores the session, and the request is allowed, challenged or blocked

Why

  • No puzzles. Real people just use your form. When the shield is unsure, the browser solves a short proof-of-work in the background instead of showing a picture puzzle.
  • Your server, your data. Everything runs on your own machine. No third-party service sees your visitors.
  • No typed text leaves the browser. The SDK sends movement and timing only; every typed character is masked.
  • Drop-in. One middleware line for FastAPI, Django, Flask, Litestar, Sanic or any ASGI app, plus a small browser SDK (plain JS, React or Vue).
A human-like cursor path is allowed with risk 0, a Bezier bot path is blocked with risk 100

Generated from the project's own synthetic traces by scripts/make_readme_gifs.py; the verdicts are the engine's real output on those traces.

Install

pip install "synapse-shield[server]"

Start the server with its live dashboard, then open http://127.0.0.1:8000:

synapse-shield run --port 8000

Check that everything is set up correctly:

synapse-shield doctor

Upgrading to 0.12 behind a reverse proxy? The client IP is now read only from the header you name in SYNAPSE_PROXY_HEADER (default x-forwarded-for). Behind Cloudflare set SYNAPSE_PROXY_HEADER=cf-connecting-ip, otherwise every visitor looks like a Cloudflare IP (details).

Docker
git clone https://github.com/0xStoic-bit/Synapse_Shield.git
cd Synapse_Shield
docker-compose up -d

The API and dashboard are on http://localhost:8000.

Other install options
Command What you get
pip install synapse-shield Scoring engine only (for use inside your own app)
pip install "synapse-shield[server]" + the built-in server and dashboard
pip install "synapse-shield[frameworks]" + Django, Flask, Sanic and Litestar adapters
pip install "synapse-shield[all]" Everything

Pre-built wheels are published for Linux, macOS and Windows, so no Rust toolchain is needed.

Protect a form in 5 minutes

1. Server (FastAPI shown, other frameworks):

from fastapi import FastAPI
from synapse_shield import SynapseShieldMiddleware

app = FastAPI()
app.add_middleware(SynapseShieldMiddleware, protected_paths=["/api/login"])

2. Browser (plain HTML shown, React and Vue):

<!-- served by `synapse-shield run`; in your own app, serve synapse_shield/static/synapse-sdk.js from the installed package -->
<script src="/static/synapse-sdk.js"></script>
<script>
  SynapseShield.init();
  SynapseShield.protectFetch("/api/login"); // adds the X-Synapse-Token header to these requests

  // your existing code stays the same
  fetch("/api/login", { method: "POST", body: new FormData(loginForm) });
</script>

That's it. Requests to /api/login without a valid token, or that look automated, are refused before they reach your code.

When the server is unsure it answers 429 challenge_required and asks for a background proof-of-work. The React and Vue SDKs (submitProtected()) and plain JS (submit(), protectFetch()) solve it automatically in the background (details).

What your users experience

Situation Result
Normal visitor (mouse, touch, trackpad) Passes, sees nothing
Keyboard-only or screen-reader user, very short interaction Passes after a short background proof-of-work (handled by all three browser SDKs)
Scripted bot, headless browser, replayed request Blocked

Want to try it on real traffic first without blocking anyone? Use shadow mode.

Honest limits

  • Bot detection numbers in this project come from synthetic attack generators, not from real bot traffic. Human false-positive numbers come from the public SapiMouse dataset (120 people).
  • A determined attacker who records real human sessions and replays each one with small changes can look human. The shield raises the cost (single-use tokens, replay fingerprints, proof-of-work), but it is one layer: keep rate limits and account-level protections such as MFA.

Documentation

I want to… Read
Add it to Django, Flask, Litestar, Sanic, ASGI, React, Vue Integrations
Tune behaviour, alerts, metrics Configuration
Measure false positives before enforcing Shadow mode
Know what data is processed and stored Privacy notes for operators
Understand how detection works Architecture
See attack test results Benchmarks
Browse every feature by release Feature history
Run the tests or build the Rust core Tests · Rust core · SDK tests

Full index: docs/.

Support

If Synapse Shield saves you from a CAPTCHA or a bot swarm, a ⭐ helps other developers find it. Issues and pull requests are welcome (CONTRIBUTING.md), and you can sponsor the project.

Featured on Mfuns (architecture review, in Chinese).

License

MIT. Free for commercial and personal use.

Metadata

Release files for synapse-shield 0.12.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synapse-shield 0.12.2
File Size Uploaded Provenance Actions
synapse_shield-0.12.2.tar.gz 201.0 kB Without provenance Details for synapse_shield-0.12.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for synapse-shield 0.12.2
File Actions
synapse_shield-0.12.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for synapse_shield-0.12.2-cp310-abi3-win_amd64.whl
synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_x86_64.whl
synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_aarch64.whl
synapse_shield-0.12.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for synapse_shield-0.12.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
synapse_shield-0.12.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for synapse_shield-0.12.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
synapse_shield-0.12.2-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for synapse_shield-0.12.2-cp310-abi3-macosx_11_0_arm64.whl
synapse_shield-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for synapse_shield-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 3.9 MB

Release files / synapse_shield-0.12.2.tar.gz

Download URL synapse_shield-0.12.2.tar.gz
Size 201.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a30079ac6ee648de4de836cc02fcdab4ae6bc87051faa8a4af354e78096e661c
BLAKE2b-256 checksum
How to use checksums
3267344ff1e9ed8bac4ddc71ec29bd302174bd4e3766c9160d0630405500eda3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-win_amd64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-win_amd64.whl
Size 394.7 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9fb3f1f42f33ce73f38858069734c135a558c50343be7231d74b3cc23b53d6e6
BLAKE2b-256 checksum
How to use checksums
9d04c39f9867338cd50292697c3879357c308d017924b6d5445cde0bd1639d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_x86_64.whl
Size 710.3 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
b05ad1efd071d451de00bf5f19db3c3784a88fd417daa48489ee58f0adc23d7c
BLAKE2b-256 checksum
How to use checksums
b74e160af158802f61596a9761c36b35ce92c46b4aca1b8e7426b172e685ec4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-musllinux_1_2_aarch64.whl
Size 666.1 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
1966abe980b9ea7b6f87cfb23a34d32de433832327dea0b2ce5339dde12bb44a
BLAKE2b-256 checksum
How to use checksums
2d9cd020434809c6616855085064cb7f820cfaa387dff5509fddcb67c08fd544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 499.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b0a6eaa407541a2b05b3b503d1e6a0853604a10c2e307adf96aae146763f1404
BLAKE2b-256 checksum
How to use checksums
98958feb5d28d56fd9c0232c8773bf7e4b4a4825c837592b61bcd79a181e15fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 488.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
963d25b2b157e63bafd7f0ec2e3fb8a80c9077ea9e5863dde3f442483c1f7412
BLAKE2b-256 checksum
How to use checksums
0c61218e82570e48328f83ec98a3cb26d75c9c090fc7bb79bebba7f0ac6c5db7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-macosx_11_0_arm64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-macosx_11_0_arm64.whl
Size 470.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5abc3ba6b2d25dd0c2d54ce0b57ee1fdf40eb54e56e9d41ddc6045e47958a10b
BLAKE2b-256 checksum
How to use checksums
36b91558ead10c3bfb2c1cae2528fcce76bcff2f228e2cb810f12781326ad50c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / synapse_shield-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl

Download URL synapse_shield-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl
Size 488.3 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1c87a23b140ed5e9f556c896f17252c74ac3b5fb537d09745e08099a4a2d89b5
BLAKE2b-256 checksum
How to use checksums
bea1d932196f86f1487d04be5f17d0b35c943b070cf78c420209e32ecfbea863
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for synapse-shield 0.12.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.2 This release

8 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page