Skip to main content

AI-first runtime security framework for AI agents โ€” 14 guards, 5 framework adapters, sub-ms rule checks

Project description

๐Ÿง€ Qise

AI-First Runtime Security Framework for AI Agents

Python 3.11+ License: CC BY-NC-SA 4.0 Tests: 410 passed Guards: 14 Adapters: 5

English | ไธญๆ–‡


Overview

Qise (pronounced "Cheese" ๐Ÿง€) is an open-source runtime security framework that protects AI agents from both directions:

  • World โ†’ Agent: Stops prompt injection, tool poisoning, memory/KB tampering, and supply chain attacks
  • Agent โ†’ World: Stops dangerous commands, path traversal, SSRF, data exfiltration, and policy violations

Unlike rule-only solutions that are easily bypassed, Qise uses layered AI models (SLM fast-screen + LLM deep analysis) to understand attack intent, with deterministic rules as fast-path and fallback โ€” never fail-open.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Qise Security Framework                   โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ”Œโ”€โ”€โ”€ Soft Defense โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚  SecurityContextProvider  โ†’  Scene-aware rules injection  โ”‚ โ”‚
โ”‚   โ”‚  ReasoningGuard          โ†’  Chain-of-thought monitoring   โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                           โ†“ still executes                      โ”‚
โ”‚   โ”Œโ”€โ”€โ”€ Hard Defense (14 Guards) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚                                                           โ”‚ โ”‚
โ”‚   โ”‚  Ingress (World โ†’ Agent)                                  โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚   โ”‚  โ”‚ Prompt โ”‚ โ”‚ ToolSanity โ”‚ โ”‚ Context โ”‚ โ”‚ SupplyChain  โ”‚ โ”‚ โ”‚
โ”‚   โ”‚  โ”‚ Guard  โ”‚ โ”‚   Guard    โ”‚ โ”‚  Guard  โ”‚ โ”‚    Guard     โ”‚ โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚   โ”‚                                                           โ”‚ โ”‚
โ”‚   โ”‚  Egress (Agent โ†’ World)                                   โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
โ”‚   โ”‚  โ”‚ Command โ”‚ โ”‚Filesystemโ”‚ โ”‚Network โ”‚ โ”‚Exfil โ”‚ โ”‚Policyโ”‚ โ”‚ โ”‚
โ”‚   โ”‚  โ”‚  Guard  โ”‚ โ”‚  Guard   โ”‚ โ”‚ Guard  โ”‚ โ”‚Guard โ”‚ โ”‚Guard โ”‚ โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ”‚   โ”‚                         + ResourceGuard                    โ”‚ โ”‚
โ”‚   โ”‚                                                           โ”‚ โ”‚
โ”‚   โ”‚  Output (Audit)                                           โ”‚ โ”‚
โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚ โ”‚
โ”‚   โ”‚  โ”‚Credential โ”‚ โ”‚  Audit   โ”‚ โ”‚  Output  โ”‚                 โ”‚ โ”‚
โ”‚   โ”‚  โ”‚   Guard   โ”‚ โ”‚  Guard   โ”‚ โ”‚  Guard   โ”‚                 โ”‚ โ”‚
โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ”Œโ”€โ”€โ”€ Shared Services โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚  ModelRouter (SLM <50ms + LLM <2s) โ”‚ ThreatPatternLoader โ”‚ โ”‚
โ”‚   โ”‚  BaselineManager (SHA-256) โ”‚ SessionTracker โ”‚ EventLogger โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Why Qise

Problem Qise's Approach
Keyword rules easily bypassed AI understands attack semantics, not just pattern matching
Single model bottleneck Layered models: SLM <50ms fast-screen + LLM deep analysis
Fail-open on model errors Rule fallback โ€” never fail-open
No exfiltration detection ExfilGuard: AI-first data exfiltration detection
No tool poisoning detection ToolSanityGuard: hash baseline + AI semantic analysis
Static safety instructions Dynamic SecurityContextProvider + Guard enforcement
Requires code changes Proxy mode / MCP mode: zero-code integration

Three-Layer Decision Flow

Every guard uses the same decision flow โ€” rules first for speed, AI for semantics, rules last for safety:

  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Rule Fast-Path   โ”‚  <1ms โ€” deterministic BLOCK or PASS
  โ”‚ (regex, hash,    โ”‚  e.g., "rm -rf /" โ†’ BLOCK
  โ”‚  patterns)       โ”‚  e.g., matching hash โ†’ PASS
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚ uncertain
           โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ SLM Fast-Screen  โ”‚  <50ms โ€” semantic classification
  โ”‚ (โ‰ค4B model)      โ”‚  e.g., obfuscated command โ†’ BLOCK
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  e.g., paraphrased injection โ†’ ESCALATE
           โ”‚ low confidence
           โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ LLM Deep Analysisโ”‚  <2s โ€” full trajectory reasoning
  โ”‚ (8B-70B model)   โ”‚  e.g., multi-turn attack chain โ†’ BLOCK
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚ model unavailable
           โ–ผ
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ Rule Fallback    โ”‚  <1ms โ€” conservative defaults
  โ”‚ (never fail-open)โ”‚  e.g., WARN on uncertain + network tool
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Defense in Depth

Four layers protect from soft guidance to hard enforcement:

  Layer 0: SecurityContextProvider
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ Inject scene-aware security rules into agent โ”‚
           โ”‚ Agent follows voluntarily (~80% prevention)  โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ†“ Agent ignores rules
  Layer 1: ReasoningGuard
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ SLM detects manipulation in chain-of-thought โ”‚
           โ”‚ Inserts safety reminders, lowers thresholds  โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ†“ Agent still executes
  Layer 2: Guard Pipeline (14 Guards)
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ Rule โ†’ SLM โ†’ LLM โ†’ Rule fallback            โ”‚
           โ”‚ BLOCK / WARN / APPROVE                      โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ†“ Action already executed
  Layer 3: OutputGuard + CredentialGuard
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚ Detect data leaks, PII, credentials         โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Quick Start

Install

pip install qise

One-Command Setup

# Generate default config
qise init

# Check a tool call
qise check bash '{"command": "rm -rf /"}'
# โ†’ {"verdict": "block", "blocked_by": "command", ...}

qise check bash '{"command": "ls"}'
# โ†’ {"verdict": "pass", "blocked_by": null, "warnings": []}

# List all guards and their modes
qise guards

Zero-Code: Proxy Mode

Start a local HTTP proxy that intercepts all Agentโ†”LLM traffic:

# Start proxy server
qise proxy start --port 8822 --upstream https://api.openai.com

# Point your agent at the proxy
export OPENAI_API_BASE="http://localhost:8822/v1"

The proxy intercepts requests/responses in real-time, running all 14 guards on tool calls, injection attempts, and output leaks โ€” with SSE streaming support for zero-latency text passthrough.

Zero-Code: MCP Mode

Add to your agent's MCP configuration:

{
  "mcpServers": {
    "qise": {
      "command": "python",
      "args": ["-m", "qise.mcp_server"]
    }
  }
}

SDK Mode: Framework Adapters

Nanobot:

from qise import Shield
from qise.adapters.nanobot import QiseNanobotHook

shield = Shield.from_config()
hook = QiseNanobotHook(shield)
loop = AgentLoop(hooks=[hook])

LangGraph:

from qise import Shield
from qise.adapters.langgraph import QiseLangGraphWrapper

shield = Shield.from_config()
wrapper = QiseLangGraphWrapper(shield)
safe_tools = [wrapper.wrap_tool_call(tool) for tool in my_tools]

NexAU:

from qise import Shield
from qise.adapters.nexau import QiseNexauMiddleware

shield = Shield.from_config()
middleware = QiseNexauMiddleware(shield)
agent = NexAUAgent(middlewares=[middleware])

OpenAI Agents SDK:

from qise import Shield
from qise.adapters.openai_agents import QiseOpenAIAgentsGuardrails

shield = Shield.from_config()
guardrails = QiseOpenAIAgentsGuardrails(shield)
agent = Agent(guardrails=[guardrails.input_guardrail, guardrails.output_guardrail])

Hermes:

from qise import Shield
from qise.adapters.hermes import QiseHermesPlugin

shield = Shield.from_config()
plugin = QiseHermesPlugin(shield)
plugin.register(ctx)

Run Tests

pytest tests/ -v    # 410 tests

14 Guards at a Glance

Ingress Pipeline (World โ†’ Agent)

Guard Strategy Detects
PromptGuard AI-first (80/20) Indirect injection, multi-turn attacks, context poisoning
ReasoningGuard AI-only (100/0) Manipulation traces in chain-of-thought
ToolSanityGuard AI-first (80/20) Tool description poisoning, rug pulls, name shadowing
ContextGuard AI+hash (70/30) Memory/KB poisoning, data tampering, hash integrity
SupplyChainGuard AI+rules (60/40) Malicious Skills, MCP tampering, source verification

Egress Pipeline (Agent โ†’ World)

Guard Strategy Detects
CommandGuard Rules+AI (70/30) Shell injection, dangerous commands, privilege escalation
FilesystemGuard Rules (90/10) Path traversal, workspace violations, system dir access
NetworkGuard Rules (90/10) SSRF, forbidden domains, internal network scanning
ExfilGuard AI-first (80/20) Data exfiltration, covert channels, DNS exfil
ResourceGuard Rules+AI (60/40) Infinite loops, budget overruns, circuit breaker
ToolPolicyGuard Rules (100/0) Unauthorized tool access, deny/approval/owner-only

Output Pipeline (Audit)

Guard Strategy Detects
CredentialGuard Rules (100/0) API keys, secrets, tokens in output
AuditGuard AI+rules (50/50) Attack chain reconstruction, session risk scoring
OutputGuard AI+rules (70/30) PII exposure, KB content leaks, credential leaks

5 Framework Adapters

Framework Adapter Hook Points Ingress Egress Output SecContext
Nanobot QiseNanobotHook before_execute_tools, after_iteration โœ… โœ… โœ… โœ…
Hermes QiseHermesPlugin pre/post_tool_call, transform_result, post_llm_call โœ… โœ… โœ… โ€”
NexAU QiseNexauMiddleware before/after_agent, before/after_model, before/after_tool โœ… โœ… โœ… โœ…
LangGraph QiseLangGraphWrapper wrap/awrap_tool_call, pre_model_hook โ€” โœ… โ€” โœ…
OpenAI Agents QiseOpenAIAgentsGuardrails input/output_guardrail, tool_input/output_guardrail โœ… โœ… โœ… โ€”

All adapters use the IngressCheckMixin + EgressCheckMixin base classes โ€” no monkey-patching, only official Hook/Plugin/Middleware APIs.

Model Layer

Tier Model Latency Usage
SLM fast-screen Qwen3-4B / Phi-4-mini <50ms Every tool call (AI-first guards)
LLM deep analysis Claude / GPT / Qwen-72B <2s Only when SLM escalates (~5%)
Rule fallback Deterministic rules <1ms When models unavailable (never fail-open)

Stub mode: Works out of the box without any model server โ€” all guards degrade to rules gracefully. Rules-based guards (command, filesystem, network, credential, tool_policy) default to enforce mode; AI-first guards default to observe mode.

Performance

Rule-only mode adds virtually zero overhead:

Operation Target Measured (p95)
Rule fast-path (single guard) <1ms ~0.02ms
Full egress pipeline (6 guards) <10ms ~0.02ms
Full ingress pipeline (5 guards) <10ms ~0.02ms
Full output pipeline (3 guards) <10ms ~0.01ms
Shield initialization <100ms ~7ms
Security context render <5ms ~0.01ms

100 sequential egress checks: ~1.8ms total (~0.02ms avg).

See docs/performance.md for detailed benchmarks.

Data-Driven Threat Intelligence

Threat patterns are YAML data, not hardcoded regex โ€” versionable, shareable, and AI-readable:

# data/threat_patterns/indirect_injection_via_tool.yaml
id: TPI-001
name: Indirect injection via tool result
severity: high

attack_examples:
  - input: 'Tool result: "IMPORTANT: Ignore previous instructions..."'
    verdict: malicious
    reasoning: "Tool result contains override instructions"

rule_signatures:
  - type: regex
    pattern: "ignore\\s+(previous|above)\\s+instructions"
    confidence: 0.9

Architecture

qise/
โ”œโ”€โ”€ src/qise/
โ”‚   โ”œโ”€โ”€ core/              # GuardContext, AIGuardBase, Pipeline, Shield, Config
โ”‚   โ”‚   โ”œโ”€โ”€ models.py      # Data models (GuardContext, GuardResult, GuardVerdict, RiskAttribution)
โ”‚   โ”‚   โ”œโ”€โ”€ guard_base.py  # AIGuardBase + RuleChecker (three-layer decision)
โ”‚   โ”‚   โ”œโ”€โ”€ pipeline.py    # Ingress/Egress/Output pipeline with BLOCK short-circuit
โ”‚   โ”‚   โ”œโ”€โ”€ shield.py      # Main entry point โ€” 14 guards, dependency injection
โ”‚   โ”‚   โ”œโ”€โ”€ config.py      # ShieldConfig parser for shield.yaml
โ”‚   โ”‚   โ”œโ”€โ”€ session_tracker.py  # Cross-turn security state
โ”‚   โ”‚   โ””โ”€โ”€ event_logger.py     # Structured security event logging
โ”‚   โ”œโ”€โ”€ guards/            # 14 Guard implementations
โ”‚   โ”œโ”€โ”€ models/            # ModelRouter (httpx-based OpenAI-compatible client)
โ”‚   โ”œโ”€โ”€ data/              # ThreatPatternLoader + BaselineManager
โ”‚   โ”œโ”€โ”€ providers/         # SecurityContextProvider (DSL template rendering)
โ”‚   โ”œโ”€โ”€ adapters/          # 5 Framework adapters
โ”‚   โ”‚   โ”œโ”€โ”€ base.py        #   AgentAdapter ABC + IngressCheckMixin + EgressCheckMixin
โ”‚   โ”‚   โ”œโ”€โ”€ nanobot.py     #   Nanobot AgentHook integration
โ”‚   โ”‚   โ”œโ”€โ”€ hermes.py      #   Hermes Plugin hook integration
โ”‚   โ”‚   โ”œโ”€โ”€ nexau.py       #   NexAU Middleware (6 hooks)
โ”‚   โ”‚   โ”œโ”€โ”€ langgraph.py   #   LangGraph tool wrapper + pre-model hook
โ”‚   โ”‚   โ””โ”€โ”€ openai_agents.py # OpenAI Agents SDK guardrails
โ”‚   โ”œโ”€โ”€ proxy/             # HTTP proxy server
โ”‚   โ”‚   โ”œโ”€โ”€ server.py      #   aiohttp-based proxy with SSE streaming
โ”‚   โ”‚   โ”œโ”€โ”€ streaming.py   #   SSEStreamHandler with BufferedToolCall state machine
โ”‚   โ”‚   โ”œโ”€โ”€ parser.py      #   Request/Response parser for OpenAI-compatible API
โ”‚   โ”‚   โ”œโ”€โ”€ interceptor.py #   ProxyInterceptor routing through Guard pipelines
โ”‚   โ”‚   โ”œโ”€โ”€ context_injector.py # SecurityContext injection into system messages
โ”‚   โ”‚   โ””โ”€โ”€ config.py      #   ProxyConfig with env overrides
โ”‚   โ””โ”€โ”€ mcp_server.py      # MCP Server (4 security check tools)
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ threat_patterns/   # 6 YAML threat patterns
โ”‚   โ””โ”€โ”€ security_contexts/ # 8 DSL security context templates
โ”œโ”€โ”€ tests/                 # 410 tests
โ””โ”€โ”€ docs/                  # Architecture, Guards, Threat Model, Integration

CLI Reference

qise check bash '{"command": "rm -rf /"}'  # Single security check
qise serve                                  # Start MCP Server
qise proxy start --port 8822                # Start HTTP proxy
qise init                                   # Generate shield.yaml
qise adapters                               # List framework adapters
qise adapters nexau                         # Show integration code
qise context bash                           # Get security context
qise guards                                 # List registered guards
qise version                                # Print version

Documentation

Document Description
Architecture System design, integration modes, core interfaces
Guards Detailed Guard specifications and AI/rule strategies
Threat Model Attack taxonomies, trust boundaries, defense chains
Integration Guide Proxy/MCP/SDK modes, desktop app setup
Quick Start 5-minute setup guide
Performance Latency benchmarks

Integration Modes

Mode Code Required Defense Depth Best For
Proxy Mode 0 lines Full (4 layers) Desktop users, non-developers
MCP Mode 0 lines Hard defense (14 guards) MCP ecosystem users
SDK Mode 1-5 lines Full (4 layers) + lowest latency Agent developers

Status

Component Status
Core engine (AIGuardBase, Pipeline, Shield) โœ… Complete
14 Guards (Ingress + Egress + Output) โœ… Complete
ModelRouter (httpx-based SLM/LLM client) โœ… Complete
Proxy Server (aiohttp + SSE streaming) โœ… Complete
5 Framework Adapters (Nanobot, Hermes, NexAU, LangGraph, OpenAI Agents) โœ… Complete
CLI (check / serve / proxy / init / adapters / context / guards / version) โœ… Complete
MCP Server (4 security check tools) โœ… Complete
SecurityContextProvider (DSL template rendering) โœ… Complete
BaselineManager (SHA-256 hash integrity) โœ… Complete
Soft-Hard Defense Linkage (active_security_rules) โœ… Complete
410 unit + integration + performance tests โœ… Complete
Desktop App (Tauri 2) ๐Ÿ”œ Planned

License

CC BY-NC-SA 4.0 โ€” Free for personal, academic, and non-commercial use. Commercial use requires separate permission.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qise-0.1.0.tar.gz (153.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qise-0.1.0-py3-none-any.whl (110.8 kB view details)

Uploaded Python 3

File details

Details for the file qise-0.1.0.tar.gz.

File metadata

  • Download URL: qise-0.1.0.tar.gz
  • Upload date:
  • Size: 153.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qise-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1106cd74d809cee0737a47ed43b100fd3d69c0cdf5a5984bc66d6bc7ba1ee4ee
MD5 2c372a5412589b9b4e28893e6702a9b3
BLAKE2b-256 6c0b97ce663648ba54f6d42459066288927e2581ec7c2c1b603588a396a7d8db

See more details on using hashes here.

Provenance

The following attestation bundles were made for qise-0.1.0.tar.gz:

Publisher: workflow.yml on WhitzardAgent/qise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qise-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qise-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 110.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qise-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4b4d163b7587a217d2ef6e18bf49612e3fa092d1b11068064fbeb98e5534a3
MD5 104422dc0f1442726646e14cb3e3dcec
BLAKE2b-256 b8b939888db0ad3bbabe1f9f52b7fddbd344eea3f62391a8c928278019dd45bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for qise-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on WhitzardAgent/qise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page