Detect steganographic covert channels in LLM outputs
Project description
phantom-detect
Detect steganographic covert channels in LLM outputs.
phantom-detect monitors AI agent outputs for statistical anomalies that indicate hidden data encoding — covert channels embedded in the text, timing, structure, or tool-call patterns of large language model responses.
The Problem
LLM outputs can carry hidden information through:
- Entropy manipulation — biasing word choices to encode bits
- Structural encoding — using formatting patterns (lists, paragraphs, punctuation) as a side channel
- Timing channels — encoding data in response latency patterns
- Tool call orchestration — sequencing API calls to carry hidden messages
- Cross-agent synchronization — coordinating multiple agents to transmit data
These channels are invisible to humans reading the output but detectable through statistical analysis.
Installation
pip install phantom-detect
Or from source:
git clone https://github.com/brianrutherford/phantom-detect.git
cd phantom-detect
pip install -e .
Quick Start
Command Line
Analyze a JSONL file of LLM outputs:
phantom-detect analyze outputs.jsonl
Watch streaming input:
your-llm-pipeline | phantom-detect watch --stdin
Build a baseline from known-clean outputs:
phantom-detect baseline clean_outputs.jsonl
Python API
from phantom_detect import CCDS, AgentActivity
from datetime import datetime, timezone
# Initialize detector
ccds = CCDS(sensitivity=0.7)
# Analyze agent output
activity = AgentActivity(
agent_id="gpt-4-agent",
timestamp=datetime.now(timezone.utc),
activity_type="generation",
content={
"text": "The quick brown fox jumps over the lazy dog.",
"entropy": 3.14
}
)
alerts = ccds.analyze_activity(activity)
for alert in alerts:
print(f"[{alert.severity.name}] {alert.description}")
print(f" Channel: {alert.channel_type}")
print(f" Evidence: {alert.evidence}")
Input Format
phantom-detect expects JSONL (one JSON object per line):
{"agent_id": "agent_001", "text": "LLM output text...", "entropy": 3.14, "timestamp": "2026-01-15T10:30:00Z"}
{"agent_id": "agent_001", "text": "Another output...", "entropy": 2.87}
{"agent_id": "agent_002", "text": "Different agent output", "entropy": 4.21, "activity_type": "tool_call", "tool_calls": [{"name": "search"}]}
Fields:
agent_id(required): Identifies the source agenttext: The LLM output textentropy: Token distribution entropy (if available from the API)timestamp: ISO 8601 timestamp (defaults to current time)activity_type:"generation"(default) or"tool_call"tool_calls: List of tool call objects (for tool_call activities)metadata: Additional context (e.g.,{"time_since_last_ms": 500})
Detection Methods
Statistical Anomaly Detection
Compares agent behavior against a learned baseline. Flags deviations in entropy, timing, and structural patterns that exceed configured thresholds.
Cross-Agent Correlation
Detects synchronized behavior across multiple agents that could indicate coordinated covert communication (Cross-Agent Synchronization Protocol).
Pattern Recognition
Identifies known encoding signatures in tool call sequences and text structure patterns.
Channel Types Detected
| Channel | Code | Description |
|---|---|---|
| Tool Call Orchestration | TCOE | Hidden data in tool call sequences |
| Chain-of-Thought Structure | COTSE | Encoding in reasoning structure |
| Hardware Side-Channel | HSCE | Timing-based encoding |
| Entropy Gradient | EGE | Biased token distributions |
| Probability Ratio Stego | PRS | Steganography via probability manipulation |
| Cross-Agent Sync | CASP | Multi-agent coordination channels |
Configuration
ccds = CCDS(
sensitivity=0.7, # 0-1, higher = more alerts (default: 0.7)
baseline_window=timedelta(hours=24), # Baseline computation window
correlation_window=timedelta(seconds=5), # Cross-agent correlation window
enable_cross_agent=True # Enable cross-agent detection
)
Development
git clone https://github.com/brianrutherford/phantom-detect.git
cd phantom-detect
pip install -e ".[dev]"
pytest
License
Apache 2.0
Author
Brian Rutherford — brianrutherford.dev
Citation
If you use phantom-detect in research, please cite:
@software{rutherford2026phantomdetect,
author = {Rutherford, Brian},
title = {phantom-detect: LLM Covert Channel Detection Toolkit},
year = {2026},
url = {https://github.com/brianrutherford/phantom-detect}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phantom_detect-0.1.0.tar.gz.
File metadata
- Download URL: phantom_detect-0.1.0.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2c1f0793f00502effa323a462e9f5b6a8a3bd015f7145618d0c0caa01637316
|
|
| MD5 |
7223795f63c3e3923e8c33f3728fc772
|
|
| BLAKE2b-256 |
c7ad18c62a343ef7388e6804092f37c9df5260ca497c3670da031cc093b0cfa8
|
File details
Details for the file phantom_detect-0.1.0-py3-none-any.whl.
File metadata
- Download URL: phantom_detect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b129de7e759faeaf7befb56ea793a72998b4b2cdc9f4cced3564745f64f10fe4
|
|
| MD5 |
00f14c1d66d31ec71bba7a1baafc3cfb
|
|
| BLAKE2b-256 |
e118ada6cfe17de349823e109dcb67c814b1af502f974a0a9d080c6ca6323097
|