
CAWODOG is a proof-of-concept project demonstrating how to protect Python-based AI models deployed on offline industrial machines. Across three progressive steps (0 → 2), the project shows: * how a naïve Python AI application can be trivially reverse-engineered, * how attackers can extract models from packaged binaries, and * how to harden an AI deployment using ONNX conversion, model encryption, and a separated runtime engine. The PoC uses a playful dog-detector model (the “Cat World Dominance Group”) to illustrate real industrial IP-protection concepts that apply to AI-driven control systems, such as Starlinger’s StarX platform. It serves as a reference implementation for the accompanying whitepaper “Hardening Python IP for Offline Industrial AI Deployments.
CAWODOG (Cat World Dominance Group) is a playful but realistic proof-of-concept for protecting Python-based AI models deployed on offline industrial machines.
The core idea:
Take a small image classifier that detects dogs (the “enemy” of CAWODOG), wrap it in a simple app, and then progressively harden the deployment against IP theft.
The PoC is designed as a companion to an internal whitepaper on:
Hardening Python IP for Offline Industrial AI Deployments
This repository demonstrates, step by step:
.
├── 0/ # Step 0 – Unhardened baseline
│ ├── model/ # Training + inference code
│ ├── app/ # Gradio-based web UI
│ ├── requirements.txt
│ └── (optional) build / run helpers
│
├── 1/ # Step 1 – Packaged with Nuitka (Level 1)
│ ├── app/ # Same UI, adapted entrypoint
│ ├── model/ # Same model logic as step 0
│ ├── build.sh # Nuitka onefile build script
│ └── requirements.txt
│
├── 2/ # Step 2 – Encrypted ONNX model (Level 2)
│ ├── model/ # Training + ONNX export + encryption
│ ├── engine/ # Engine module (decryption + ONNX runtime + scoring)
│ ├── app/ # UI calling the engine only
│ ├── hardening/ # Encryption key + utilities (dev only)
│ ├── build.sh # Nuitka onefile build script
│ └── requirements.txt
│
└── attacker/ # Attacker tooling (optional, for demo)
├── run_and_extract.sh # Finds Nuitka temp dir and lists contents
├── steal_model.sh # Copies model file out of extracted payload
└── use_stolen_model.py# Uses stolen model in a separate script
python -m venv .venv)git, pip, and basic command-line familiarityMost steps require:
pip install -r requirements.txt
Folder: 0/
Goal: A plain Python app with a trained model and a simple web UI. No protection.
dog vs not_dogmodel_training.py) that:
data/dog and data/not_dog into train/validationmodel/models/dog_model.ptmodel_inference.py) that:
dog_model.ptapp/gradio_app.py) that:
From the repo root:
cd 0
python -m venv .venv
source .venv/bin/activate # on Windows: .venv\Scripts\activate
pip install -r requirements.txt
Prepare data:
0/data/
dog/
<dog images>.jpg
not_dog/
<non-dog images>.jpg
Train the model:
python -m model.model_training
This will create something like:
model/models/dog_model.pt
Run the Gradio app:
python -m app.gradio_app
Open the printed URL (default http://127.0.0.1:7860) and test with images.
.pt file).This is the “before” picture.
Folder: 1/
Goal: Package the app into a single executable using Nuitka.
Security effect: Makes it look like a product, but does not protect the IP.
app/main.py or cawodog_app.py)build.sh) that:
--standalone and --onefiledog_model.pt)cawodog_step1_nuitka).cd 1
source .venv/bin/activate
./build.sh
After building, you get something like:
./cawodog_step1_nuitka
Running it will start the Gradio UI as before, but now from a single executable.
attacker/)The attacker folder shows how an attacker can:
$TMPDIRdog_model.pt out of that directoryuse_stolen_model.py to run predictions outside of the appKey takeaway: Level 1 is not meaningful protection. It’s packaging, not security.
Folder: 2/
Goal: Introduce real IP protection at the model level.
Security effect: Competitors cannot use the model by simply copying a file.
Model format conversion
dog_model.pt → dog_model.onnx using PyTorch’s ONNX export.Model encryption
dog_model.onnx with AES-GCM to dog_model.enchardening/dev_model.key (for PoC purposes)Engine abstraction
Introduce engine/core.py that:
dog_model.enc at runtimepredict_is_dog() and enemy_score()UI as orchestrator
app/gradio_app.py no longer sees raw model files or internals.cd 2
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Train (or reuse) the model (same as Step 0, but inside 2/):
python -m model.model_training
Export to ONNX:
python -m model.export_to_onnx
# produces model/models/dog_model.onnx
Encrypt the ONNX model:
python -m hardening.encrypt_model
# produces model/models/dog_model.enc and hardening/dev_model.key
Build with Nuitka (via build.sh):
./build.sh
A key will be printed upon completion. You need to set the environment variable CAWODOG_MODEL_KEY_HEX to that key in order for the program to load the encrypted model. Any different key will result in an error.
Run the resulting onefile binary. The UI should behave the same as before.
dog_model.enc) is encrypted.dog_model.enc directly in PyTorchIt is still not tied to a hardware root of trust, and a skilled reverse-engineer can eventually reconstruct the model, but the bar is significantly higher than in Step 1.
This PoC focuses on:
It does not claim to:
Typical narrative flow:
Step 0 – Baseline
Step 1 – Packaging (Nuitka onefile)
attacker/ scripts to demonstrate how easily the model is still stolen.Step 2 – Encrypted ONNX
dog_model.enc is no longer sufficient.You can then discuss further future levels (not implemented here yet):
MIT License
Copyright (c) 2025 Daniel Eder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.