aiot-production-kit / grounded-tool-use-rbac
AI SAFETY · RBAC TOOL-USE & FAIL-SAFE
RBAC Tool-Use Validator & Hardware Fail-Safe Boundary Guard
Stops prompt-injection privilege escalation and blocks LLMs from overwriting industrial hardware cutoffs or mutating ERP production tables.
TL;DR ENGINEERING FACTS
- Caller-Bound RBAC Whitelists: API gateway enforces role permissions independently of LLM prompts so viewers never invoke ERP or BMS advisories.
- Strict Schema & Regex Sanitization: Rejects injection tokens (`; DROP TABLE`) and out-of-range bounds before touching read-only telemetry/SQL queries.
- Hard Fail-Safe Latch Separation: Permanently blocks AI calls to `overwrite_ovp_threshold`, `disable_bms_thermal_latch`, or `force_relay_override` across all roles.
Run & Test Locally (Zero External Dependencies)
python3 -m unittest discover -s tools -p "test_*.py" python3 tools/tool_use_rbac_guard.py --demo
Field Failure Mode vs. Spacebit Reference Fix
| Field Failure Mode | Why Naïve Implementations Break | Production Guardrail |
|---|---|---|
| Prompt injection requests restricted ERP data | LLM shares single admin DB credential | Per-caller RBAC allowlist checked outside LLM |
| AI proposes higher BMS over-voltage cutoff | AI agent shares write access with firmware | Hard-coded `FORBIDDEN_HW_MUTATION_TOOLS` block |
| Unstructured LLM guess misdiagnoses fault | Chatbot ungrounded from live time-series DB | Typed SQL/telemetry read-only Tool-Use + citation ID |