<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mustafa Güngör</title>
    <description>The latest articles on DEV Community by Mustafa Güngör (@0xstoic_bit).</description>
    <link>https://dev.to/0xstoic_bit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4104331%2F6ea399c1-1f38-4254-aa5d-e2300bbf5bbe.png</url>
      <title>DEV Community: Mustafa Güngör</title>
      <link>https://dev.to/0xstoic_bit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0xstoic_bit"/>
    <language>en</language>
    <item>
      <title>I asked two AI teams to break my bot detector. They found 8 holes, and their fixes opened 3 new ones.</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Sun, 22 Nov 2026 20:28:22 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/i-asked-two-ai-teams-to-break-my-bot-detector-they-found-8-holes-and-their-fixes-opened-3-new-f58</link>
      <guid>https://dev.to/0xstoic_bit/i-asked-two-ai-teams-to-break-my-bot-detector-they-found-8-holes-and-their-fixes-opened-3-new-f58</guid>
      <description>&lt;p&gt;Last week I shipped a release where I barely wrote any code myself.&lt;/p&gt;

&lt;p&gt;AI agents found the bugs, and other agents wrote the fixes. My job was to &lt;strong&gt;check every fix as if it had come from a stranger&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That turned out to be the most important part. Three of the eleven patches passed their own tests and were still wrong.&lt;/p&gt;

&lt;p&gt;This post covers what the agents found in my open-source bot detector, how the review process worked, and what I learned about letting AI touch security code.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 Quick context: what is Synapse Shield?
&lt;/h2&gt;

&lt;p&gt;It's a self-hosted replacement for CAPTCHAs. A small browser SDK records &lt;strong&gt;how&lt;/strong&gt; a visitor moves, taps and types. It never records &lt;strong&gt;what&lt;/strong&gt; they type. Your server then scores the session and allows it, blocks it, or asks the browser to solve an invisible proof-of-work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhuman-vs-bot.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhuman-vs-bot.gif" alt="A human-like cursor path is allowed, a Bézier-curve bot is blocked" width="760" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's written in Python with a Rust core, has SDKs for React, Vue and plain JS, and is MIT licensed.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 The setup: two research teams and a red team
&lt;/h2&gt;

&lt;p&gt;I split the codebase into five areas: detection engine, crypto and tokens, framework adapters and SDKs, Rust core, and monitoring. I gave each area to an AI "owner" with one rule: &lt;strong&gt;research only, change nothing, and back every claim with a file and line number&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I ran the same assignment twice, once with Claude agents and once with Gemini agents.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Issues found independently by &lt;strong&gt;both&lt;/strong&gt; teams&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Found only by one team&lt;/td&gt;
&lt;td&gt;several each&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claims later confirmed by a red-team agent writing a working proof of concept&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;8 of 8&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The overlap was the useful signal. When two different models independently point at the same line, it's probably real.&lt;/p&gt;

&lt;p&gt;Then a third agent played attacker. For every claim it wrote a small script that either reproduced the hole or failed to. No reproduction meant no fix.&lt;/p&gt;




&lt;h2&gt;
  
  
  🕳️ The 8 holes
&lt;/h2&gt;

&lt;p&gt;All of these are fixed in v0.12.0. If you run Synapse Shield, please upgrade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Phone-sized screens skipped the behavioural layer (critical).&lt;/strong&gt;&lt;br&gt;
If a request said "I support touch" but sent no touch events, the session was supposed to be treated as desktop. That check only ran on screens 1024 px or wider. On a phone-sized screen, a one-click macro scored &lt;strong&gt;0 out of 100&lt;/strong&gt; and was allowed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The client could choose its own IP address (critical, behind some proxies).&lt;/strong&gt;&lt;br&gt;
Behind a reverse proxy, the server trusted several forwarding headers in a fixed order. If the proxy passed client-sent headers through, an attacker could pick their own IP and dodge bans and rate limits. In development mode, a forged loopback address even unlocked the admin panel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Two framework integrations broke the proof-of-work.&lt;/strong&gt;&lt;br&gt;
They wrapped the challenge response one level deeper than the SDKs expected. Users on those routes got stuck on a 429 they could never clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The Rust core and the Python fallback disagreed.&lt;/strong&gt;&lt;br&gt;
Leave one field out of the request and the Rust path said "human" while the Python path said "bot". That's a free bypass whenever the fast path is active.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. A locked database looked like an attack.&lt;/strong&gt;&lt;br&gt;
When SQLite was briefly locked, the nonce check failed. A failed check was counted as a replay, so a real user got a strike against their IP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Very short mouse movements were punished for being short (false positives).&lt;/strong&gt;&lt;br&gt;
With 3 or 4 points, some statistics only have one value, so their variance is 0. The rule read that zero as "too perfect, must be a bot".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. The docs told you to send a field no integration read.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. The plain-JS SDK didn't solve the proof-of-work.&lt;/strong&gt;&lt;br&gt;
The React and Vue SDKs did.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧯 The part I didn't expect: the fixes were wrong
&lt;/h2&gt;

&lt;p&gt;I gave each fix to a coding agent with a strict ticket. It had to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write a failing test that reproduces the hole.&lt;/li&gt;
&lt;li&gt;Make the smallest change that turns the test green.&lt;/li&gt;
&lt;li&gt;Run the whole test suite.&lt;/li&gt;
&lt;li&gt;Touch only the files listed in the ticket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every agent came back saying it was done and all tests passed.&lt;/p&gt;

&lt;p&gt;I didn't accept a single "done" without checking. I read every diff, reran every proof of concept myself and wrote my own probes. &lt;strong&gt;Three patches were wrong, and every one of them had passed its own tests.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ❌ Rejection 1: the IP fix created a new IP bypass
&lt;/h3&gt;

&lt;p&gt;The agent's new header parser tried to be helpful. It treated header names written in other ways, such as &lt;code&gt;x_forwarded_for&lt;/code&gt; or &lt;code&gt;http-x-forwarded-for&lt;/code&gt;, as the real &lt;code&gt;X-Forwarded-For&lt;/code&gt; header and merged their values.&lt;/p&gt;

&lt;p&gt;My probe added one fake header next to the proxy's real one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;real proxy header only           -&amp;gt; 203.0.113.5   (correct)
+ "http-x-forwarded-for: 9.9.9.9" -&amp;gt; 9.9.9.9       (attacker wins)
+ "x_forwarded_for: 8.8.8.8"      -&amp;gt; 8.8.8.8       (attacker wins)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent's tests only covered the attacks from the original report. &lt;strong&gt;It closed the reported hole and opened a new one right next to it.&lt;/strong&gt; In the second round, only the exact canonical header names are read.&lt;/p&gt;

&lt;h3&gt;
  
  
  ❌ Rejection 2: the panic handler that never catches a panic
&lt;/h3&gt;

&lt;p&gt;Rust panics must never kill the Python worker. The agent switched the build from &lt;code&gt;abort&lt;/code&gt; to &lt;code&gt;unwind&lt;/code&gt; and wrapped every native call so that a &lt;code&gt;PanicException&lt;/code&gt; falls back to Python.&lt;/p&gt;

&lt;p&gt;Its tests injected a fake &lt;code&gt;PanicException&lt;/code&gt; class, and they passed. At runtime, though, the real class was never found, because the module the agent looked it up in isn't registered in &lt;code&gt;sys.modules&lt;/code&gt;. &lt;strong&gt;The code caught every exception except the one it was written for.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pyo3_runtime in sys.modules: False
resolved PanicException: _NeverMatchingPanic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In round two the Rust module exports the real type. A test now triggers a real panic and checks that the process survives.&lt;/p&gt;

&lt;h3&gt;
  
  
  ❌ Rejection 3: guessing at functions that don't exist
&lt;/h3&gt;

&lt;p&gt;The storage fix called three Rust functions "if they exist". None of them did, so the code did nothing at all. It also added a cache with no size limit. Neither problem would ever fail a test.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Lesson:&lt;/strong&gt; an agent's test suite shows that the agent's idea of the bug is fixed. It doesn't show that the bug is fixed. Someone has to attack the fix with the same suspicion as the original code.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📏 Measured, not claimed
&lt;/h2&gt;

&lt;p&gt;Every number below was measured on real people (the public SapiMouse dataset, 120 people, and the CMU keystroke dataset), except bot detection, which comes from synthetic generators.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;v0.11&lt;/th&gt;
&lt;th&gt;v0.12&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Real 3–10 point mouse movements blocked&lt;/td&gt;
&lt;td&gt;12.1%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.7%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real 2 / 6 / 20 s sessions blocked&lt;/td&gt;
&lt;td&gt;2.3 / 0.97 / 0.46%&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Real typing sessions blocked (CMU, 20,400)&lt;/td&gt;
&lt;td&gt;0.034%&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Synthetic bots detected&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust feature extraction, 300 points&lt;/td&gt;
&lt;td&gt;592 µs&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;136 µs&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;One measurement bug of my own.&lt;/strong&gt; An agent reported a small regression on 6-second windows. When I re-ran it, I got a third, different number. The cause was the benchmark itself: it reused the same database and IP addresses between runs, so session history from earlier runs leaked into later ones. With one isolated database per run, before and after were &lt;strong&gt;identical&lt;/strong&gt;. The regression never existed, but I would have shipped a wrong number into the docs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What still isn't good enough:&lt;/strong&gt; on the longest traces (300 points), the 95th-percentile latency is &lt;strong&gt;1.22 ms&lt;/strong&gt;, over my 1 ms budget. The Rust part is now fast; the remaining time is in Python. That's the next release.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ One breaking change
&lt;/h2&gt;

&lt;p&gt;The client IP is now read &lt;strong&gt;only&lt;/strong&gt; from the header you name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;SYNAPSE_PROXY_HEADER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;x-forwarded-for   &lt;span class="c"&gt;# default&lt;/span&gt;
&lt;span class="nv"&gt;SYNAPSE_PROXY_HEADER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cf-connecting-ip  &lt;span class="c"&gt;# behind Cloudflare: set this!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run behind Cloudflare and don't set this, every visitor will look like a Cloudflare IP. That's why this release is 0.12.0, not a patch, and why both the startup log and &lt;code&gt;synapse-shield doctor&lt;/code&gt; warn you about it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install -U &lt;span class="s2"&gt;"synapse-shield[server]"&lt;/span&gt;
npm install synapse-shield-react   &lt;span class="c"&gt;# or synapse-shield-vue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The React and Vue SDKs are on npm for the first time.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;0xStoic-bit/Synapse_Shield&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Over to you
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;If you use AI agents on security-sensitive code, how do you review their output?&lt;/strong&gt; Do you trust their tests?&lt;/li&gt;
&lt;li&gt;Have you seen an AI-written fix that passed its tests but was still wrong?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If this was useful, a ⭐ on GitHub helps other developers find the project.&lt;/p&gt;

</description>
      <category>security</category>
      <category>python</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
    <item>
      <title>I built a local memory for my PC in Rust, then tried to steal my own secrets from it</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Sun, 22 Nov 2026 11:43:43 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/i-built-a-local-memory-for-my-pc-in-rust-then-tried-to-steal-my-own-secrets-from-it-2h5k</link>
      <guid>https://dev.to/0xstoic_bit/i-built-a-local-memory-for-my-pc-in-rust-then-tried-to-steal-my-own-secrets-from-it-2h5k</guid>
      <description>&lt;p&gt;What was that error I searched for an hour ago? Which terminal did I paste that command into? What was I even doing before lunch?&lt;/p&gt;

&lt;p&gt;I wanted to press one shortcut and just &lt;em&gt;find&lt;/em&gt; it. Tools like that exist, but most of them take periodic screenshots or send your activity to a server. I did not want either. So I built &lt;strong&gt;Synapse Mind&lt;/strong&gt;: a local-first memory for Windows that never takes screenshots, never leaves the device, and masks secrets in memory before anything touches the disk.&lt;/p&gt;

&lt;p&gt;This post is about the parts that turned out to be harder than expected, and about testing the privacy claims by actually dumping the app's memory and searching it for secrets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8lpumar7bih7xybb5d5e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8lpumar7bih7xybb5d5e.gif" alt="Alt+Space search with causality links" width="720" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remembers:&lt;/strong&gt; captures the focused window's text through UI Automation, clipboard events and window switches. No periodic screenshots.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connects:&lt;/strong&gt; links events by time and simple rules ("searched after an error", "pasted from clipboard", "switched app"), so a result shows the chain around a moment, not just the moment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finds:&lt;/strong&gt; &lt;code&gt;Alt+Space&lt;/code&gt;, type, done. Hybrid search: BM25 full text + vector similarity + recency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protects:&lt;/strong&gt; password managers, private browser windows and &lt;code&gt;.env&lt;/code&gt; / &lt;code&gt;.pem&lt;/code&gt; / &lt;code&gt;id_rsa&lt;/code&gt; windows are never processed. Everything else passes a masker: &lt;code&gt;STRIPE_SECRET=[REDACTED_API_KEY]&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;It is a Rust 2024 workspace plus a Tauri 2 app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;s-sensor  ──►  s-guard  ──►  s-core  ──►  Tauri UI
(Win32 hooks,   (blocklist,     (SQLCipher,     (Alt+Space overlay,
 UI Automation,  PII/secret      FTS5 + vectors,  Memory Panel, tray)
 clipboard)      masker,         causality)
                 zeroize)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule that shaped everything: &lt;strong&gt;raw data cannot reach the disk or the embedding model without passing the guard.&lt;/strong&gt; The type system enforces part of it. The raw packet type has no &lt;code&gt;Debug&lt;/code&gt;, &lt;code&gt;Serialize&lt;/code&gt; or &lt;code&gt;Clone&lt;/code&gt;, and that is checked with &lt;code&gt;compile_fail&lt;/code&gt; doctests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is a compile_fail doctest: it must NOT compile.&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;leak&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;s_types&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;RawCapturePacket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"{:?}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// error[E0277]: `RawCapturePacket` doesn't implement `Debug`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Raw fields are wiped with &lt;code&gt;zeroize&lt;/code&gt; on drop. The database is SQLite encrypted with SQLCipher (AES-256), and its key is random and protected by Windows DPAPI, so the plain key is never written to disk.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Windows keeps copies you cannot wipe
&lt;/h2&gt;

&lt;p&gt;UI Automation is the right way to read text from other apps (OCR is only a fallback). But &lt;code&gt;UIAutomationCore.dll&lt;/code&gt; copies the text it reads into its own internal heap buffers and frees them &lt;strong&gt;without zeroing&lt;/strong&gt;. Those buffers are not reachable from my code, so &lt;code&gt;zeroize&lt;/code&gt; cannot help. In a long-running process, that text just sits in RAM, and in any memory dump.&lt;/p&gt;

&lt;p&gt;The fix was to move the read out of the main process. A &lt;strong&gt;single-use, pre-warmed helper process&lt;/strong&gt; waits with COM and UI Automation already initialized. For each read it receives only numbers (a window handle and limits) over stdin, reads one window, writes the result back and is killed. When the process dies, the kernel reclaims and zeroes its pages. All helpers are in a job object with kill-on-close, so they die if the main app dies. The main app never loads the UIA library at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2: proving it, with memory dumps
&lt;/h2&gt;

&lt;p&gt;"We zeroize everything" is easy to write in a README. I wanted a test that could fail.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gate 1&lt;/strong&gt; feeds synthetic PII and secrets (cards with valid Luhn digits, national IDs, API keys, JWTs, private keys, plus encoded and split variants) through the guard and checks that nothing leaks into what gets stored.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gate 2&lt;/strong&gt; starts the real release binary with an isolated data folder, feeds synthetic secrets through the real sensor path (a fake window with secret text, clipboard contents), uses the search box, opens the Memory Panel, and takes &lt;strong&gt;full memory dumps of the app, the helper processes and every WebView2 process&lt;/strong&gt; at several stages. Then it searches the dumps for the raw secrets, the database key in several encodings, and the SQLCipher-derived HMAC key. At the end it opens the encrypted database and confirms that the events were stored masked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The harness has its own controls, so a blind detector cannot pass: it must find the secrets in its &lt;em&gt;own&lt;/em&gt; memory, and it must find a marker typed into the search box inside the WebView.&lt;/p&gt;

&lt;p&gt;For v0.1.1, the final run dumped 41 processes and found no raw secrets or keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 3: a 3.6 GB surprise from attention padding
&lt;/h2&gt;

&lt;p&gt;After switching from a test embedder to a real model (&lt;code&gt;bge-small-en-v1.5&lt;/code&gt; through &lt;code&gt;fastembed&lt;/code&gt; / ONNX Runtime, running on the CPU), existing records have to be re-embedded once. On a fresh test database this path never ran. On my real database, the app climbed to &lt;strong&gt;3.6 GB&lt;/strong&gt; of memory.&lt;/p&gt;

&lt;p&gt;The cause: the backfill sent 128 texts to ONNX Runtime in one call. Every text is padded to the longest one (up to 512 tokens), and attention memory grows with &lt;code&gt;batch × seq_len²&lt;/code&gt;. I wrote a test that pushes 128 long texts through the app's exact configuration and measured peak working set by batch size:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Texts per call&lt;/th&gt;
&lt;th&gt;Peak working set&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;128&lt;/td&gt;
&lt;td&gt;3,351 MB&lt;/td&gt;
&lt;td&gt;20.3 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;417 MB&lt;/td&gt;
&lt;td&gt;11.7 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;299 MB&lt;/td&gt;
&lt;td&gt;9.9 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;238 MB&lt;/td&gt;
&lt;td&gt;12.6 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;209 MB&lt;/td&gt;
&lt;td&gt;13.4 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One at a time keeps memory at the model-loaded footprint, and it is still faster than the original single call. The model is also unloaded after 10 idle minutes, which brings the app's private memory down to about 32 MB.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 4: the spinning cursor
&lt;/h2&gt;

&lt;p&gt;I noticed a busy (loading) cursor that kept spinning. The single-use UIA helper was the cause: it is the same GUI-subsystem executable as the app, and Windows shows "app starting" feedback for a new GUI process until it shows a window or calls &lt;code&gt;GetMessage&lt;/code&gt;, or a timeout passes. The helper did neither, and a new one starts for every read.&lt;/p&gt;

&lt;p&gt;The fix is one call at the top of the helper: post a message to its own thread and immediately read it with &lt;code&gt;GetMessageW&lt;/code&gt;. Windows turns the feedback cursor off after the first &lt;code&gt;GetMessage&lt;/code&gt;. In a 60-second check with 14 helper launches, the busy cursor never appeared.&lt;/p&gt;

&lt;h2&gt;
  
  
  Numbers (Ryzen 7 8845HS, release build)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Single-query embedding p95: &lt;strong&gt;~18 ms&lt;/strong&gt; on CPU&lt;/li&gt;
&lt;li&gt;Long pasted queries (4 KB) are trimmed: embedding p95 went from 88 ms to 19 ms, keyword search p95 from 25 ms to 3 ms&lt;/li&gt;
&lt;li&gt;Idle: about 32 MB private memory after the model is unloaded; about 200 MB with the model loaded&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Honest limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Windows 11 only for now.&lt;/li&gt;
&lt;li&gt;The semantic model is English-only. Turkish text still matches by keyword, but not by meaning.&lt;/li&gt;
&lt;li&gt;The links between events are rule-based. Nothing here "understands" your content.&lt;/li&gt;
&lt;li&gt;Accepted risks are documented in &lt;code&gt;SECURITY.md&lt;/code&gt;, including what this cannot protect against (malware in the same user session, pagefile and hibernation).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Repo: &lt;a href="https://github.com/0xStoic-bit/Synapse_Mind" rel="noopener noreferrer"&gt;https://github.com/0xStoic-bit/Synapse_Mind&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Release (Windows installer, per-user, no admin): &lt;a href="https://github.com/0xStoic-bit/Synapse_Mind/releases/tag/v0.1.1" rel="noopener noreferrer"&gt;https://github.com/0xStoic-bit/Synapse_Mind/releases/tag/v0.1.1&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The license is FSL-1.1-MIT: source-available now, and each version becomes MIT two years after release.&lt;/p&gt;

&lt;p&gt;I would love feedback, especially on the threat model and on the memory-dump approach. If you can think of a way the guard could be bypassed, please open an issue.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>privacy</category>
      <category>windows</category>
      <category>security</category>
    </item>
    <item>
      <title>My bot detector blocked 1 in 5 real humans. My tests said 1.4%.</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:26:25 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/my-bot-detector-blocked-1-in-5-real-humans-my-tests-said-14-2cmp</link>
      <guid>https://dev.to/0xstoic_bit/my-bot-detector-blocked-1-in-5-real-humans-my-tests-said-14-2cmp</guid>
      <description>&lt;p&gt;My open-source bot detector had a test suite with 950+ passing tests, a 1D-CNN, a Rust core with SIMD, and a README full of green checkmarks.&lt;/p&gt;

&lt;p&gt;It was also blocking &lt;strong&gt;about 19% of real humans&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Not bots. People. Moving a mouse normally.&lt;/p&gt;

&lt;p&gt;This post covers how I found that out, why my tests couldn't see it, and what changed in &lt;strong&gt;Synapse Shield v0.11.0&lt;/strong&gt;. Every number below was measured before and after the change, on the same seeds.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 What is Synapse Shield?
&lt;/h2&gt;

&lt;p&gt;It's a self-hosted alternative to CAPTCHAs and Cloudflare Turnstile. It doesn't show puzzles. It looks at &lt;strong&gt;how&lt;/strong&gt; a visitor moves, clicks and types, never &lt;strong&gt;what&lt;/strong&gt; they type, and scores the session on your own server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhuman-vs-bot.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhuman-vs-bot.gif" alt="A human-like cursor path is allowed (risk 0), a Bézier-curve bot is blocked (risk 100)" width="760" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setup is one line of middleware plus a small browser SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;synapse_shield&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;SynapseShieldMiddleware&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SynapseShieldMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;protected_paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/api/login"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/static/synapse-sdk.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="nc"&gt;SynapseShield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nc"&gt;SynapseShield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;protectFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/login"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the pitch. Now the uncomfortable part.&lt;/p&gt;




&lt;h2&gt;
  
  
  💥 The bug that hid behind a green test suite
&lt;/h2&gt;

&lt;p&gt;The engine has five layers. One of them is a small 1D-CNN that looks at 60-step movement sequences.&lt;/p&gt;

&lt;p&gt;On my machine its false-positive rate was &lt;strong&gt;1.4%&lt;/strong&gt;. That looked fine.&lt;/p&gt;

&lt;p&gt;Then I replayed the public &lt;strong&gt;SapiMouse&lt;/strong&gt; dataset (120 real people, real mouse recordings) through the exact weights that ship inside the package. Those are the weights a Docker deployment actually loads.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Real-human windows blocked&lt;/th&gt;
&lt;th&gt;What I thought&lt;/th&gt;
&lt;th&gt;What production did&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6-second windows&lt;/td&gt;
&lt;td&gt;1.4%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;19.0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20-second windows&lt;/td&gt;
&lt;td&gt;~0.5%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;19.2%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The cause took a while to see:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;bundled&lt;/strong&gt; weights had been trained only on synthetic Gaussian noise.&lt;/li&gt;
&lt;li&gt;My local runs loaded a &lt;strong&gt;different&lt;/strong&gt; weights file from the working directory.&lt;/li&gt;
&lt;li&gt;A unit test (&lt;code&gt;test_train.py&lt;/code&gt;) kept &lt;strong&gt;overwriting&lt;/strong&gt; that local file with a model so saturated it was effectively switched off.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the "1.4%" number came from a model that did nothing. The model my users would get was blocking one person in five.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weights now load in a fixed, explicit order: argument, then env var, then bundled file. A stray file in the working directory is ignored, with a warning.&lt;/li&gt;
&lt;li&gt;Retraining refuses to write a saturated model.&lt;/li&gt;
&lt;li&gt;The CNN now runs in &lt;strong&gt;shadow mode by default&lt;/strong&gt;. It still scores every request and reports its raw score, but it can't block anyone until it earns that on real data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 19.0% → &lt;strong&gt;1.4%&lt;/strong&gt; (6 s) and 19.2% → &lt;strong&gt;0.5%&lt;/strong&gt; (20 s) on real people. Detection of the synthetic bots stayed at 100%.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;Lesson:&lt;/strong&gt; a test suite proves your code does what you think. It doesn't prove what you think is true. Only real data does that.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🛠️ 6 more things real users taught me
&lt;/h2&gt;

&lt;p&gt;Once I started measuring against real humans, the same pattern kept showing up. The rule looked reasonable, the synthetic tests passed, and it was still unfair to someone.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Touchscreen laptops were treated as liars
&lt;/h3&gt;

&lt;p&gt;If the browser said "I support touch" but no touch events arrived, the session was marked as a spoofer.&lt;/p&gt;

&lt;p&gt;A stricter penalty I tried would have blocked &lt;strong&gt;100% of touch-laptop users&lt;/strong&gt; and &lt;strong&gt;71% of iPad-with-keyboard users&lt;/strong&gt;. Those are normal devices.&lt;/p&gt;

&lt;p&gt;Now such sessions are simply scored as desktop. I verified that the touch flag gives a bot no advantage: scores are identical with and without it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Everyone behind one NAT was punished for one bot
&lt;/h3&gt;

&lt;p&gt;Offices, universities and mobile carriers (CGNAT) put thousands of people behind one IP. One bot on that IP raised everyone's risk.&lt;/p&gt;

&lt;p&gt;Now the short-term penalty is keyed to a hashed IP + User-Agent pair, and only hard violations count toward an IP ban. Under 60 requests per minute of mixed traffic, human loss went &lt;strong&gt;2.47% → 0.08%&lt;/strong&gt;. Scripted bots are still banned on their 4th request.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Short mouse movements looked "too perfect"
&lt;/h3&gt;

&lt;p&gt;A single short flick of the mouse has very few points. Too few for curvature and frequency rules to mean anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;50%&lt;/strong&gt; of real single movements were blocked. Those rules now carry a capped weight on short traces, and borderline cases get a silent proof-of-work instead of a block. Result: &lt;strong&gt;50.0% → 4.9%&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Pressing Enter looked like a bot click
&lt;/h3&gt;

&lt;p&gt;When you press Enter on a form, Chrome fires a synthetic click at (0, 0). The engine saw a teleporting cursor.&lt;/p&gt;

&lt;p&gt;Synthetic clicks within 50 ms of a key press are now ignored. In that scenario blocks went &lt;strong&gt;100% → 5.4%&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Replaying a real human recording worked every time
&lt;/h3&gt;

&lt;p&gt;This one's the attacker's side. If you record a real person's mouse trace and replay it from a fresh IP and User-Agent, it really does look human.&lt;/p&gt;

&lt;p&gt;v0.11.0 adds two defences, neither of which stores raw traces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;keyed 64-bit trajectory fingerprint&lt;/strong&gt;, consumed only when a request is allowed;&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;session shape hash&lt;/strong&gt; (SimHash) that survives scaling, noise and time warping.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A recorded trace replayed with fresh IPs was allowed &lt;strong&gt;100% → 10%&lt;/strong&gt; of the time, and only on its first use. In-session repeats are caught from the 3rd request. Measured human false positives: 0.02%.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Some client signals could only help the attacker
&lt;/h3&gt;

&lt;p&gt;A few browser-side hints &lt;em&gt;lowered&lt;/em&gt; the risk score, for example a flag claiming "this is a common letter pair". Anything the client sends can be forged.&lt;/p&gt;

&lt;p&gt;The rule now: &lt;strong&gt;client signals can only raise risk, never lower it.&lt;/strong&gt; Real-typist false positives on the CMU keystroke dataset didn't change (0.034%).&lt;/p&gt;




&lt;h2&gt;
  
  
  ❌ What I didn't ship (and why)
&lt;/h2&gt;

&lt;p&gt;Some ideas looked good on paper and failed when measured:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tremor detection via an FFT frequency band:&lt;/strong&gt; it cost bot detection and didn't fix the people it was meant to help.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extra keystroke rules:&lt;/strong&gt; at most 8% more bots caught at a 0.5% real-human false-positive cost. Not worth it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail-closed on a Redis outage:&lt;/strong&gt; it sounds secure, but it turns a cache hiccup into a self-inflicted outage. Fail-open is now documented instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deleting a feature you spent a day on is painful. Shipping one that blocks real people is worse.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧾 Honest limits
&lt;/h2&gt;

&lt;p&gt;I'd rather you hear these from me than find them in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;All bot numbers are synthetic.&lt;/strong&gt; Human false-positive numbers come from real public datasets, but I have no labelled real-bot traffic yet. Read "100% detection" as "catches these generators".&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;About 18% of very short (3–10 point) single movements are still blocked.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sophisticated replay still works partly.&lt;/strong&gt; An attacker who records many real sessions and replays each one once with small changes looks human to the behavioural layer. The system raises their cost; it isn't a wall. Keep rate limits and MFA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The plain-JS &lt;code&gt;protectFetch&lt;/code&gt; doesn't auto-solve proof-of-work challenges yet.&lt;/strong&gt; The React and Vue SDKs do (&lt;code&gt;submitProtected()&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install &lt;span class="s2"&gt;"synapse-shield[server]"&lt;/span&gt;
synapse-shield run --port 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;http://127.0.0.1:8000&lt;/code&gt; for the live dashboard, then run &lt;code&gt;synapse-shield test&lt;/code&gt; in a second terminal to throw the built-in attack simulations at it.&lt;/p&gt;

&lt;p&gt;Not ready to block anyone yet? Turn on &lt;strong&gt;shadow mode&lt;/strong&gt;. It scores real traffic and reports what &lt;em&gt;would&lt;/em&gt; have been blocked, per device cohort, without touching a single user.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;0xStoic-bit/Synapse_Shield&lt;/a&gt; (MIT, Python 3.10–3.14, prebuilt wheels for Linux, macOS and Windows)&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Over to you
&lt;/h2&gt;

&lt;p&gt;I'm curious about two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Have you ever shipped a security rule that turned out to punish real users?&lt;/strong&gt; How did you find out?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does anyone have labelled real bot traffic&lt;/strong&gt; (even a small sample) that could be used to test bot detection honestly? It's the biggest gap in this project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If this saved you from one more "select all traffic lights" puzzle, a ⭐ on GitHub helps other developers find it.&lt;/p&gt;

</description>
      <category>security</category>
      <category>python</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>My bot detector was blocking most real users, and my tests never noticed</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Tue, 10 Nov 2026 16:40:24 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/my-bot-detector-was-blocking-most-real-users-and-my-tests-never-noticed-3ea6</link>
      <guid>https://dev.to/0xstoic_bit/my-bot-detector-was-blocking-most-real-users-and-my-tests-never-noticed-3ea6</guid>
      <description>&lt;p&gt;I maintain &lt;strong&gt;Synapse Shield&lt;/strong&gt;, an open-source bot detection engine (Python with a native Rust core and JS client SDKs) that evaluates mouse and keyboard dynamics: jerk variance, Fitts' law terminal deceleration, path curvature, and keystroke flight times.&lt;/p&gt;

&lt;p&gt;On paper, my test suite looked bulletproof: over 500 unit tests, mutation testing, and adversarial red-team suites. Every test case representing a "human" was passing cleanly.&lt;/p&gt;

&lt;p&gt;Then I finally did what I should have done from day one: I ran actual recorded mouse movements from real people through the engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  The experiment
&lt;/h2&gt;

&lt;p&gt;Getting labeled interaction data is tedious, so I used recorded desktop sessions from a public academic dataset (120 participants). I converted the raw trajectories to match exactly what the frontend SDK emits (30 ms throttling, integer pixel coordinates, click events) and fed them directly into the full evaluation pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Window&lt;/th&gt;
&lt;th&gt;Real-user sessions blocked&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6 s (typical login)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;68.0%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 s (longer interaction)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;87.8%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every single participant was blocked as a bot at least once.&lt;/p&gt;

&lt;p&gt;My unit tests never caught this because my "human" fixtures were synthetic. They were sine waves with Gaussian noise, shaped by my own assumptions about how people move mice. The heuristic rules were tuned against a caricature of human movement, not reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  The culprit: a division by zero in disguise
&lt;/h2&gt;

&lt;p&gt;Nearly all the false positives came from a single rule: the differential curvature check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;κ = |v × a| / |v|³
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The formula divides by speed cubed. When a real person aims for a button, they slow down and pause. While the cursor is resting, browsers do not emit mousemove events. When the user makes a tiny 1-pixel adjustment after that 200-500 ms pause, the recorded speed drops to about 0.003 px/ms.&lt;/p&gt;

&lt;p&gt;Because &lt;code&gt;|v|³&lt;/code&gt; is in the denominator, κ shoots up to 30-100. The engine interpreted that sudden spike as chaotic trajectory jitter and slapped a heavy bot penalty on the session.&lt;/p&gt;

&lt;p&gt;In other words, the rule was triggering precisely when a human did what humans naturally do: stop and adjust before clicking.&lt;/p&gt;

&lt;p&gt;To make matters worse, that branch barely caught real bots. Against automated scripts it flagged only 5-13% of them, and only when the bots happened to produce a similar stop artifact.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The chaotic curvature check now filters out near-stationary points. It only evaluates steps where the cursor actually traveled a meaningful distance (at least 5 px on both neighboring steps, with a minimum of 10 such points).&lt;/p&gt;

&lt;p&gt;Instead of guessing a threshold, I swept values against the real recordings:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step threshold&lt;/th&gt;
&lt;th&gt;Real humans flagged by this rule&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0 px (old code)&lt;/td&gt;
&lt;td&gt;67.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 px&lt;/td&gt;
&lt;td&gt;3.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;5 px (chosen)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.39%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Across the entire decision engine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;6 s windows: &lt;strong&gt;68.0% → 1.4%&lt;/strong&gt; false positives&lt;/li&gt;
&lt;li&gt;20 s windows: &lt;strong&gt;87.8% → 2.7%&lt;/strong&gt; false positives&lt;/li&gt;
&lt;li&gt;Synthetic bot patterns: &lt;strong&gt;100%&lt;/strong&gt; detection maintained&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What an external review caught
&lt;/h2&gt;

&lt;p&gt;After drafting the fix, an independent code review found real problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ineffective regression tests:&lt;/strong&gt; My first tests for minimum-jerk bots did not actually exercise the new moving-point path (one fixture was a straight line, the other was too clean). I rewrote them with coordinates rounded the way real bots produce them, and the tests now also assert that the fixture is &lt;em&gt;not&lt;/em&gt; smooth on all points, so only the new branch can pass them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile touch false positives:&lt;/strong&gt; A polynomial acceleration rule meant for desktop mouse trajectories was also evaluating mobile taps. Taps spaced seconds apart collapsed acceleration variance to near zero, blocking simulated mobile users about 97% of the time. Adding a touch check brought that down to 2-3%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rollover typing:&lt;/strong&gt; When fast typists hold Shift or overlap keypresses, the inter-keystroke interval can be negative or zero. Because the check only looked for &lt;code&gt;&amp;lt; 25ms&lt;/code&gt;, negative numbers tripped the "superhuman typing frequency" penalty. Adding a strict lower bound (&lt;code&gt;0 &amp;lt; interval &amp;lt; 25ms&lt;/code&gt;) fixed it, and the same bug turned out to live in two more places (the Brave privacy cap and the threat label), so the check is now a single shared function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Every fix has a test that fails on the old code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Known limitations
&lt;/h2&gt;

&lt;p&gt;A few blind spots remain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quantized Bézier curves:&lt;/strong&gt; On integer coordinates, curvature analysis alone only catches about 23.5% of smooth Bézier bots. Other layers (FFT spectral analysis, terminal deceleration) catch the rest, but curvature is not a magic bullet on its own. That was true before the fix too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast typing false positives:&lt;/strong&gt; The superhuman typing threshold still trips on roughly 1.4% of real typing sessions. That is next on the list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simulated mobile data:&lt;/strong&gt; The mobile numbers come from a simulation model, not in-the-wild mobile recordings. Keyboard-only and older users have no real data yet either.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adversarial tooling:&lt;/strong&gt; Detection was evaluated against mathematical generators, not yet against full stealth headless browsers like Playwright with ghost-cursor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Synthetic test fixtures share your blind spots.&lt;/strong&gt; If you generated your own "human" test data with math, your heuristics will overfit to your own mental model of how people behave.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure false positives before tightening detection.&lt;/strong&gt; A bot detector that catches 99% of bots is useless if it blocks most legitimate customers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch out for singularities in kinematic formulas.&lt;/strong&gt; Anything with velocity or time in the denominator will blow up when a user stops moving.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These fixes are shipped in &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;v0.10.6&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I built this with AI assistance (Claude) for implementation and review. The detection approach and design decisions are mine.&lt;/p&gt;

</description>
      <category>security</category>
      <category>python</category>
      <category>rust</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How a regex turned my Zero-PII feature into a word leak (Synapse Shield v0.10.5)</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Sat, 07 Nov 2026 16:46:12 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/my-privacy-feature-was-leaking-whole-words-shipping-synapse-shield-v0105-2k4m</link>
      <guid>https://dev.to/0xstoic_bit/my-privacy-feature-was-leaking-whole-words-shipping-synapse-shield-v0105-2k4m</guid>
      <description>&lt;p&gt;For the past few months I've been building &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;Synapse Shield&lt;/a&gt; by myself. It's a self-hosted bot protection library for Python web apps (FastAPI, Flask, Django, Sanic, Litestar, and plain ASGI) backed by a Rust core and lightweight browser SDKs. Instead of making users click fire hydrants, it scores mouse kinematics, typing rhythm, and touch or scroll behavior on your own server so visitor telemetry never goes to a third-party vendor.&lt;/p&gt;

&lt;p&gt;A few days ago in v0.10.4, I shipped the feature I cared about most: client- and server-side Zero-PII keystroke masking. The promise was simple: the server only sees timing intervals and hold durations, never the characters someone types into a form.&lt;/p&gt;

&lt;p&gt;Right before tagging v0.10.5, I hit the usual solo-maintainer wall. Nobody is around to review my pull requests, and testing your own code mostly confirms your own assumptions. So I opened fresh, zero-context sessions across different AI models, handed them the repo in Red Team mode, and asked them to break it.&lt;/p&gt;

&lt;p&gt;They came back with 10 findings. LLM security reviews hallucinate plenty of nonsense, so I wrote quick local scripts to test each claim before touching any code, and all 10 reproduced.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I broke my own privacy guarantee
&lt;/h2&gt;

&lt;p&gt;To measure typing rhythm without logging text, the SDKs and the server needed to mask printable characters (&lt;code&gt;"a"&lt;/code&gt;, &lt;code&gt;"7"&lt;/code&gt;, &lt;code&gt;"@"&lt;/code&gt;) while still recognizing non-printable control keys like &lt;code&gt;Enter&lt;/code&gt;, &lt;code&gt;Backspace&lt;/code&gt;, and &lt;code&gt;ArrowLeft&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I didn't want to type out every valid control key by hand, so I wrote a regex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# From privacy.py before the fix&lt;/span&gt;
&lt;span class="n"&gt;_NAMED_KEY_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^[A-Za-z][A-Za-z0-9]+$"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;My brain read that as: single characters fail because of &lt;code&gt;+&lt;/code&gt;, while named keys like &lt;code&gt;Enter&lt;/code&gt; or &lt;code&gt;Backspace&lt;/code&gt; pass. What I completely missed is that any multi-character word is also two or more alphanumeric characters. Whenever browser autofill, mobile swipe typing, or an IME committed a whole word like &lt;code&gt;Mustafa&lt;/code&gt; in a single event, it matched the regex and went straight to the server in plain text.&lt;/p&gt;

&lt;p&gt;That stung, mostly because Zero-PII masking had been the headline of my v0.10.4 release notes three days earlier. The fix was boring and obvious in hindsight: delete the regex in &lt;code&gt;privacy.py&lt;/code&gt; and all three JS/TS SDKs (Vanilla, React, Vue), and replace it with a closed allowlist of W3C UI Events control key names. Anything outside that set becomes &lt;code&gt;"masked"&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Blocking real phone users on their fourth tap
&lt;/h2&gt;

&lt;p&gt;While multi-character words slipped past the privacy filter, real people on mobile browsers had the opposite problem. If an iPhone or Android user tapped a button four times within five minutes, the fourth tap got rejected with HTTP 403 and a 100% bot risk score.&lt;/p&gt;

&lt;p&gt;A stationary finger tap only records one touch coordinate (&lt;code&gt;mouse_points = 1&lt;/code&gt;), so there is no movement curve to measure. When &lt;code&gt;mouse_points &amp;lt; 3&lt;/code&gt;, my feature extractor fell back to placeholder numbers: &lt;code&gt;avg_jerk = 0.0&lt;/code&gt;, &lt;code&gt;straightness = 1.0&lt;/code&gt;, and &lt;code&gt;total_distance = 0.0&lt;/code&gt;. My request pipeline saved those placeholders into the user's session history anyway. On the fourth tap, the cross-request invariance check saw three &lt;code&gt;(0.0, 1.0, 0.0)&lt;/code&gt; entries in a row with zero variance between them and decided a bot was replaying a recorded trace.&lt;/p&gt;

&lt;p&gt;I had written dozens of tests for synthetic Bézier bots and almost none that simulated a normal person tapping around on a phone screen. Session history now ignores requests unless there is a real trajectory (&lt;code&gt;mouse_points &amp;gt;= 3&lt;/code&gt; and &lt;code&gt;total_distance &amp;gt; 0&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;
  
  
  Two embarrassingly cheap bypasses
&lt;/h2&gt;

&lt;p&gt;The kinematic engine checks for empty payloads, straight-line movement, and synthetic tremor, yet a headless script could still score 0.0% risk by sending empty mouse, click, and keystroke arrays alongside one scroll event:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mouse_movements"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"clicks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"keystrokes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"scrolls"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"t"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Because &lt;code&gt;scroll_count&lt;/code&gt; counted toward &lt;code&gt;total_interactive_events&lt;/code&gt;, that lone scroll passed the zero-interaction check, and none of the mouse or keyboard rules fired because their event counts were zero. A 25px ruler-straight mouse move with zero timing variance slipped through for a similar reason, since the desktop linearity checks only started above 30px.&lt;/p&gt;

&lt;p&gt;On top of that, all six framework middlewares opened with the same check:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PATCH"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;app&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receive&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I had written that filter in six separate adapter files and forgotten &lt;code&gt;"DELETE"&lt;/code&gt; every single time. Calling &lt;code&gt;DELETE /api/account/123&lt;/code&gt; on a protected route skipped token verification and IP bans altogether. All six adapters now read from a shared &lt;code&gt;PROTECTED_METHODS = ("POST", "PUT", "PATCH", "DELETE")&lt;/code&gt; tuple in &lt;code&gt;core.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The remaining findings were smaller plumbing bugs that still would have caused headaches in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Vue SDK's &lt;code&gt;solvePow()&lt;/code&gt; helper generated its own random salt instead of hashing the server's signed &lt;code&gt;pow_salt&lt;/code&gt;, so Vue proof-of-work solutions could never pass verification. React and Vue also kept reusing a consumed single-use challenge in SPAs instead of fetching a fresh one after submission.&lt;/li&gt;
&lt;li&gt;The Litestar route guard was missing the 256 KB body cap enforced by the other five adapters and returned &lt;code&gt;403&lt;/code&gt; instead of &lt;code&gt;429&lt;/code&gt; when asking a client for proof-of-work.&lt;/li&gt;
&lt;li&gt;Event timestamp freshness checks in &lt;code&gt;tokens.py&lt;/code&gt; only inspected &lt;code&gt;"t"&lt;/code&gt;, even though keystroke extractors also read &lt;code&gt;"down"&lt;/code&gt;, &lt;code&gt;"up"&lt;/code&gt;, and &lt;code&gt;"time"&lt;/code&gt; (and didn't exclude Python &lt;code&gt;bool&lt;/code&gt;, which is a subclass of &lt;code&gt;int&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Enabling &lt;code&gt;extension-module&lt;/code&gt; directly on &lt;code&gt;pyo3&lt;/code&gt; in &lt;code&gt;Cargo.toml&lt;/code&gt; worked on Windows locally, where MSVC links &lt;code&gt;python3xx.lib&lt;/code&gt; anyway, and broke &lt;code&gt;cargo test&lt;/code&gt; on Linux in CI because &lt;code&gt;extension-module&lt;/code&gt; suppresses &lt;code&gt;-lpython&lt;/code&gt;. Making it an optional Cargo feature enabled by Maturin fixed Linux builds.&lt;/li&gt;
&lt;li&gt;The standalone FastAPI gateway (&lt;code&gt;main.py&lt;/code&gt;) had drifted behind &lt;code&gt;core.py&lt;/code&gt;: &lt;code&gt;/metrics&lt;/code&gt; was open without authentication, CGNAT sessions weren't salted with a User-Agent hash, and raw IPs were written to local logs even when &lt;code&gt;SYNAPSE_PRIVACY_MODE&lt;/code&gt; was set to &lt;code&gt;hash&lt;/code&gt; or &lt;code&gt;strict&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Testing the test suite with mutation testing
&lt;/h2&gt;

&lt;p&gt;Each of those 10 bugs now has regression tests pinning the fix, bringing the repo to 536 Python tests, 78 Vitest SDK tests, and 42 Rust unit tests (~88% line and branch coverage in Python).&lt;/p&gt;

&lt;p&gt;Since line coverage doesn't tell you whether assertions actually catch broken logic, I also tried mutation testing (&lt;code&gt;mutmut&lt;/code&gt;) on &lt;code&gt;tokens.py&lt;/code&gt;, &lt;code&gt;core.py&lt;/code&gt;, and &lt;code&gt;storage.py&lt;/code&gt;. It edits your source code one operator at a time (turning &lt;code&gt;&amp;lt;&lt;/code&gt; into &lt;code&gt;&amp;lt;=&lt;/code&gt; or deleting an early return) and checks whether pytest fails.&lt;/p&gt;

&lt;p&gt;My first full run reported a 92.1% mutation score. That felt great for about an hour, until I realized a bug in my runner had left mutated files sitting on disk across runs and inflated the kill count. After throwing that result out and restoring clean source before every mutant, the real number settled around 88% across 1,145 evaluated mutants. That run happened right before this last batch of patches, so the newest code still needs its weekly CI mutation run.&lt;/p&gt;
&lt;h2&gt;
  
  
  Two breaking changes in v0.10.5
&lt;/h2&gt;

&lt;p&gt;If you're upgrading from an earlier &lt;code&gt;0.10.x&lt;/code&gt; release, check two things first:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;DELETE&lt;/code&gt; requests to protected paths now require a token and return HTTP 403 without one. Since &lt;code&gt;DELETE&lt;/code&gt; requests rarely carry a JSON body, pass the token in the &lt;code&gt;X-Synapse-Token&lt;/code&gt; header.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /metrics&lt;/code&gt; on the standalone gateway now requires your admin secret (&lt;code&gt;X-Admin-Secret&lt;/code&gt; or &lt;code&gt;Authorization: Bearer&lt;/code&gt;). Add that header to your scraper if you poll it.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  What I still don't know
&lt;/h2&gt;

&lt;p&gt;All of my human test traces pass, mobile single-taps included, though synthetic fixtures are no substitute for messy live traffic and assistive tools. I still don't have a real false-positive rate from production visitors. Next on my list is running a shadow-mode pilot (&lt;code&gt;mode="shadow"&lt;/code&gt;), where Synapse Shield scores and logs traffic without blocking anyone.&lt;/p&gt;

&lt;p&gt;No human security researcher has audited the codebase yet either. If a cross-model Red Team pass turned up 10 real bugs in code I thought was ready to release, a dedicated human auditor will probably find more.&lt;/p&gt;
&lt;h2&gt;
  
  
  Trying it out
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install synapse-shield
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you test it on your own app, start in shadow mode (&lt;code&gt;mode="shadow"&lt;/code&gt;) and inspect what it flags on your own visitors before switching to &lt;code&gt;mode="enforce"&lt;/code&gt;. And if you manage to break it, please send a report through &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield/security/advisories" rel="noopener noreferrer"&gt;GitHub Security Advisories&lt;/a&gt; instead of opening a public issue.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/0xStoic-bit" rel="noopener noreferrer"&gt;
        0xStoic-bit
      &lt;/a&gt; / &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;
        Synapse_Shield
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Next-gen open-source behavioral biometrics &amp;amp; bot mitigation engine. Sub-millisecond (&amp;lt;0.5ms) Turnstile alternative powered by human kinematics (Jerk da/dt), Poisson anomaly detection, and zero-PII telemetry.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;🛡️ Synapse Shield&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Stop bots on your login and signup forms without showing your users a CAPTCHA.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A self-hosted, open-source alternative to Cloudflare Turnstile. It looks at &lt;em&gt;how&lt;/em&gt; a visitor moves, taps and types, never at &lt;em&gt;what&lt;/em&gt; they type.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pypi.org/project/synapse-shield/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/218db2b14f37a7d123735fd4a2a2f8e42332f21f7c21aa788b94cf42b47d80c0/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f73796e617073652d736869656c643f636f6c6f723d303046304646266c6162656c3d70797069" alt="PyPI"&gt;&lt;/a&gt;
&lt;a href="https://github.com/0xStoic-bit/Synapse_Shield/actions" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/0xStoic-bit/Synapse_Shield/actions/workflows/ci.yml/badge.svg" alt="CI"&gt;&lt;/a&gt;
&lt;a href="https://python.org" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/dcdb9a4949f65b74745957dbd6367fe819ba6efc0e8aabdbb7285a8e1224d708/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f507974686f6e2d332e3130254532253830253933332e31342d626c75652e7376673f6c6f676f3d707974686f6e" alt="Python 3.10–3.14"&gt;&lt;/a&gt;
&lt;a href="https://opensource.org/licenses/MIT" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/8d113874389d80d1fb6491e12ff5d38adc44228979b656c8e5a778ba7e410d82/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d3030463046462e737667" alt="License: MIT"&gt;&lt;/a&gt;
&lt;a href="https://github.com/0xStoic-bit/Synapse_Shield/stargazers" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/9c1e0976254b875cc0dd604e1086380cda5cd2f9db07d62b5f606c957b1f32de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f307853746f69632d6269742f53796e617073655f536869656c643f7374796c653d736f6369616c" alt="Stars"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;🌐 English | &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield/blob/main/README_ZH.md" rel="noopener noreferrer"&gt;简体中文&lt;/a&gt;&lt;/p&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/0xStoic-bit/Synapse_Shield/main/docs/assets/how-it-works.gif"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhow-it-works.gif" alt="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" width="760"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Why&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No puzzles.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your server, your data.&lt;/strong&gt; Everything runs on your own machine. No third-party service sees your visitors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No typed text leaves the browser.&lt;/strong&gt; The SDK sends movement and timing only; every typed character is masked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drop-in.&lt;/strong&gt; One middleware line for FastAPI, Django, Flask, Litestar, Sanic or any ASGI app, plus a small browser SDK (plain JS, React or Vue).&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/0xStoic-bit/Synapse_Shield/main/docs/assets/human-vs-bot.gif"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fraw.githubusercontent.com%2F0xStoic-bit%2FSynapse_Shield%2Fmain%2Fdocs%2Fassets%2Fhuman-vs-bot.gif" alt="A human-like cursor path is allowed with risk 0, a Bezier bot path is blocked with risk 100" width="760"&gt;&lt;/a&gt;
&lt;p&gt;Generated from the project's own synthetic traces by &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield/blob/main/scripts/make_readme_gifs.py" rel="noopener noreferrer"&gt;&lt;code&gt;scripts/make_readme_gifs.py&lt;/code&gt;&lt;/a&gt;; the verdicts are the engine's real output on those traces.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;…&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>python</category>
      <category>security</category>
      <category>opensource</category>
      <category>buildinpublic</category>
    </item>
    <item>
      <title>Synapse Shield v0.10.0: Bringing Behavioral Bot Detection to Mobile (Without Building an App)</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Tue, 27 Oct 2026 11:05:01 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/synapse-shield-v0100-bringing-behavioral-bot-detection-to-mobile-without-building-an-app-7km</link>
      <guid>https://dev.to/0xstoic_bit/synapse-shield-v0100-bringing-behavioral-bot-detection-to-mobile-without-building-an-app-7km</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Synapse Shield is an open-source, self-hosted behavioral biometrics engine for bot mitigation. It scores mouse, touch and keystroke dynamics instead of showing CAPTCHAs, and it collects no PII (only relative millisecond timings).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;v0.10.0&lt;/strong&gt; adds the mobile leg: a Mobile SDK v2.0 across the vanilla JS, React and Vue packages, plus matching changes in the Python engine and the native Rust core.&lt;/p&gt;




&lt;h2&gt;
  
  
  The problem: desktop heuristics punish real phones
&lt;/h2&gt;

&lt;p&gt;The first versions were tuned on mouse trajectories. Mobile traffic exposed five false-positive cases, all of which looked like bots to desktop-oriented rules:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Why it was flagged&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Single tap&lt;/strong&gt; (no drag)&lt;/td&gt;
&lt;td&gt;A single point gives the 1D-CNN a zero-padded 60-step tensor, which it scored as a bot. A hard rule also flagged 1-2 mouse points as "teleportation".&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Flick-scroll, then tap elsewhere&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fitts's Law deceleration and click-to-cursor distance checks assume a persistent cursor.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;iOS / WebView &lt;code&gt;radiusX == 0&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Touch radius is quantized or zero, which looked like a synthetic constant-radius touch.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Android Gboard / IME&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Soft keyboards emit &lt;code&gt;key="Unidentified"&lt;/code&gt; with 0-5 ms synthetic dwell times, tripping the mechanical-key rules.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Touch drawing on the demo canvas&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The cockpit canvas only listened for &lt;code&gt;mousemove&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What changed in v0.10.0
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Client SDK (JS, React, Vue)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tap hold time&lt;/strong&gt; (&lt;code&gt;touchend - touchstart&lt;/code&gt;) is recorded as &lt;code&gt;tap_duration_ms&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Touch points carry &lt;code&gt;source: "touch"&lt;/code&gt; and a 3-decimal average radius, so WebViews that report &lt;code&gt;r = 0&lt;/code&gt; can still be recognized as touch input.&lt;/li&gt;
&lt;li&gt;The synthetic &lt;code&gt;click&lt;/code&gt; that browsers fire after &lt;code&gt;touchend&lt;/code&gt; is de-duplicated.&lt;/li&gt;
&lt;li&gt;A passive &lt;code&gt;devicemotion&lt;/code&gt; listener computes &lt;code&gt;motion_variance&lt;/code&gt; (handheld micro-tremor, no permission prompt needed where the browser allows it).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;device_pixel_ratio&lt;/code&gt;, orientation and the WebGL renderer string are included for cross-validation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Engine rules
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GPU mismatch:&lt;/strong&gt; a mobile-sized touch viewport reporting &lt;code&gt;SwiftShader&lt;/code&gt;, &lt;code&gt;llvmpipe&lt;/code&gt; or a desktop NVIDIA/AMD renderer scores +85 risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tap timing:&lt;/strong&gt; an average tap under 8 ms scores +55. Three or more taps with near-zero duration variance score +50. A tap of 15-800 ms is a small bonus.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IME-aware keystrokes:&lt;/strong&gt; &lt;code&gt;Unidentified&lt;/code&gt; / &lt;code&gt;Process&lt;/code&gt; keys are exempt from the mechanical dwell-time penalties. Flight-time and entropy checks still apply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Short touch sessions:&lt;/strong&gt; the desktop 1D-CNN is skipped below 12 points on touch devices, Fitts's Law is not applied to touch, and click-to-cursor compares against the &lt;em&gt;nearest&lt;/em&gt; recorded touch point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Rust parity
&lt;/h3&gt;

&lt;p&gt;The six new features (&lt;code&gt;tap_count&lt;/code&gt;, &lt;code&gt;avg_tap_duration&lt;/code&gt;, &lt;code&gt;tap_duration_var&lt;/code&gt;, &lt;code&gt;device_pixel_ratio&lt;/code&gt;, &lt;code&gt;motion_variance&lt;/code&gt;, &lt;code&gt;is_mobile_gpu_mismatch&lt;/code&gt;) exist in both the Rust SIMD core (&lt;code&gt;synapse_core_rs&lt;/code&gt;) and the Python fallback. A new parity test runs both implementations on the same telemetry and compares the results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verifying it
&lt;/h2&gt;

&lt;p&gt;The full suite passes with 141 tests, including new cases for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a genuine single tap&lt;/li&gt;
&lt;li&gt;iOS-style zero-radius touches&lt;/li&gt;
&lt;li&gt;Android IME typing&lt;/li&gt;
&lt;li&gt;swipe followed by a distant tap&lt;/li&gt;
&lt;li&gt;an emulator spoof (NVIDIA renderer on a 390 px touch viewport with a 2 ms tap), which is blocked&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a new &lt;code&gt;mobile_emulator_spoof_plugin&lt;/code&gt; in the built-in red-team orchestrator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install -U synapse-shield
synapse-shield run --port 8000
synapse-shield redteam
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Honest limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The models and thresholds were validated on synthetic and hand-built telemetry. Real-world device diversity (old Android builds, cracked screens, unusual WebViews) still needs field data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;devicemotion&lt;/code&gt; availability varies by browser and permission policy, so it is a bonus signal, never a requirement.&lt;/li&gt;
&lt;li&gt;This is a web SDK for mobile browsers, PWAs and WebViews. There is no native Swift or Kotlin SDK yet.&lt;/li&gt;
&lt;li&gt;It does not do TLS / JA3 fingerprinting, so it works at the application layer only.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Field data collection to recalibrate the mobile thresholds&lt;/li&gt;
&lt;li&gt;A native mobile bridge&lt;/li&gt;
&lt;li&gt;Network-layer fingerprinting through a reverse-proxy plugin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback, issues and PRs are welcome. If you try it on a real device fleet, I would like to hear which false positives you hit.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>security</category>
      <category>python</category>
      <category>rust</category>
    </item>
    <item>
      <title>Synapse Shield v0.9.8: Red-Teaming Our Rust + 1D-CNN Bot Mitigation Engine &amp; Introducing Shadow Mode</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Tue, 20 Oct 2026 08:12:31 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/synapse-shield-v098-red-teaming-our-rust-1d-cnn-bot-mitigation-engine-introducing-shadow-mode-15no</link>
      <guid>https://dev.to/0xstoic_bit/synapse-shield-v098-red-teaming-our-rust-1d-cnn-bot-mitigation-engine-introducing-shadow-mode-15no</guid>
      <description>&lt;p&gt;Traditional CAPTCHAs hurt user conversion rates while increasingly failing to stop vision-LLM solvers and stealth browser automation frameworks (&lt;code&gt;playwright-extra&lt;/code&gt;, &lt;code&gt;nodriver&lt;/code&gt;, &lt;code&gt;ghost-cursor&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synapse Shield&lt;/strong&gt; takes a different approach: zero-CAPTCHA, invisible behavioral biometrics powered by a native &lt;strong&gt;Rust (PyO3 + AVX2 SIMD)&lt;/strong&gt; core and a pure-NumPy &lt;strong&gt;1D-CNN Micro-Brain&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With the release of &lt;strong&gt;&lt;code&gt;v0.9.8&lt;/code&gt;&lt;/strong&gt;, the engine introduces major adversarial security hardening, &lt;strong&gt;Shadow Mode&lt;/strong&gt; for zero-risk production rollouts, &lt;strong&gt;1-line Frontend SDK interceptors&lt;/strong&gt;, &lt;strong&gt;Zero-PII GDPR hashing&lt;/strong&gt;, and &lt;strong&gt;Alpine Linux (&lt;code&gt;musllinux&lt;/code&gt;)&lt;/strong&gt; native binary wheels.&lt;/p&gt;

&lt;p&gt;Here is a technical deep dive into how the 5-layer defense architecture works, the adversarial bypass vectors we patched during our internal red-team audit, and what is new in &lt;code&gt;v0.9.8&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 The 5-Layer Defense Architecture
&lt;/h2&gt;

&lt;p&gt;Instead of interrupting users with visual puzzles, Synapse Shield evaluates human neuro-mechanics invisibly in the background:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Layer 1 — Cryptographic Challenge &amp;amp; Replay Defense:&lt;/strong&gt; HMAC-SHA256 signed one-time challenges backed by sub-microsecond ($\sim 15\text{ ns}$) Two-Bucket Rust L1 + SQLite/Redis atomic nonce consumption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 2 — 19D Neuromuscular Kinematics (Rust AVX2 SIMD):&lt;/strong&gt; Computes 3rd-derivative Jerk ($d^3x/dt^3$), differential curvature ($\kappa(t)$), Fitts's Law terminal deceleration, sub-movement peak decomposition, and FFT spectral entropy to separate biological $8\text{–}12\text{ Hz}$ physiological tremor from synthetic Bézier and Minimum-Jerk trajectories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 3 — 1D-CNN Micro-Brain:&lt;/strong&gt; A 60-step temporal convolutional neural network running in pure NumPy ($\sim 0.3\text{ ms}$ inference latency, zero PyTorch/TensorFlow runtime overhead).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 4 — Anti-Stealth &amp;amp; Prototype Tamper Detection:&lt;/strong&gt; Identifies &lt;code&gt;navigator.webdriver&lt;/code&gt; prototype overrides, mocked &lt;code&gt;PluginArray&lt;/code&gt; instances, and Canvas/WebGL hooks via clean iframe &lt;code&gt;Function.prototype.toString&lt;/code&gt; inspection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 5 — Network Anomaly &amp;amp; Gray-Area PoW:&lt;/strong&gt; Combines Poisson request-arrival distribution ($\lambda=2.0$) with an automatic WebCrypto SHA-256 Proof-of-Work challenge for gray-area risk scores ($35 \le \text{score} \le 65$).&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  ⚔️ Red-Teaming the Engine: Adversarial Fixes in &lt;code&gt;v0.9.8&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;When building an open-source security library, you must assume sophisticated attackers will read the source code to look for edge cases. For &lt;code&gt;v0.9.8&lt;/code&gt;, we audited every layer of the engine from an adversarial perspective and closed several subtle evasion vectors:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Defeating the "Privacy Browser Camouflage" Bypass
&lt;/h3&gt;

&lt;p&gt;Privacy-focused browsers like &lt;strong&gt;Brave&lt;/strong&gt; intentionally farble WebGL and Canvas APIs (&lt;code&gt;is_webgl_hooked = true&lt;/code&gt;). To prevent false positives for privacy-conscious users, the engine previously capped the risk score at &lt;code&gt;34.0&lt;/code&gt; when basic trajectory straightness and jerk appeared organic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Evasion Vector:&lt;/strong&gt; An attacker generating a synthetic harmonic sine-wave trajectory could inject &lt;code&gt;"is_webgl_hooked": true&lt;/code&gt; into the browser telemetry object—camouflaging the bot as a privacy browser to force the score cap at &lt;code&gt;34.0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;v0.9.8&lt;/code&gt; Patch:&lt;/strong&gt; Privacy browser score capping now cross-checks &lt;strong&gt;FFT Spectral Purity&lt;/strong&gt;, &lt;strong&gt;Differential Curvature ($\kappa(t)$)&lt;/strong&gt;, &lt;strong&gt;Sub-movement decomposition&lt;/strong&gt;, &lt;strong&gt;Timer Variance (&lt;code&gt;dt_var&lt;/code&gt;)&lt;/strong&gt;, &lt;strong&gt;Session Behavioral Invariance&lt;/strong&gt;, and &lt;strong&gt;1D-CNN AI confidence&lt;/strong&gt;. Genuine privacy browser users still pass without friction, while camouflaged bots are blocked at &lt;code&gt;100%&lt;/code&gt; risk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Closing the "Micro-Path" ($N \le 5$ Points) Loophole
&lt;/h3&gt;

&lt;p&gt;Previously, full kinematic curve heuristics only engaged when &lt;code&gt;mouse_points &amp;gt; 5&lt;/code&gt;. A bot sending a 4-point ruler-straight line (&lt;code&gt;straightness = 1.0&lt;/code&gt;, &lt;code&gt;jerk = 0.0&lt;/code&gt;) could slip between the "zero-mouse" rule and the 6-point kinematic analyzer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;v0.9.8&lt;/code&gt; Patch:&lt;/strong&gt; Kinematic straightness, velocity variance, and jerk checks now engage down to 3 points, and synthetic desktop micro-teleports ($1\text{–}2$ points prior to interaction) are automatically penalized.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Hardening "Time-Travel" &amp;amp; Stale Telemetry Detection
&lt;/h3&gt;

&lt;p&gt;The Time-Travel defense stops bots from stuffing 10 seconds of pre-recorded mouse telemetry into a 1.6-second challenge window (&lt;code&gt;max(t) - min(t) &amp;gt; elapsed&lt;/code&gt;).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;v0.9.8&lt;/code&gt; Patch:&lt;/strong&gt; Added strict numeric validation on all event timestamps (preventing non-numeric values from triggering a fallback exception) and bound event timestamps to the cryptographic token's &lt;code&gt;challenge_ts&lt;/code&gt; creation window so pre-recorded human trajectories from past sessions cannot be replayed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Multi-Worker (&lt;code&gt;uvicorn --workers N&lt;/code&gt;) Write-Through Sync &amp;amp; Dwell-Time Parity
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Worker State Consistency:&lt;/strong&gt; Ensured write-through persistence between the Rust L1 cache and SQLite/Redis alongside automatic expired-ban eviction, eliminating cross-worker replay windows and memory growth during sustained attacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keystroke Dwell &amp;amp; Flight Pairing:&lt;/strong&gt; Synchronized browser SDK &lt;code&gt;keydown&lt;/code&gt;/&lt;code&gt;keyup&lt;/code&gt; event pairing with the Rust/Python keystroke dynamics analyzer for sub-millisecond dwell-time variance and digraph entropy accuracy.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 New Enterprise &amp;amp; Developer Experience Features in &lt;code&gt;v0.9.8&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Shadow Mode (&lt;code&gt;mode="shadow"&lt;/code&gt;) for Safe Production Rollouts
&lt;/h3&gt;

&lt;p&gt;Engineering teams rarely want to enable hard blocking (&lt;code&gt;HTTP 403&lt;/code&gt;) on Day 1 in production. You can now deploy Synapse Shield in &lt;strong&gt;Shadow Mode&lt;/strong&gt; across FastAPI, Litestar, Sanic, Django, Flask, and pure ASGI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;synapse_shield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asgi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;SynapseShieldASGIMiddleware&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Analyzes every request, records Prometheus metrics, and attaches&lt;/span&gt;
&lt;span class="c1"&gt;# X-Synapse-Decision: shadow-block headers WITHOUT blocking live traffic!&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;SynapseShieldASGIMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;protected_paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/api/auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;max_risk_score&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;50.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"shadow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# Switch to "enforce" once validated&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. 1-Line Frontend Interceptors (&lt;code&gt;protectFetch&lt;/code&gt; &amp;amp; &lt;code&gt;protectAxios&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;You no longer need to manually embed tokens inside JSON request bodies. Passing the token via the &lt;strong&gt;&lt;code&gt;X-Synapse-Token&lt;/code&gt;&lt;/strong&gt; HTTP header eliminates schema conflicts with strict Pydantic (&lt;code&gt;extra="forbid"&lt;/code&gt;) models and allows seamless protection for &lt;code&gt;multipart/form-data&lt;/code&gt; file uploads and URL-encoded forms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Automatically attaches X-Synapse-Token header to matching routes&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;SynapseShield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;SynapseShield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;protectFetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/api/auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Or with Axios:&lt;/span&gt;
&lt;span class="nc"&gt;SynapseShield&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;protectAxios&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;axiosInstance&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/api/auth"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Zero-PII GDPR Mode (&lt;code&gt;SYNAPSE_PRIVACY_MODE=hash&lt;/code&gt;) &amp;amp; Auto-TTL Pruning
&lt;/h3&gt;

&lt;p&gt;For strict GDPR/privacy compliance, setting &lt;code&gt;SYNAPSE_PRIVACY_MODE=hash&lt;/code&gt; replaces client IP addresses with a daily-rotating salted &lt;code&gt;HMAC-SHA256&lt;/code&gt; digest (&lt;code&gt;anon_8f3a...&lt;/code&gt;) before any data touches disk or logs. Additionally, automatic TTL retention (&lt;code&gt;SYNAPSE_LOG_RETENTION_DAYS=14&lt;/code&gt;) prunes old telemetry records automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Lightweight Core &amp;amp; Alpine Linux (&lt;code&gt;musllinux&lt;/code&gt;) Native Wheels
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Minimal Core Footprint:&lt;/strong&gt; &lt;code&gt;pip install synapse-shield&lt;/code&gt; now only requires &lt;code&gt;numpy&lt;/code&gt;. Server and dashboard dependencies (&lt;code&gt;fastapi&lt;/code&gt;, &lt;code&gt;uvicorn&lt;/code&gt;, &lt;code&gt;websockets&lt;/code&gt;) are isolated into optional extras (&lt;code&gt;pip install "synapse-shield[cockpit]"&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full Static Typing:&lt;/strong&gt; Includes PEP 561 &lt;code&gt;py.typed&lt;/code&gt; and &lt;code&gt;synapse_core_rs.pyi&lt;/code&gt; type stubs for full IDE autocompletion and &lt;code&gt;mypy&lt;/code&gt;/&lt;code&gt;pyright&lt;/code&gt; checks across the Rust boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alpine Docker Support:&lt;/strong&gt; Added pre-compiled &lt;code&gt;musllinux&lt;/code&gt; wheels alongside &lt;code&gt;manylinux&lt;/code&gt;, Windows, and macOS (Intel &amp;amp; Apple Silicon) for Python 3.10 through 3.14—allowing &lt;code&gt;FROM python:3.12-alpine&lt;/code&gt; containers to install the native binary in 1 second without a Rust toolchain.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Quick Start
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Lightweight core (for Django, Flask, Litestar, Sanic, or ASGI)&lt;/span&gt;
pip install -U synapse-shield

&lt;span class="c"&gt;# Or with the real-time Cyber-Cockpit &amp;amp; FastAPI server&lt;/span&gt;
pip install -U &lt;span class="s2"&gt;"synapse-shield[cockpit]"&lt;/span&gt;
synapse-shield start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>rust</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How We Audited and Hardened an Open-Source Anti-Bot Engine for Production (Synapse Shield v0.9.3)</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Sun, 04 Oct 2026 06:40:02 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/how-we-audited-and-hardened-an-open-source-anti-bot-engine-for-production-synapse-shield-v093-4abm</link>
      <guid>https://dev.to/0xstoic_bit/how-we-audited-and-hardened-an-open-source-anti-bot-engine-for-production-synapse-shield-v093-4abm</guid>
      <description>&lt;p&gt;Building a bot detection engine is challenging, but making it resilient against adversarial attacks, denial-of-service (DoS), and subtle concurrency bottlenecks in production is an entirely different battle.&lt;/p&gt;

&lt;p&gt;A few days ago, we conducted an end-to-end security and algorithmic audit on &lt;strong&gt;Synapse Shield&lt;/strong&gt;—our open-source, privacy-first alternative to commercial CAPTCHAs and proprietary cloud WAFs.&lt;/p&gt;

&lt;p&gt;In this post, we'll walk through the actual architectural vulnerabilities we identified, how we patched them in &lt;strong&gt;v0.9.3&lt;/strong&gt;, and what you can learn when designing high-throughput Python and Rust security middleware.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Synapse Shield?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;Synapse Shield&lt;/a&gt; is a self-hosted, sub-millisecond bot mitigation engine. Instead of forcing legitimate users to click distorted fire hydrants or crosswalks, it analyzes behavioral biometrics (neuromuscular micro-tremors via jerk analysis, differential cursor curvature κ(t), and keystroke dynamics) along with network kinematics using a hybrid &lt;strong&gt;Python + Rust SIMD&lt;/strong&gt; core.&lt;/p&gt;

&lt;p&gt;However, security software must itself be impervious to abuse. Here are the vulnerabilities we audited, the real-world risks they posed, and how we resolved them.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Algorithmic DoS: The Poisson Factorial Bottleneck
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;To detect abnormal request velocity (rate anomalies), we evaluate Poisson distribution probabilities for incoming IP request spikes. In earlier iterations, the cumulative probability was calculated using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Vulnerable code:&lt;/span&gt;
&lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lambda_val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lambda_val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When an attacker flooded the endpoint with high request bursts (k &amp;gt;= 500), &lt;code&gt;math.factorial(i)&lt;/code&gt; rapidly consumed excessive CPU cycles and raised an &lt;code&gt;OverflowError&lt;/code&gt;. This opened up an &lt;strong&gt;Algorithmic Denial-of-Service (DoS / CPU Starvation)&lt;/strong&gt; vector: an attacker could deliberately trigger extreme CPU exhaustion simply by generating large request counts.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix
&lt;/h3&gt;

&lt;p&gt;In v0.9.3, we replaced factorial computation with an O(1) iterative multiplicative recurrence. Furthermore, because Poisson cumulative probability approaches 1.0 when k &amp;gt;= 30 under standard baselines, we added a fast short-circuit cutoff:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Hardened v0.9.3 implementation:&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;poisson_anomaly_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lambda_val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;  &lt;span class="c1"&gt;# Instant thresholding: avoids unnecessary math loops&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lambda_val&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

    &lt;span class="n"&gt;cumulative_prob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
    &lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lambda_val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;lambda_val&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
        &lt;span class="n"&gt;cumulative_prob&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;term&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cumulative_prob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Execution time dropped to &lt;strong&gt;&amp;lt; 0.1 ms&lt;/strong&gt;, completely eliminating CPU starvation even under 100,000 incoming burst counts.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Keystroke Dynamics: O(N²) List Shifting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;During client-side keystroke hold-time analysis, timestamps for &lt;code&gt;keydown&lt;/code&gt; and &lt;code&gt;keyup&lt;/code&gt; events are paired. The previous implementation used a standard Python list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Vulnerable code:&lt;/span&gt;
&lt;span class="n"&gt;down_t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pending_downs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k_code&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# O(N) memory shift operation!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Python, &lt;code&gt;list.pop(0)&lt;/code&gt; shifts every subsequent element in memory to the left, making it an O(N) operation. When a user or scraper submitted long text inputs, the overall tokenization degraded to &lt;strong&gt;O(N²)&lt;/strong&gt;, blocking the asynchronous Event Loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix
&lt;/h3&gt;

&lt;p&gt;We switched the queue data structure to &lt;code&gt;collections.deque&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;

&lt;span class="n"&gt;pending_downs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;span class="n"&gt;down_t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pending_downs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k_code&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# True O(1) popping&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;popleft()&lt;/code&gt;, element extraction is now strictly O(1), ensuring zero event loop stalling even on massive typing payloads.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Reverse Proxy IP Spoofing &amp;amp; IPv4-Mapped IPv6 Masking
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;In modern deployments, microservices sit behind Cloudflare, Nginx, or AWS ALBs. Blindly trusting &lt;code&gt;X-Forwarded-For&lt;/code&gt; or &lt;code&gt;X-Real-IP&lt;/code&gt; headers allows attackers to spoof their IP address.&lt;/p&gt;

&lt;p&gt;Additionally, IPv4-mapped IPv6 addresses (e.g., &lt;code&gt;::ffff:192.168.1.1&lt;/code&gt;) caused subnet masking routines to misclassify addresses or fail strict GDPR/KVKK anonymization policies.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Trusted Proxies:&lt;/strong&gt; Added the &lt;code&gt;SYNAPSE_TRUSTED_PROXIES&lt;/code&gt; environment variable configuration to restrict header traversal strictly to recognized proxies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proper IPv6 Normalization &amp;amp; Unwrapping:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;mask_ip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip_str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""GDPR/KVKK compliance: Mask the last octet of IPv4 or last 4 blocks of IPv6."""&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ip_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip_str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# Unwrap IPv4-mapped IPv6 addresses (e.g., ::ffff:10.0.0.1 -&amp;gt; 10.0.0.1)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ipv4_mapped"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ipv4_mapped&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;network&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ip_network&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{ip}/24"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strict&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{network.network_address.exploded.rsplit('.', 1)[0]}.*"&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;network&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ipaddress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ip_network&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{ip}/64"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strict&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;prefix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;network_address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exploded&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{':'.join(prefix)}:*:*:*:*"&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"unknown"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Preventing Arbitrary Code Execution on Model Loading &amp;amp; Path Traversal
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;Synapse Shield uses pre-trained neural weights to evaluate client-side trajectory kinematics. Using &lt;code&gt;numpy.load(weights_path)&lt;/code&gt; without restrictions can potentially allow arbitrary object unpickling (Arbitrary Code Execution / RCE) if a malicious file replaces the weights. Furthermore, the retrainer module lacked strict path validation.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix
&lt;/h3&gt;

&lt;p&gt;Enforced strict disallowed pickling and explicit canonical path validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# 1. RCE Guard (Pickling strictly disabled):&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weights_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;allow_pickle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conv_w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"conv_w"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Path Traversal Guard (Canonical resolution &amp;amp; extension validation):&lt;/span&gt;
&lt;span class="n"&gt;resolved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abspath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;resolved&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".npz"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Invalid output weights file extension: {output_path} (must be .npz)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Benchmark Results (v0.9.3)
&lt;/h2&gt;

&lt;p&gt;Following the audit, our test suite was updated to cover all targeted attack surfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ pytest tests -q
85 passed, 12 skipped &lt;span class="k"&gt;in&lt;/span&gt; 6.74s &lt;span class="o"&gt;(&lt;/span&gt;100% Success&lt;span class="o"&gt;)&lt;/span&gt;

$ ruff check src tests
All checks passed!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key performance metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Overhead Latency:&lt;/strong&gt; &lt;strong&gt;&amp;lt; 0.5 ms&lt;/strong&gt; per incoming request (microsecond range).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Footprint:&lt;/strong&gt; Capped with O(1) LRU cache eviction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero PII Exposure:&lt;/strong&gt; Fully masked, GDPR/KVKK-compliant network telemetry.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Getting Started in 30 Seconds
&lt;/h2&gt;

&lt;p&gt;You can integrate Synapse Shield into any FastAPI or ASGI application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install synapse-shield
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;synapse_shield&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;SynapseShieldMiddleware&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add Synapse Shield protection middleware&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;SynapseShieldMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;protected_paths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/api/v1/auth/login"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/api/v1/checkout"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"block"&lt;/span&gt;  &lt;span class="c1"&gt;# Options: 'block', 'challenge', 'log'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;root&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"protected"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Open Source &amp;amp; Community
&lt;/h2&gt;

&lt;p&gt;Security is not a static state; it is a continuous process of verification, testing, and refinement. We welcome feedback, code contributions, and security reviews from the community.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;0xStoic-bit/Synapse_Shield&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/synapse-shield/" rel="noopener noreferrer"&gt;pypi.org/project/synapse-shield&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you find this project useful for protecting your endpoints against modern botnets, feel free to give the repository a star ⭐ and share your thoughts in the comments!&lt;/p&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How I Rewrote Synapse Shield in Rust: Achieving Sub-Millisecond Kinematic Biometrics &amp; 15 Multi-Platform Native Wheels with Maturin</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Thu, 24 Sep 2026 19:38:42 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/how-i-rewrote-synapse-shield-in-rust-achieving-sub-millisecond-kinematic-biometrics-15-398a</link>
      <guid>https://dev.to/0xstoic_bit/how-i-rewrote-synapse-shield-in-rust-achieving-sub-millisecond-kinematic-biometrics-15-398a</guid>
      <description>&lt;p&gt;When building an in-process Web Application Firewall (WAF) and bot mitigation system, your margin for latency error is practically zero. &lt;/p&gt;

&lt;p&gt;Traditional CAPTCHAs degrade user experience, and cloud-based WAFs (like Cloudflare or AWS WAF) often inject 100ms to 250ms of network round-trip overhead. With &lt;strong&gt;&lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;Synapse Shield&lt;/a&gt;&lt;/strong&gt;, my objective was clear: &lt;strong&gt;zero user friction (no puzzles, no clicks) and zero external network hops.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Everything had to happen &lt;em&gt;inside the application process&lt;/em&gt; within microseconds.&lt;/p&gt;

&lt;p&gt;In earlier versions (v0.6.x – v0.7.x), the core engine was written entirely in Python. While Python excels at rapid prototyping, orchestrating async web requests, and serving ML inference, it hit a brick wall when handling high-throughput kinematic feature extraction and concurrent state verification under botnet load.&lt;/p&gt;

&lt;p&gt;Here is the technical deep-dive into how I re-engineered Synapse Shield’s core into &lt;strong&gt;Rust (&lt;code&gt;synapse-core-rs&lt;/code&gt;)&lt;/strong&gt;, dropped feature extraction latency from &lt;strong&gt;123 µs to 22 µs&lt;/strong&gt;, replaced SQLite disk bottlenecks with an atomic two-bucket in-memory nonce cache, and automated the cross-compilation of &lt;strong&gt;15 multi-platform native wheels&lt;/strong&gt; using &lt;strong&gt;Maturin&lt;/strong&gt; and GitHub Actions.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Bottlenecks: Why Pure Python Reached Its Limit
&lt;/h2&gt;

&lt;p&gt;To distinguish synthetic mouse and keyboard movements (generated by Puppeteer, Playwright, or Selenium) from biological humans, Synapse Shield extracts 24 kinematic and biometric features over time-series telemetry:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Third-order derivatives (Jerk: $d^3x/dt^3$):&lt;/strong&gt; Detecting neuromuscular micro-tremors (8–12 Hz) that algorithmic bots either omit or fake with naive Gaussian jitter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fitts’ Law Terminal Deceleration:&lt;/strong&gt; Biological motor control naturally decelerates in the final 25% of a ballistic trajectory as visual feedback guides the cursor to the target.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Euclidean Straightness &amp;amp; Curvature:&lt;/strong&gt; Ratio of displacement to path length ($\frac{D}{\sum \Delta s}$).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Power Spectral Density &amp;amp; Spectral Entropy:&lt;/strong&gt; Discrete Fast Fourier Transforms (RFFT) on velocity vectors.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       [ Client Telemetry (x, y, t) ]
                      │
                      ▼
   ┌─────────────────────────────────────┐
   │        Kinematic Differentiation    │
   │  Velocity (dx/dt) -&amp;gt; Accel -&amp;gt; Jerk  │
   ├─────────────────────────────────────┤
   │     Spectral Analysis (RFFT/PSD)    │
   ├─────────────────────────────────────┤
   │   Two-Bucket Nonce Replay Check     │
   └─────────────────────────────────────┘
                      │
                      ▼
             [ Bot / Human Score ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Problems Encountered:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;GIL and Loop Overhead:&lt;/strong&gt; Iterating over 150–300 trajectory points, calculating trigonometric arc distances, and running continuous numerical differentiations in Python loops incurred significant interpreter overhead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Allocation Churn:&lt;/strong&gt; Dynamically allocating dozens of temporary lists per request under 5,000 req/s triggered aggressive Python garbage collection cycles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite Disk Locks under DDoS:&lt;/strong&gt; To prevent replay attacks, nonces were originally written to an atomic SQLite table with WAL mode. Under concurrent spikes, SQLite file lock contention (&lt;code&gt;sqlite3.OperationalError: database is locked&lt;/code&gt;) degraded throughput and increased p99 latency to over 15ms.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The solution was obvious: &lt;strong&gt;Extract the CPU-intensive numerical math and the high-concurrency state management into a compiled, memory-safe Rust extension.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Re-engineering Kinematics in Rust
&lt;/h2&gt;

&lt;p&gt;In Rust (&lt;code&gt;crates/synapse_core_rs/src/kinematics.rs&lt;/code&gt;), we process raw telemetry without heap allocations wherever possible, passing continuous slices and pre-allocating vectors with &lt;code&gt;Vec::with_capacity&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Calculating Neuromuscular Jerk ($d^3x/dt^3$)
&lt;/h3&gt;

&lt;p&gt;Synthetic curves (like Bézier or linear interpolation) look smooth to the naked eye, but in the 3rd derivative, their jerk profile collapses to zero or produces unnatural step functions. &lt;/p&gt;

&lt;p&gt;Here is how we calculate discrete accelerations and absolute jerk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Accelerations &amp;amp; Jerk extraction in Rust&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with_capacity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;acc_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;avg_acc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;acc_count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;feat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;avg_acceleration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;avg_acc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;feat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;acceleration_var&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;avg_acc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;powi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="o"&gt;::&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;acc_count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;jerks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with_capacity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;jerks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;accelerations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;jerks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;jerk_sum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jerks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;feat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;avg_jerk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jerk_sum&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jerks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Discrete Spectral Analysis (RFFT) Without Heavy External BLAS
&lt;/h3&gt;

&lt;p&gt;Rather than pulling in massive C-libraries (like FFTW) which complicate cross-compilation, we implemented a lightweight Discrete Real Fourier Transform optimized for small sequences ($N \le 300$ points):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;compute_spectral_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;avg_vel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;feat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nc"&gt;ExtractedFeatures&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;num_freqs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;psd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with_capacity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_freqs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;v_centered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;velocities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;avg_vel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_freqs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;im&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;angle_factor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;consts&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;v_centered&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;angle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;angle_factor&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;re&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;im&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;power&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;im&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;im&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;psd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Compute Spectral Purity &amp;amp; Spectral Entropy...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Sub-Microsecond Nonce Cache: The Two-Bucket Architecture
&lt;/h2&gt;

&lt;p&gt;To prevent token replay attacks without touching the disk or invoking SQLite locks, we engineered a &lt;strong&gt;Two-Bucket In-Memory State Engine&lt;/strong&gt; wrapped in an &lt;code&gt;RwLock&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;StateEngine&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;current_bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HashSet&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;previous_bucket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HashSet&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;last_rotation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;window_duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;ip_bans&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HashMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;u64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Two Buckets?
&lt;/h3&gt;

&lt;p&gt;If you store nonces in a single hash set with individual TTLs, you must either run a background sweep thread (which causes locking pauses) or store timestamps with every entry (increasing memory overhead).&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;Two Buckets&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nonces are inserted into &lt;code&gt;current_bucket&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;window_duration&lt;/code&gt; (e.g., 60 seconds) expires, &lt;code&gt;previous_bucket&lt;/code&gt; is replaced with &lt;code&gt;current_bucket&lt;/code&gt; via &lt;code&gt;std::mem::replace&lt;/code&gt;, and a new, clean &lt;code&gt;current_bucket&lt;/code&gt; is initialized.&lt;/li&gt;
&lt;li&gt;Checking a nonce requires checking &lt;code&gt;current_bucket.contains()&lt;/code&gt; or &lt;code&gt;previous_bucket.contains()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt; $O(1)$ lookups and $O(1)$ rotation, zero disk I/O, sub-microsecond latency ($&amp;lt; 0.8\ \mu s$).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;consume_nonce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;maybe_rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Check if seen in either active window&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;previous_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Replay attack detected!&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current_bucket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Bridging Rust to Python via PyO3
&lt;/h2&gt;

&lt;p&gt;Using &lt;strong&gt;PyO3&lt;/strong&gt;, exposing our Rust engine to Python required zero boilerplate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;pyo3&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;prelude&lt;/span&gt;&lt;span class="o"&gt;::*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;pyo3&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;PyDict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PyAny&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cp"&gt;#[pyfunction]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;extract_features_rs&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'py&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Python&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'py&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;telemetry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;Bound&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'py&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PyAny&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;PyResult&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Bound&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'py&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PyDict&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parse_python_telemetry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;telemetry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;feat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;compute_kinematics&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;features_to_pydict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;feat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cp"&gt;#[pymodule]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;synapse_core_rs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;Bound&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;'_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PyModule&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;PyResult&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;wrap_pyfunction!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_rust_core_active&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;wrap_pyfunction!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;extract_features_rs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;wrap_pyfunction!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;consume_nonce_rs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;wrap_pyfunction!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_ip_banned_rs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Seamless Python Fallback
&lt;/h3&gt;

&lt;p&gt;In Python, we gracefully detect whether the native binary is present. If someone installs on an unsupported embedded architecture, it smoothly falls back to pure Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;synapse_core_rs&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;_core&lt;/span&gt;
    &lt;span class="no"&gt;RUST_CORE_AVAILABLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ImportError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;_core&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="no"&gt;RUST_CORE_AVAILABLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;extract_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;telemetry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;RUST_CORE_AVAILABLE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extract_features_rs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;telemetry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;_python_fallback_extract_features&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;telemetry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Shipping 15 Multi-Platform Native Wheels with Maturin
&lt;/h2&gt;

&lt;p&gt;The biggest hurdle with compiled C/Rust extensions in Python is &lt;strong&gt;user distribution&lt;/strong&gt;. If a user does &lt;code&gt;pip install your-package&lt;/code&gt; and their machine triggers &lt;code&gt;cargo build&lt;/code&gt; without a Rust toolchain installed, the installation fails.&lt;/p&gt;

&lt;p&gt;We solved this by using &lt;strong&gt;&lt;a href="https://github.com/PyO3/maturin" rel="noopener noreferrer"&gt;Maturin&lt;/a&gt;&lt;/strong&gt; paired with GitHub Actions matrix builds to generate pre-compiled binary wheels for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux:&lt;/strong&gt; &lt;code&gt;manylinux_2_17&lt;/code&gt; and &lt;code&gt;musllinux_1_1&lt;/code&gt; (x86_64, aarch64) across CPython 3.9, 3.10, 3.11, 3.12, and 3.13.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;macOS:&lt;/strong&gt; &lt;code&gt;universal2&lt;/code&gt; (supporting both Apple Silicon M-series and Intel x86_64).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows:&lt;/strong&gt; MSVC x86_64.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The GitHub Actions Workflow Snippet:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build Native Wheels&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'v*'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build_wheels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Wheel on ${{ matrix.os }} (${{ matrix.target }})&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.os }}&lt;/span&gt;
    &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;matrix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;include&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;os&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;x86_64-unknown-linux-gnu&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;os&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aarch64-unknown-linux-gnu&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;os&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;macos-latest&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;universal2-apple-darwin&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;os&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;windows-latest&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;x86_64-pc-windows-msvc&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-python@v5&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;python-version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3.12'&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install Rust toolchain&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dtolnay/rust-toolchain@stable&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.target }}&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build Wheels with Maturin&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PyO3/maturin-action@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.target }}&lt;/span&gt;
          &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;--release --out dist -m crates/synapse_core_rs/Cargo.toml&lt;/span&gt;
          &lt;span class="na"&gt;manylinux&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;auto&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When users run &lt;code&gt;pip install synapse-shield&lt;/code&gt;, pip automatically pulls the pre-built &lt;code&gt;.whl&lt;/code&gt; for their exact OS and Python ABI. &lt;strong&gt;Zero C++ compilers, zero Rust toolchains required on the client machine.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Benchmarks: 10,000-Request Stress Test
&lt;/h2&gt;

&lt;p&gt;To validate the architecture, we ran an adversarial benchmark simulating a high-rate botnet assault (10,000 continuous requests across 50 worker threads).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Pure Python (v0.7.x)&lt;/th&gt;
&lt;th&gt;Rust Core (&lt;code&gt;synapse-core-rs&lt;/code&gt; v0.8.2)&lt;/th&gt;
&lt;th&gt;Improvement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Feature Extraction Latency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;123.4 µs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;21.8 µs&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~5.6x faster (82% reduction)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Replay Nonce Verification&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;1,240.0 µs&lt;/code&gt; (SQLite)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;&lt;code&gt;0.7 µs&lt;/code&gt;&lt;/strong&gt; (Two-Bucket)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1,700x faster&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Max Throughput (RPS)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;2,450 req/s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;11,200 req/s&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4.5x higher capacity&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;P99 Defense Latency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;18.2 ms&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;0.84 ms&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Sub-millisecond guaranteed&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dropped / Locked Requests&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;0.42%&lt;/code&gt; (SQLite lock)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;0.00%&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;100% Reliability&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Under saturated load, the pure Python version choked on SQLite locks and GIL context switching. The Rust native engine kept CPU utilization flat and processed all 10,000 requests without a single dropped packet.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Lessons for Systems Engineers
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don't rewrite everything—isolate the hot paths:&lt;/strong&gt; Python is fantastic for FastAPI middleware, configuration parsing, and routing. Rust is unmatched for high-frequency differentiation, cryptographic hashing, and atomic concurrency. PyO3 gives you the best of both worlds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disk I/O has no place in microsecond security pipelines:&lt;/strong&gt; Moving replay attack prevention from SQLite into an in-memory double-buffering scheme (&lt;code&gt;Two-Bucket&lt;/code&gt;) provided the single largest latency win.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maturin makes shipping Rust wheels delightful:&lt;/strong&gt; Building cross-platform binary wheels used to require terrifying Docker setups. With &lt;code&gt;maturin-action&lt;/code&gt;, distributing native extensions to PyPI is now as straightforward as publishing pure Python packages.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Links &amp;amp; Source Code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📦 &lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/synapse-shield/" rel="noopener noreferrer"&gt;synapse-shield&lt;/a&gt; | &lt;a href="https://pypi.org/project/synapse-core-rs/" rel="noopener noreferrer"&gt;synapse-core-rs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;0xStoic-bit/Synapse_Shield&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📝 &lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are working on bot mitigation, biometric signal processing, or writing high-performance Python extensions in Rust, feel free to star the repo or leave your thoughts below!&lt;/p&gt;

</description>
      <category>rust</category>
      <category>python</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building a 19D Kinematic Biometrics Engine for Bot Mitigation in FastAPI</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Tue, 15 Sep 2026 19:47:19 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/building-a-19d-kinematic-biometrics-engine-for-bot-mitigation-in-fastapi-57ap</link>
      <guid>https://dev.to/0xstoic_bit/building-a-19d-kinematic-biometrics-engine-for-bot-mitigation-in-fastapi-57ap</guid>
      <description>&lt;p&gt;__&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Modern Bot Detection
&lt;/h2&gt;

&lt;p&gt;Most web applications rely on standard rate-limiting (Leaky Bucket, Token Bucket) or invasive third-party CAPTCHA widgets.&lt;/p&gt;

&lt;p&gt;However, modern automated scrapers and headless browser suites (Playwright, Selenium-Stealth, Undetected-Chromedriver) bypass IP-based rate limiters with cheap residential proxies. Meanwhile, forcing human users to click traffic lights or solve distorted puzzles degrades user experience and leaks privacy.&lt;/p&gt;

&lt;p&gt;What if we could identify automation at the middleware layer using pure behavioral biometrics — without storing a single piece of Personally Identifiable Information (Zero-PII)?&lt;/p&gt;

&lt;p&gt;Here is how I designed and built a 19-dimensional kinematic engine and cryptographic challenge protocol from scratch.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture Overview: The 5 Defense Layers
&lt;/h2&gt;

&lt;p&gt;Instead of treating incoming HTTP requests as isolated JSON payloads, the engine processes telemetry through a multi-tiered pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ Incoming Request ]
         │
         ▼
[ Layer 1: Cryptographic Guard ]   ── HMAC-SHA256 Challenge &amp;amp; Single-Use Nonce
         │
         ▼
[ Layer 2: Anti-Stealth Scanner ]  ── Prototype Unhooking &amp;amp; Runtime Checks
         │
         ▼
[ Layer 3: 19D Kinematics Engine ] ── Jerk Analysis &amp;amp; Fitts's Law Profiling
         │
         ▼
[ Layer 4: Micro-Brain (1D-CNN) ]  ── 60-Step Sequence Pattern Detection
         │
         ▼
[ Layer 5: Network Anomaly Guard ] ── Sliding-Window Poisson &amp;amp; IP Quarantine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  1. Kinematics: Why Bots Fail at Third-Order Derivatives
&lt;/h2&gt;

&lt;p&gt;Most bot scripts simulate mouse movements using linear interpolation, Bézier curves, or basic Gaussian jitter. While a Bézier curve looks smooth to the naked eye, its physical properties immediately expose it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Neuro-Muscular Tremor &amp;amp; Jerk Analysis
&lt;/h3&gt;

&lt;p&gt;Human motor control is naturally imperfect due to neuromuscular lag. When a human moves a cursor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position:     x(t)&lt;/li&gt;
&lt;li&gt;Velocity:     v(t) = dx/dt&lt;/li&gt;
&lt;li&gt;Acceleration: a(t) = d²x/dt²&lt;/li&gt;
&lt;li&gt;Jerk:         j(t) = d³x/dt³&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Automated scripts trying to minimize jerk (such as Flash &amp;amp; Hogan models) or applying naive random noise generate unnatural velocity spikes or mathematically flat jerk profiles.&lt;/p&gt;

&lt;p&gt;In our telemetry extractor, we compute discrete third derivatives over microsecond-stamped coordinates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_jerk_profile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndarray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndarray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndarray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timestamps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Prevent zero-division on microsecond clamping&lt;/span&gt;
    &lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1e-6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Velocities&lt;/span&gt;
    &lt;span class="n"&gt;vx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;
    &lt;span class="n"&gt;vy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;

    &lt;span class="c1"&gt;# Accelerations&lt;/span&gt;
    &lt;span class="n"&gt;dt_mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt_mid&lt;/span&gt;
    &lt;span class="n"&gt;ay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt_mid&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hypot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Jerk (Third derivative)&lt;/span&gt;
    &lt;span class="n"&gt;dt_jerk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dt_mid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;jerk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt_jerk&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jerk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jerk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Terminal Deceleration (Fitts's Law)
&lt;/h3&gt;

&lt;p&gt;When humans move a pointer to click a target, the final 20–25% of the trajectory exhibits progressive deceleration to stabilize target acquisition.&lt;/p&gt;

&lt;p&gt;Bots typically maintain constant velocity until the exact click coordinate or snap abruptly. By calculating velocity ratios in the terminal phase, robotic trajectories are separated with high statistical confidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Zero-PII Cryptographic Defense
&lt;/h2&gt;

&lt;p&gt;Client-side behavioral collectors are worthless if an attacker can simply capture a real human session and replay the payload.&lt;/p&gt;

&lt;p&gt;To guarantee zero data storage while maintaining atomic replay resistance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The server issues a timestamped, HMAC-SHA256 signed token containing a high-entropy random nonce.&lt;/li&gt;
&lt;li&gt;The client telemetry payload is signed alongside this nonce.&lt;/li&gt;
&lt;li&gt;The middleware verifies that elapsed time exceeds a physiological human threshold (t_elapsed &amp;gt; 1500 ms).&lt;/li&gt;
&lt;li&gt;The nonce is consumed atomically via distributed cache (Redis SET key 1 EX 120 NX or local SQLite WAL transactions).&lt;/li&gt;
&lt;li&gt;Any subsequent request reusing the same token is rejected with HTTP 403 instantly.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3. Fast In-Process Inference Without Bloat
&lt;/h2&gt;

&lt;p&gt;A security middleware cannot afford 100ms inference latencies. Standard PyTorch or TensorFlow runtimes introduce heavy memory footprints and cold-start penalties.&lt;/p&gt;

&lt;p&gt;Instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The 1D-CNN sequence classifier was trained offline on trajectory vectors.&lt;/li&gt;
&lt;li&gt;Model weights were exported directly to compressed NumPy arrays (.npz).&lt;/li&gt;
&lt;li&gt;The forward pass is executed in pure NumPy using vector operations, completing inference in under 2 milliseconds inside the ASGI event loop.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Physical laws beat statistical obfuscation: Advanced stealth tools can fake navigator.webdriver, but mimicking human neuromuscular jerk across time derivatives without massive latency overhead is computationally expensive for scrapers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stateless cryptography reduces attack surfaces: You don't need user cookies or session tables to verify authenticity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep middleware lean: Pre-compiled arrays and pure matrix operations beat bloated ML runtime dependencies every single time.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What challenges have you faced when dealing with modern automated traffic? Let's discuss in the comments below!&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>fastapi</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>I built an open-source alternative to Cloudflare Turnstile using Fitts's Law and Kinematics</title>
      <dc:creator>Mustafa Güngör</dc:creator>
      <pubDate>Tue, 01 Sep 2026 12:23:05 +0000</pubDate>
      <link>https://dev.to/0xstoic_bit/i-built-an-open-source-alternative-to-cloudflare-turnstile-using-fittss-law-and-kinematics-442</link>
      <guid>https://dev.to/0xstoic_bit/i-built-an-open-source-alternative-to-cloudflare-turnstile-using-fittss-law-and-kinematics-442</guid>
      <description>&lt;p&gt;Hey everyone! 👋&lt;/p&gt;

&lt;p&gt;I’ve always hated intrusive CAPTCHAs and expensive proprietary cloud WAFs. Even the "invisible" ones (like Cloudflare Turnstile or reCAPTCHA v3) are black boxes that collect massive amounts of user telemetry.&lt;/p&gt;

&lt;p&gt;So, I spent the last few months building &lt;strong&gt;Synapse Shield&lt;/strong&gt; — a completely open-source, self-hosted behavioral bot mitigation engine for Python (FastAPI/Django/Flask) and React.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔗 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/0xStoic-bit/Synapse_Shield" rel="noopener noreferrer"&gt;https://github.com/0xStoic-bit/Synapse_Shield&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;PyPI Package:&lt;/strong&gt; &lt;a href="https://pypi.org/project/synapse-shield/" rel="noopener noreferrer"&gt;https://pypi.org/project/synapse-shield/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 How it works (Kinematics &amp;amp; Math)
&lt;/h2&gt;

&lt;p&gt;Instead of just checking if a mouse moves in a straight line, Synapse Shield analyzes 19D kinematic vectors in sub-milliseconds:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Jerk (3rd Derivative of Position):&lt;/strong&gt; Human muscles have micro-tremors. Bots (even advanced Bézier curve bots) produce near-zero or static Jerk. The engine looks for biological tremors ($da/dt$).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fitts's Law Terminal Deceleration:&lt;/strong&gt; Humans naturally decelerate as the cursor approaches a target to click. We measure the &lt;code&gt;terminal_decel_ratio&lt;/code&gt; to catch bots.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poisson Anomaly Detection:&lt;/strong&gt; Headless API flooders are caught using a cumulative Poisson distribution algorithm.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  ✨ Key Features &amp;amp; Hardening (v0.5.0)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;⚡ &lt;strong&gt;Async Non-Blocking SLA (&amp;lt;0.5ms):&lt;/strong&gt; Offloaded via &lt;code&gt;asyncio.to_thread&lt;/code&gt; so it never blocks the FastAPI/Django event loop.&lt;/li&gt;
&lt;li&gt;🔐 &lt;strong&gt;Cryptographic Replay Defense:&lt;/strong&gt; Uses HMAC-SHA256 signed nonces (with SQLite WAL) to ensure tokens can't be replayed.&lt;/li&gt;
&lt;li&gt;♿ &lt;strong&gt;Accessibility Mode:&lt;/strong&gt; &lt;code&gt;accessibility_mode=True&lt;/code&gt; gracefully scales down kinematic thresholds so motor-impaired users aren't falsely flagged.&lt;/li&gt;
&lt;li&gt;⚛️ &lt;strong&gt;React &amp;amp; Next.js SSR Support:&lt;/strong&gt; Native &lt;code&gt;"use client"&lt;/code&gt; Drop-in Component and hook to avoid Hydration errors.&lt;/li&gt;
&lt;li&gt;📈 &lt;strong&gt;Enterprise Prometheus Metrics:&lt;/strong&gt; Native &lt;code&gt;PROMETHEUS_MULTIPROC_DIR&lt;/code&gt; support for Gunicorn/Uvicorn workers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 Quick Code Example (FastAPI)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
python
from fastapi import FastAPI, Request
from synapse_shield import shield_protect, SynapseShieldMiddleware

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

@app.post("/api/login")
@shield_protect(max_risk_score=50.0, accessibility_mode=False)
async def login(request: Request):
    return {"status": "authenticated"}

I'm a 2nd-year Computer Engineering student, and I built this to bridge the gap between low-level math and modern web frameworks.

I’d love your feedback, code audits, or ideas on how to improve the kinematics engine!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
