Skip to main content

Wiqa (وِقاء)

tests License: Apache-2.0

Know who tried, from where, and how to close it.

Wiqa is an open-source security layer that runs inside your app, not in front of it. It sees every request from the inside, stops the attack before it reaches your code or your database, and explains it in Arabic and English. Nothing leaves your server.

This repository is the Python library for FastAPI / Starlette + MongoDB. Website: wiqa.shift-agency.net · العربي ↓

Early release (v0.1). It catches two attack classes today. Read What it does not do before relying on it.

What it catches

Attack Example What happens without protection
NoSQL operator injection {"username": "admin", "password": {"$ne": ""}} Login as admin without the password
Regex DoS (ReDoS) GET /search?q=^(a+)+$ One request keeps the database/server busy

Normal input passes: Arabic text, names like O'Brien, prices like $15, phone numbers.

Install and use

pip install wiqa
from fastapi import FastAPI
from wiqa import WiqaMiddleware

app = FastAPI()
app.add_middleware(WiqaMiddleware, mode="monitor")  # log only. Switch to "block" when you trust it.

In monitor mode nothing changes for your users; each finding is logged on the wiqa logger. In block mode the request gets 403 with a JSON explanation. Raw values (passwords, search text) are never logged.

No dependencies, no network calls, no telemetry.

Try it yourself (the demo)

demo/vulnerable_app.py is a small FastAPI + MongoDB app with both bugs on purpose (in-memory database, fake users).

python -m venv .venv
.venv/bin/pip install -e ".[dev]"        # Windows: .venv\Scripts\pip
.venv/bin/python -m demo.attack          # same attacks, without and with wiqa
.venv/bin/python -m pytest -q            # 31 tests

What it does not do (yet)

  • It checks the request, not the final query sent to MongoDB, so an operator built inside your own code is not seen.
  • It does not cover SQL databases, XSS, SSRF, or auth logic bugs.
  • The ReDoS check looks for nested quantifiers; it is a heuristic, not a full regex analyser.
  • It is not a replacement for fixing the code: type your Pydantic fields as str and use re.escape() on user text.

Roadmap

  • Working on: query-level checks inside pymongo/motor (so a real Arabic name is never blocked), SQL injection and XSS, first real apps in monitor mode.
  • Next: one fast engine for every language (Node.js, Django and more), WhatsApp alerts, an Arabic/English security report.

Security

Found a way past Wiqa? Please report it privately. See SECURITY.md.


بالعربي

اعرف مين حاول، ومنين، وإزاي تقفلها.

وِقاء طبقة حماية مفتوحة المصدر بتتركّب جوه تطبيقك، مش قدامه. بتشوف كل طلب من جوه، وبتوقف الهجمة قبل ما توصل للكود أو الداتابيز، وبتشرحها بالعربي. وبيانات عملائك عمرها ما بتخرج من سيرفرك.

الريبو ده هو مكتبة بايثون لـ FastAPI + MongoDB.

بتمسك إيه دلوقتي

  • حقن أوامر MongoDB، زي {"$ne": ""} في خانة الباسورد، اللي بيدخّل المهاجم كأدمن من غير باسورد.
  • ReDoS، يعني نص بحث متصمم عشان يوقّف السيرفر.

النصوص العادية بتعدّي: العربي، والأسماء زي O'Brien، والأسعار زي $15.

الاستخدام

ابدأ بوضع monitor: بيسجّل بس، ومش بيغيّر حاجة لمستخدمينك. ولما تطمّن، حوّل لـ block. القيم الحساسة زي الباسوردات عمرها ما بتتكتب في اللوج.

اللي لسه مش بتعمله

بتفحص الطلب نفسه، مش الـquery النهائية. ومش بتغطي SQL ولا XSS لسه، وده اللي شغالين عليه دلوقتي. وهي مش بديل إنك تصلّح الكود.

لو لقيت ثغرة في وِقاء نفسها، شوف SECURITY.md.


License: Apache-2.0

Metadata

Release files for wiqa 0.1.0

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

Source distribution (sdist)

Source distribution for wiqa 0.1.0
File Size Uploaded Provenance Actions
wiqa-0.1.0.tar.gz 15.9 kB With provenance Details for wiqa-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wiqa 0.1.0
File Interpreter ABI Platform Actions
wiqa-0.1.0-py3-none-any.whl Python 3 none any Details for wiqa-0.1.0-py3-none-any.whl

Total release size: 28.5 kB

Release files / wiqa-0.1.0.tar.gz

Download URL wiqa-0.1.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
30077942ac6449bf757985caa8b0ddf00ccdbb97c70554c43b19678b97d1db50
BLAKE2b-256 checksum
How to use checksums
d01e2c338657d484e60925829078789035bfe1a2ce6b3a769d151a30969ec0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Release files / wiqa-0.1.0-py3-none-any.whl

Download URL wiqa-0.1.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c78a673d961b69c36354ffd00b2a54ed09d5698ebb7cc1e8bbbfa3c5dd00a26
BLAKE2b-256 checksum
How to use checksums
d3c36fe8b2ee195f1e81f8194e2153c3ba0a8b646432a5b6fe5c2435b80960e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Security for wiqa 0.1.0

Provenance

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

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wiqa-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

A note on package security

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

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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