Skip to main content

Ushka ฅ^•ﻌ•^ฅ

PyPI Version Documentation Python Versions License

Ushka is the Python web framework where insecure code, whether you or an AI wrote it, does not run silently. It stops and tells you how to fix it.

It is an async (ASGI) framework with filesystem routing, and it is small on purpose. It needs few dependencies, but it ships everything a web app needs. Its main feature is Ushka Guard: anything that comes from outside your program arrives as an Untrusted string, and the places where such a string could do harm refuse it.

# routes/login.py
from ushka.guard import safe
from ushka.http import redirect

async def get(request):
    target = request.query.get("next", "/")      # Untrusted
    # return redirect(target)                    # ✗ USHKA-G003 open redirect, with the fix
    return redirect(safe.url(target, allow=["/"], default="/"))   # ✓

Why

AI assistants write a growing share of web code, and studies keep finding OWASP Top 10 flaws in around 45% of generated samples. Apps also pass model output into HTML, redirects and SQL, where prompt injection can steer it. Ushka puts the check where it cannot be skipped: in the framework, at runtime, on your real code. Read Why Ushka changed.

What's in the box

  • Ushka Guard:
    • Untrusted by default. Query, form, JSON, headers, cookies and path parameters are Untrusted, and so is model output once marked with guard.llm().
    • Guarded sinks. HTML, redirects, file paths and raw SQL refuse those values.
    • Sanitisers and errors. The way out is through explicit sanitisers. Errors give the risk and the fix, as text and as JSON for coding agents.
  • Python 3.14 t-strings. t"<h1>{name}</h1>" and db.execute(t"... {id}") are safe by construction.
  • Routing. Filesystem routing (routes/users/[user_id].py) plus decorators (@app.get(...)).
  • Responses. Return a str, a dict, a (body, status) tuple, None (204) or a Response. HEAD and 405 Allow are handled for you.
  • Data, sessions and templates:
    • Async Active Record ORM on SQLAlchemy, with migrations in ushka db (extra ushka[orm]).
    • Jinja2 templates, signed sessions, cookies, flash messages, file uploads and request size limits.
  • Config. Defaults, then ushka.toml, then .env, then environment variables, all without extra packages. DATABASE_URL works out of the box.
  • CLI. new, dev, run, check (CI-friendly security check), routes and db.
  • Low dependency. The core needs only uvicorn, jinja2 and python-multipart (plus tomli on 3.10).

Quick start

pip install ushka
ushka new hello
cd hello
ushka dev

ushka new creates a project that is safe from the first commit:

  • debug = false in config (ushka dev turns debug on by itself)
  • a generated secret in .env
  • a .gitignore
  • an AGENTS.md that teaches coding agents the rules

Or write a single-file app:

from ushka import Ushka

app = Ushka()

@app.get("/greet/[name]")
async def greet(name):
    return f"Hello, {name}!"          # plain text: safe

@app.post("/items")
async def create(request):
    data = await request.json()
    return {"created": data["name"]}, 201

if __name__ == "__main__":
    app.run()

Before deploying:

ushka check --production   # fails (exit 1) on debug on, missing secret, guard off...

Documentation

Guides, the Ushka Guard reference and the API reference are at https://kleber-code.github.io/ushka/. For AI tools there is llms.txt.

Contributing

Bug reports, ideas and pull requests are welcome. See the contributing guidelines and the security policy.

License

MIT

Metadata

Release files for ushka 0.5.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 ushka 0.5.0
File Size Uploaded Provenance Actions
ushka-0.5.0.tar.gz 91.8 kB With provenance Details for ushka-0.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 182.9 kB

Release files / ushka-0.5.0.tar.gz

Download URL ushka-0.5.0.tar.gz
Size 91.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e3c9ef5dd93f382a0d828ff39d7ba0f76fbb9e1b55f2875f475b8856f6315851
BLAKE2b-256 checksum
How to use checksums
ae019cfec8b7bc43882e75b5b36d68bc873c208de24375b649cf003e34ed1215
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 Nov 14, 2026.

Transparency log

Release files / ushka-0.5.0-py3-none-any.whl

Download URL ushka-0.5.0-py3-none-any.whl
Size 91.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e99a149868c2eaa5a82f59755db397330bf61dab72fa206b1adb44b96130818d
BLAKE2b-256 checksum
How to use checksums
8ca29648a24cceb31a9c38e83bf866c404e1fe8b55720e481c6587070a34cbb9
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 Nov 14, 2026.

Transparency log

Security for ushka 0.5.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 ushka-0.5.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 Nov 14, 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.

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