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.1

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.1
File Size Uploaded Provenance Actions
synapse_shield-0.12.1.tar.gz 190.4 kB Without provenance Details for synapse_shield-0.12.1.tar.gz

Built distributions (wheels)

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

Total release size: 3.7 MB

Release files / synapse_shield-0.12.1.tar.gz

Download URL synapse_shield-0.12.1.tar.gz
Size 190.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a284ed1bfb9433641b1d7ac114f01704f0344698a006189049b6852bbaa4b846
BLAKE2b-256 checksum
How to use checksums
2bbe6a728c082fff2a69ef3e00c8cca43e4a12e2d8821eac26d1d5aaa89c94fa
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.1-cp310-abi3-win_amd64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-win_amd64.whl
Size 362.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4fcd8a0bca03b732b8a50ea95286cf55b4dba237e3b93db7ee354b87b2f1f979
BLAKE2b-256 checksum
How to use checksums
c69cc53ca2aa349d07f5ac5104c0547ced1f9734174c481da915e73f76a2580e
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.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 677.9 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7791d8db342c55a9f349b6de0eebf9d0ba78f58889122d37e7bf1a86a2b46bc2
BLAKE2b-256 checksum
How to use checksums
9ce4f9650e1bb94d316359785c88875f421f2a0a6f8e91198b70068f36f0d410
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.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 637.0 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
a2e5cbf7a9f3910c482ac23c56ac535be074471ae9642ec171a1204321c04f74
BLAKE2b-256 checksum
How to use checksums
09766cbbbe9cd39c47a49ae081ae7ec3c7383c812ce41faabe0ab2e958158711
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.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 466.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4bc4ab5325a824de189379209e48315b678174fd2b7ac5f1f4c1771d36644240
BLAKE2b-256 checksum
How to use checksums
71fb9e8f08e4524ab31abb19c9d173a765ab11b83c6c5e4ba3e08bfce038868d
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.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 459.1 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
96a87b079369e467d66888e4c711586fe06032094c3131eb1f7c324858f76aef
BLAKE2b-256 checksum
How to use checksums
e406192668d696e1ca50cf993f2c6d9e199024f784f2ea9701a1f98753a83259
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-macosx_11_0_arm64.whl
Size 442.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
81d1435c1bc749f4875145be4a456dad06cf9ae49afd5f4963fe163447ad6222
BLAKE2b-256 checksum
How to use checksums
6a92beb62273e2594166a5f0743b197fc60f1f7b1a968435184c449866ee184f
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.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL synapse_shield-0.12.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 456.2 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
38f92151b0d5d6be46b46479c4015695329c6769ab52275c8bbf96bc69acbc6a
BLAKE2b-256 checksum
How to use checksums
38a556e10d1bb620ba05196a4e12070586f653ceec5a639a30574c3d5d9d4b80
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.1

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.1 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