DEV Community

PyKevlar Labs
PyKevlar Labs

Posted on Originally published at pykevlar.com

Why Standard Python Obfuscators Break FastAPI & Pydantic v2 Type Annotations (And How AST Vaults Fix It)

Try running a naive Python identifier obfuscator on a production FastAPI + Pydantic v2 + SQLAlchemy 2.0 codebase and your app won't even boot: path parameters stop matching route functions, BaseModel JSON serialization mutates field names, and dependency injection throws FastAPIError.

1. Preserving Public Schema Contracts While Sealing Endpoint Bodies

PyKevlar's AST pass leaves function parameter signatures, Pydantic field descriptors, and __annotations__ untouched while encrypting the executable bytecode body inside per-function ChaCha20-Poly1305 Vectorcall Vaults and transpiling pure service/domain modules to native C (--enable-bcc):

pykevlar build main.py \
    --protect app \
    --mix-str --enable-bcc --anti-llm \
    -F -O dist
# Smoke-test and verify 0 leaked .py files:
pykevlar verify dist/main --protect app
Enter fullscreen mode Exit fullscreen mode

Compile FastAPI + Uvicorn into a single armored binary in 1.1s

14-day compatibility money-back guarantee · $29.25/yr Pro with code LAUNCH25.

Top comments (0)