
AI 에이전트의 행동 경계를 위한 이식 가능한 보안 규칙
AI 에이전트 보안 규칙을 위한 이식 가능한 오픈 사양
사양 · 문서 · 규칙 세트 · JSON Schema
HushSpec은 AI 에이전트 보안 규칙을 위한 오픈 정책 형식입니다. 파일 시스템 접근, 네트워크 이그레스, 도구 사용, 시크릿 탐지 등을 포함하여 에이전트가 런타임에 무엇을 할 수 있는지 정의하지만, 그러한 통제가 어떻게 적용되어야 하는지는 규정하지 않습니다. 이러한 분리를 통해 정책은 런타임, 프레임워크, 언어를 넘어 이식이 가능합니다.
v0.1.1-alpha — 핵심 사양, 4개 SDK(Rust, TypeScript, Python, Go) 및 h2h CLI가 모두 공개되어 정상 작동합니다. 10가지 규칙 유형과 3가지 확장 모듈을 통해 파싱, 검증, 평가, 병합, 해석, 탐지, 서명, 감사를 수행할 수 있습니다. API 표면은 안정화되고 있지만 아직 확정(frozen)되지는 않았습니다 — v1.0 이전에 개선이 있을 것으로 예상됩니다.
hushspec: "0.1.0"
name: production-agent
rules:
forbidden_paths:
patterns:
- "**/.ssh/**"
- "**/.aws/**"
- "/etc/shadow"
egress:
allow:
- "api.openai.com"
- "*.anthropic.com"
- "api.github.com"
default: block
tool_access:
block: [shell_exec, run_command]
require_confirmation: [file_write, git_push]
default: allow
secret_patterns:
patterns:
- name: aws_key
pattern: "AKIA[0-9A-Z]{16}"
severity: critical
skip_paths: ["**/test/**"]
shell_commands:
forbidden_patterns:
- "rm\\s+-rf\\s+/"
- "curl.*\\|.*bash"
4개 SDK 모두 파싱 및 검증부터 해석과 평가까지 전체 HushSpec 파이프라인을 구현합니다.
Homebrew, npm 및 사전 빌드 바이너리는 릴리스 파이프라인이 아티팩트, tap 포뮬러, npm 패키지를 게시하는 첫 번째
v0.x태그부터 사용할 수 있습니다. 그때까지는 Cargo로 설치하세요.
모든 방법은 h2h 명령을 설치합니다. 아래 CLI 도구를 참조하세요.
[dependencies]
hushspec = "0.1"
npm install @hushspec/core
pip install hushspec
go get github.com/backbay-labs/hush/packages/go@main
use hushspec::HushSpec;
let yaml_str = "hushspec: \"0.1.0\"\nname: example\n";
let spec = HushSpec::parse(yaml_str)?;
let result = hushspec::validate(&spec);
assert!(result.is_valid());
import { parseOrThrow, validate } from '@hushspec/core';
const yamlString = 'hushspec: "0.1.0"\nname: example\n';
const spec = parseOrThrow(yamlString);
const result = validate(spec);
console.log(result.valid); // true
from hushspec import parse_or_raise, validate
yaml_string = 'hushspec: "0.1.0"\nname: example\n'
spec = parse_or_raise(yaml_string)
result = validate(spec)
assert result.is_valid
import (
"fmt"
"github.com/backbay-labs/hush/packages/go/hushspec"
)
yamlString := "hushspec: \"0.1.0\"\nname: example\n"
spec, err := hushspec.Parse(yamlString)
if err != nil {
panic(err)
}
result := hushspec.Validate(spec)
fmt.Println(result.IsValid())
각 SDK는 파싱된 사양과 액션을 받아 결정(allow, warn, deny)과 일치하는 규칙 세부 정보를 반환하는 evaluate() 함수를 제공합니다.
import { parseOrThrow, evaluate } from '@hushspec/core';
const spec = parseOrThrow(policyYaml);
const result = evaluate(spec, { type: 'egress', target: 'api.openai.com' });
// result.decision === 'allow' | 'warn' | 'deny'
// result.matched_rule === 'egress'
from hushspec import parse_or_raise, evaluate
spec = parse_or_raise(policy_yaml)
result = evaluate(spec, {"type": "egress", "target": "api.openai.com"})
assert result.decision in ("allow", "warn", "deny")
HushGuard는 정책 로딩 및 평가를 애플리케이션 코드를 위한 간단한 evaluate, check, enforce 인터페이스로 캡슐화합니다.
import { HushGuard } from '@hushspec/core';
const guard = HushGuard.fromFile('./policy.yaml');
guard.enforce({ type: 'tool_call', target: 'bash' }); // throws HushSpecDenied if denied
from hushspec import HushGuard
guard = HushGuard.from_file("./policy.yaml")
guard.enforce({"type": "tool_call", "target": "bash"}) # raises HushSpecDenied if denied
h2h CLI는 일반적인 정책 워크플로우를 다룹니다: 검증(validate), 테스트(test), 단일 액션 평가 및 설명(evaluate·explain), 린트(lint), diff, 포맷(format), 초기화(init), 서명(sign), 검증(verify), 패닉 모드 트리거(panic).
# Validate a policy against the HushSpec schema
h2h validate policy.yaml
# Run evaluation test suites
h2h test --fixtures ./tests/
# Evaluate one action and explain the decision
h2h eval policy.yaml --type egress --target api.example.com
h2h explain policy.yaml --type egress --target api.example.com
# Static analysis and linting
h2h lint policy.yaml
# Lint and auto-fix decision-neutral issues
h2h lint policy.yaml --fix
# Compare two policies and show effective decision changes
h2h diff old.yaml new.yaml
# Format policy files canonically
h2h fmt policy.yaml
# Scaffold a new policy project
h2h init --preset default
# Sign a policy with Ed25519
h2h sign policy.yaml --key h2h.key
# Verify a policy signature
h2h verify policy.yaml --key h2h.pub
# Generate a new Ed25519 keypair
h2h keygen
# Emergency override (deny-all kill switch)
h2h panic activate --sentinel /tmp/hushspec.panic
h2h panic deactivate --sentinel /tmp/hushspec.panic
설치 옵션(Homebrew, npm, Cargo, 사전 빌드 바이너리)은 위의 설치를 참조하세요.
evaluate_audited()는 규칙 추적, 정책 요약, 선택적 콘텐츠 편집(redaction)을 포함한 구조화된 결정 영수증을 생성합니다. 영수증은 hushspec-receipt.v0.schema.json을 준수하며 SOC 2, HIPAA, PCI-DSS, FedRAMP와 같은 감사 중심 환경을 지원하도록 설계되었습니다.
import { parseOrThrow, evaluateAudited } from '@hushspec/core';
const spec = parseOrThrow(policyYaml);
const receipt = evaluateAudited(spec, action, {
enabled: true,
include_rule_trace: true,
redact_content: false,
});
// receipt.decision, receipt.rule_evaluations, receipt.policy_summary
영수증 싱크(FileReceiptSink, ConsoleReceiptSink, FilteredSink, MultiSink, CallbackSink)는 4개 SDK 모두에서 영수증을 스토리지, 로깅 또는 OTLP 엔드포인트로 라우팅하는 데 사용할 수 있습니다.
탐지 파이프라인은 프롬프트 인젝션, 젤브레이크, 유출(exfiltration) 검사를 평가 흐름에 연결합니다. 정규식 기반 참조 탐지기는 모든 SDK에 포함되어 있으며, 사용자 정의 탐지기는 DetectorRegistry를 통해 등록할 수 있습니다.
import { parseOrThrow, evaluateWithDetection, DetectorRegistry } from '@hushspec/core';
const registry = DetectorRegistry.withDefaults();
const result = evaluateWithDetection(spec, action, registry, {
enabled: true,
prompt_injection_threshold: 0.5,
});
// result.detection_results contains matched patterns and confidence scores
사전 빌드된 어댑터는 프레임워크별 도구 호출을 HushSpec 평가 액션으로 변환합니다.
EvaluationObserver 인터페이스와 ObservableEvaluator 래퍼는 모든 평가, 정책 로드 및 정책 리로드에 대해 구조화된 이벤트를 내보냅니다. 내장 관찰자에는 JsonLineObserver, ConsoleObserver, MetricsCollector가 있습니다.
import { ObservableEvaluator, JsonLineObserver, MetricsCollector } from '@hushspec/core';
const evaluator = new ObservableEvaluator();
evaluator.addObserver(new JsonLineObserver(process.stderr));
evaluator.addObserver(new MetricsCollector());
const result = evaluator.evaluate(spec, action);
정책은 Ed25519 키로 서명하고 로드 시 검증할 수 있습니다. CLI는 sign, verify, keygen 명령을 제공합니다. 서명 형식은 hushspec-signature.v0.schema.json을 준수합니다.
# Generate a keypair
h2h keygen --output-dir mykeys
# Sign a policy (creates policy.yaml.sig)
h2h sign policy.yaml --key mykeys/h2h.key
# Verify the signature
h2h verify policy.yaml --key mykeys/h2h.pub
패닉 모드는 정책을 재배포하지 않고 즉시 활성화할 수 있는 전면 거부(deny-all) 킬 스위치입니다. 센티널 파일, CLI 또는 API 호출로 트리거할 수 있습니다. 패닉 모드가 활성화되어 있는 동안 모든 평가는 deny를 반환합니다.
# Activate panic mode
h2h panic activate --sentinel /tmp/hushspec.panic
# Deactivate
h2h panic deactivate --sentinel /tmp/hushspec.panic
import { activatePanic, deactivatePanic, isPanicActive } from '@hushspec/core';
activatePanic();
// All evaluate() calls now return deny
deactivatePanic();
정책은 로컬 파일, HTTPS URL(ETag 캐싱 및 SSRF 보호 포함) 또는 내장 규칙 세트에서 로드할 수 있습니다. PolicyWatcher와 PolicyPoller는 프로세스를 재시작하지 않고도 핫 리로드를 지원합니다.
import { PolicyWatcher, HushGuard } from '@hushspec/core';
const guard = HushGuard.fromFile('./policy.yaml');
const watcher = new PolicyWatcher('./policy.yaml', {
onChange: (newSpec) => guard.swapPolicy(newSpec),
});
watcher.start();
HushSpec은 더 고급 정책 동작을 위한 선택적 확장 모듈을 지원합니다:
| 확장 | 목적 |
|---|---|
| Posture | 능력 및 예산을 위한 선언적 상태 머신 |
| Origins | 출처 인식 정책 프로젝션 (Slack, GitHub, 이메일 등) |
| Detection | 프롬프트 인젝션, 젤브레이크, 위협 인텔리전스를 위한 임계값 구성 |
extensions:
posture:
initial: standard
states:
standard: { capabilities: [file_access, egress] }
restricted: { capabilities: [file_access] }
transitions:
- { from: "*", to: restricted, on: critical_violation }
detection:
prompt_injection:
block_at_or_above: high
바로 사용 가능한 정책은 rulesets/에 있습니다:
HushSpec 문서는 Clawdstrike에서 기본적으로 로드됩니다:
// Auto-detects HushSpec vs Clawdstrike-native format
let policy = clawdstrike::Policy::from_yaml_auto(yaml)?;
# Convert between formats
hush policy migrate policy.yaml --to hushspec
spec/ Normative specification, including core and extension docs
schemas/ JSON Schema definitions
crates/ Rust crates
hushspec/ Core library: parse, validate, merge, resolve, evaluate, detect, sign
hushspec-cli/ CLI tool
hushspec-testkit/ Conformance test runner
packages/ Language SDKs for TypeScript, Python, and Go
rulesets/ Built-in security rulesets
fixtures/ Conformance and evaluation fixtures
docs/ mdBook documentation site
generated/ Generated shared SDK contract artifacts
scripts/ Code generation and CI tooling
표준 사양은 spec/에 있습니다. 프로그램적 검증을 위한 JSON Schema 정의는 schemas/에 있습니다. 전체 문서는 docs/에 있습니다.
Apache-2.0. LICENSE를 참조하세요.
| 기능 | Rust | TypeScript | Python | Go |
|---|
| 파싱 + 검증 (Level 1) | 예 | 예 | 예 | 예 |
| 병합 (Level 2) | 예 | 예 | 예 | 예 |
| 해석 (Level 2+) | 예 | 예 | 예 | 예 |
| 평가 (Level 3) | 예 | 예 | 예 | 예 |
| 감사 추적 (Level 4) | 예 | 예 | 예 | 예 |
| 탐지 | 예 | 예 | 예 | 예 |
| 관찰 가능성 | 예 | 예 | 예 | 예 |
| 영수증 싱크 | 예 | 예 | 예 | 예 |
| 방법 | 명령어 |
|---|
| Homebrew (macOS/Linux) | brew install backbay-labs/tap/h2h |
| npm | npm install -g @hushspec/cli (또는 npx @hushspec/cli validate policy.yaml) |
| Cargo (소스에서) | cargo install hushspec-cli |
| 사전 빌드 바이너리 | GitHub 릴리스 — h2h-<tag>-<target>.tar.gz + SHA256SUMS, 출처 증명(provenance) 포함 |
| 프레임워크 | 어댑터 | SDK |
|---|
| Claude / Anthropic | mapClaudeToolToAction, createSecureToolHandler | TypeScript |
| OpenAI | mapOpenAIToolCall, createOpenAIGuard | TypeScript |
| MCP (Model Context Protocol) | mapMCPToolCall, createMCPGuard | TypeScript |
import { HushGuard, mapClaudeToolToAction } from '@hushspec/core';
const guard = HushGuard.fromFile('./policy.yaml');
const action = mapClaudeToolToAction(toolUseBlock);
guard.enforce(action);
| 규칙 | 목적 |
|---|
forbidden_paths | 민감한 파일시스템 경로에 대한 접근 차단 |
path_allowlist | 허용 목록 기반 읽기/쓰기/패치 접근 |
egress | 도메인별 네트워크 이그레스 제어 |
secret_patterns | 파일 콘텐츠에서 시크릿 탐지 |
patch_integrity | diff 안전성 검증 (크기 제한, 금지 패턴) |
shell_commands | 위험한 셸 명령 차단 |
tool_access | 도구/MCP 호출 제어 |
computer_use | CUA 동작 제어 |
remote_desktop_channels | 원격 데스크톱 사이드 채널 제어 |
input_injection | 입력 주입 기능 제어 |
| 규칙 세트 | 설명 |
|---|
default | AI 에이전트 실행을 위한 균형 잡힌 보안 |
strict | 최대 보안, 최소 권한 |
permissive | 개발 친화적, 완화된 제한 |
ai-agent | AI 코딩 어시스턴트에 최적화 |
cicd | CI/CD 파이프라인 보안 |
remote-desktop | 컴퓨터 사용 에이전트 세션 |
panic | 전면 거부 긴급 재정의 |