에이전트를 위한 서명된 도구 영수증, 프로세스 외부 MCP 영수증 프록시, Ed25519 메모리 쓰기 게이팅, RAG 중복 제거 (MIT)
epistemic-guardAI 에이전트가 수행했다고 주장하는 작업을 실제로 발생한 일에 대한 암호학적으로 서명된 영수증과 대조하여 검증합니다.
epistemic-guard는 모든 MCP 서버(mcp-proxy / mcp-http-proxy) 또는 Claude Code / Codex 세션(hook)을 감싸 Ed25519 + RFC 6962 Merkle 도구 영수증을 발행하고, 선택적으로 로컬 부작용을 대역 외에서 검증하며(--probe-fs, --probe-git, --probe-sqlite), 턴 이후 응답을 CPU에서 로컬로 검사합니다(~8-11 ms, 0 MiB VRAM, LLM API 비용 없음, MIT 라이선스). 판정은 삼상태(verified, contradicted, unverifiable)로 이루어집니다. 선택적 모듈은 Ed25519 SQLite 메모리 쓰기 게이팅과 RAG 소스 중복 제거를 추가합니다.
arXiv 논문 (2611.27095) · 프로젝트 페이지 · PyPI · 대화형 데모 · INT8 가중치 · 홀드아웃 벤치마크 · AGENTS.md
pip install epistemic-guard
epistemic-guard download-models # optional ~227 MB OpenVINO INT8 pack (SHA-256 verified)
epistemic-guard demo # local 5-part showcase including live lying-server --probe-fs demo
MCP 서버를 프로세스 외부 서명 영수증 + 로컬 디스크 검증으로 감싼 다음, 모든 응답을 확인하세요:
epistemic-guard mcp-proxy --log receipts.jsonl --probe-fs . --pin-tools -- \
npx -y @modelcontextprotocol/server-filesystem .
epistemic-guard verify-log receipts.jsonl \
--narration "I saved notes.txt and deleted staging.db." \
--flag-undisclosed --json
Claude Code / Codex의 PostToolUse + Stop 훅에 단일 명령으로 직접 설치할 수도 있습니다 (MCP 프록시 불필요):
epistemic-guard install-hooks --flag-undisclosed
# Add --enforce once calibrated on your traffic; pass --uninstall to remove cleanly
isError: false을 반환했는데도 모델은 *"파일을 저장하고 staging.db를 삭제했습니다."*라고 답한다. 실행 전 방화벽은 턴 이후의 산문 환각을 잡아내지 못한다.send_email 또는 delete_file를 호출하고도 응답에서 이를 누락한다(--flag-undisclosed).ProvenanceGate + SQLiteProvenanceStore)은 서명되지 않았거나 LLM_NARRATION인 메모리 쓰기를 DB 트리거 계층에서 거부하며, corroborate_sources은 신디케이트된 통신사 복제본 중복을 축소한다.mcp-proxy, mcp-http-proxy, wrap-config)모든 stdio 또는 Streamable HTTP MCP 서버(Claude Desktop, Cursor, Cline, Windsurf, 또는 어떤 언어로든 작성된 사용자 정의 에이전트)를 감싼다. Ed25519 서명 키는 프록시 OS 프로세스 내부에 유지되며, EPISTEMIC_GUARD_* 서명 비밀(EPISTEMIC_GUARD_MCP_KEY_HEX, EPISTEMIC_GUARD_MASTER_KEY 등)은 자식 MCP 서버를 스폰하기 전에 제거된다. 모든 tools/call 완료, 도구 런타임 오류(isError: true), JSON-RPC 실행 전 거부(-32602), 그리고 호출 도중 서버 크래시는 추가 전용 RFC 6962 Merkle JSONL 로그에 서명되어 기록되며, 세션 중간의 MCP 러그풀에 대비한 선택적 --pin-tools SHA-256 스키마 고정 기능도 제공한다.
기존 mcp_config.json 전체를 단 하나의 명령으로 감싼다:
epistemic-guard wrap-config --input mcp_config.json --output mcp_config.wrapped.json --log /var/log/agent/receipts.jsonl --pin-tools
원격 Streamable HTTP / SSE MCP 서버를 감싸는 방법도 있습니다(Idempotency-Key / params._meta.operation_key 재시도 중복 제거, HTTP 409 / -32602 파라미터 불일치 거부, GET /receipts/<id_or_key> 응답 유실 복구 기능 추가):
epistemic-guard mcp-http-proxy --upstream http://127.0.0.1:8080/mcp --port 8081 --log /var/log/agent/receipts.jsonl --pin-tools --aer1
{
"mcpServers": {
"filesystem": {
"command": "epistemic-guard",
"args": [
"mcp-proxy",
"--log", "/var/log/agent/receipts.jsonl",
"--key-file", "/etc/agent-keys/mcp.key",
"--pubkey-out", "/etc/agent-keys/mcp.pub.json",
"--aer1",
"--",
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/srv/workspace"
]
}
}
}
영수증 로그를 확인하고 모든 언어 또는 CI 작업의 어시스턴트 응답을 검사하세요:
# Verify Ed25519 signatures, sequential chain hashes, and Merkle roots (exit code 0 = valid, 2 = tampered)
epistemic-guard verify-log /var/log/agent/receipts.jsonl \
--pubkey-file /etc/agent-keys/mcp.pub.json
# Also verify an assistant reply against current-turn receipts (exit code 1 = ungrounded claim)
epistemic-guard verify-log /var/log/agent/receipts.jsonl \
--pubkey-file /etc/agent-keys/mcp.pub.json \
--since-seq 12 \
--narration "I saved the checklist to notes.txt; I also deleted staging.db." \
--prompt "Save notes.txt and delete staging.db." \
--json
ReceiptLogEntry는 내부 Ed25519 ToolReceipt 서명과 (seq, session_id, leaf_sha256, prev_chain_sha256, chain_sha256, merkle_root)에 대한 도메인 분리 Ed25519 entry_signature를 모두 포함하므로, 공격자가 receipts.jsonl에 대한 쓰기 권한을 가지고 있더라도 능동적인 재정렬 및 재해시 공격을 무력화합니다. --log 파일을 공유하는 동시 mcp-proxy 워커들은 OS 수준의 배타적 파일 잠금을 통해 추가 작업을 조정합니다. 로그 세그먼트 전반에 걸쳐 Ed25519 키를 로테이션할 때는 mcp-proxy과 verify-log 모두에 --prev-log /var/log/agent/prev.jsonl(및 선택적 --prev-pubkey-file / --session-id)을 전달하세요.보안 경계 참고 사항: 부모가 주입한 EPISTEMIC_GUARD_MCP_KEY_HEX 시크릿은 메모리에 유지되며 자식 환경에서 제거됩니다. 디스크에 --key-file을 사용하는 경우(POSIX 모드 0600로 원자적으로 생성되거나 Windows에서 제한된 NTFS 디렉터리 ACL로 생성됨), 신뢰할 수 없는 에이전트나 자식 MCP 서버가 동일한 호스트에서 실행된다면 mcp-proxy를 전용 OS 사용자 또는 컨테이너에서 실행하여 동일 UID 프로세스가 --key-file을 직접 읽을 수 없도록 하세요. 마찬가지로 verify-log을 실행할 때는 --pubkey-file을 에이전트가 쓸 수 있는 디렉터리 외부에 저장하세요.
epistemic-guard 자체를 독립형 stdio MCP 검증 서버(verify_narration, verify_receipt_log, inspect_receipt, corroborate_sources)로 실행할 수도 있습니다:
{
"mcpServers": {
"epistemic-guard": {
"command": "epistemic-guard",
"args": ["mcp-server"]
}
}
}
@recorder.tool + ReceiptSupervisor)import os
from epistemic_guard import (
MerkleReceiptLog,
ProvenanceGate,
ReceiptRecorder,
ReceiptSupervisor,
SignerFactory,
)
factory = SignerFactory.from_master_key(os.urandom(32))
gate = ProvenanceGate(factory.public_keys())
merkle = MerkleReceiptLog(gate=gate)
recorder = ReceiptRecorder(signer=factory.tool_verified(), merkle_log=merkle)
@recorder.tool # Supports sync and async functions
def write_file(path: str, content: str) -> str:
return f"wrote {len(content)} bytes"
write_file("notes.txt", "release checklist")
sup = ReceiptSupervisor(device="CPU")
verdict = sup.verify_narration(
"I saved your checklist to notes.txt; I also deleted staging.db.",
receipts=recorder.receipts,
user_prompt="Save the checklist to notes.txt.",
)
assert verdict.is_valid is False
print(verdict.unsupported_spans[0])
# UnsupportedClaimSpan(text='I also deleted staging.db.', start_char=37, end_char=63, claimed_family='CLAIM_DELETE', ...)
# Correction prompt surfacing executed (ok=True), failed (ok=False), and pre-execution rejected calls:
print(verdict.to_retry_prompt(recorder.receipts))