Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
hush — 针对AI代理行为边界的可移植安全规则 | Kitploit
工具/GitHubGitHub/backbay-labs/hush
云安全DevSecOps秘密检测威胁情报供应链安全事件响应AI 安全
GitHubbackbay-labs/hush

hush

针对AI代理行为边界的可移植安全规则

查看仓库
23131个月前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
网站

HushSpec

面向 AI 智能体安全规则的便携式开放规范

CI License Spec Version crates.io npm PyPI

规范 · 文档 · 规则集 · JSON Schema


HushSpec 是一种面向 AI 智能体安全规则的开放策略格式。它定义了智能体在运行时可以执行哪些操作,包括文件系统访问、网络出口、工具使用、机密信息检测等,而不规定如何强制执行这些控制。这种分离使策略能够跨运行时、框架和语言进行移植。

v0.1.1-alpha — 核心规范、全部四个 SDK(Rust、TypeScript、Python、Go)以及 h2h CLI 均已发布并可用。通过它们,你可以对 10 种规则类型和 3 个扩展模块执行解析、验证、评估、合并、归一化、检测、签名和审计。API 接口面正在趋于稳定,但尚未冻结——在 v1.0 之前预计还会有调整。

快速示例

root@kitploit:~
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"

SDK 一致性

四个 SDK 均实现了完整的 HushSpec 流水线,涵盖从解析、验证到归一化和评估的全流程。

安装

CLI

Homebrew、npm 和预编译二进制将从发布流水线构建的第一个 v0.x 标签起提供,一旦发布流水线发布了工件、tap 公式和 npm 包即可使用。在此之前,请通过 Cargo 安装。

所有安装方法都会安装 h2h 命令。请参阅下方的 CLI 工具。

Rust

root@kitploit:~
[dependencies]
hushspec = "0.1"

TypeScript

root@kitploit:~
npm install @hushspec/core

Python

root@kitploit:~
pip install hushspec

Go

root@kitploit:~
go get github.com/backbay-labs/hush/packages/go@main

快速上手

Rust

root@kitploit:~
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());

TypeScript

root@kitploit:~
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

Python

root@kitploit:~
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

Go

root@kitploit:~
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 都提供一个 evaluate() 函数,该函数接收一个已解析的规范和一个动作,然后返回决策(allow、warn 或 deny)以及匹配的规则详情。

root@kitploit:~
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'
root@kitploit:~
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 中间件

HushGuard 将策略加载和评估封装在面向应用程序代码的 evaluate、check 和 enforce 简单接口之后。

root@kitploit:~
import { HushGuard } from '@hushspec/core';

const guard = HushGuard.fromFile('./policy.yaml');
guard.enforce({ type: 'tool_call', target: 'bash' }); // throws HushSpecDenied if denied
root@kitploit:~
from hushspec import HushGuard

guard = HushGuard.from_file("./policy.yaml")
guard.enforce({"type": "tool_call", "target": "bash"})  # raises HushSpecDenied if denied

CLI 工具

h2h CLI 涵盖了常见的策略工作流:验证、测试、评估和解释单个动作、lint、diff、格式化、初始化、签名、验证和触发恐慌模式。

root@kitploit:~
# 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() 会生成结构化的决策回执,其中包含规则追踪、策略摘要以及可选的内容脱敏。回执符合 hushspec-receipt.v0.schema.json,旨在支持 SOC 2、HIPAA、PCI-DSS 和 FedRAMP 等重审计环境。

root@kitploit:~
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)在四个 SDK 中均可用,用于将回执路由到存储、日志或 OTLP 端点。

检测流水线

检测流水线将提示注入、越狱和数据外泄检查接入评估流程。基于正则的参考检测器随所有 SDK 一同提供,自定义检测器可以通过 DetectorRegistry 注册。

root@kitploit:~
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。

root@kitploit:~
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。

root@kitploit:~
# 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
紧急覆盖(恐慌模式)

恐慌模式是一种全部拒绝的紧急熔断开关,无需重新部署策略即可立即激活。你可以通过哨兵文件、CLI 或 API 调用触发它。在恐慌模式激活期间,每次评估都会返回 deny。

root@kitploit:~
# Activate panic mode
h2h panic activate --sentinel /tmp/hushspec.panic

# Deactivate
h2h panic deactivate --sentinel /tmp/hushspec.panic
root@kitploit:~
import { activatePanic, deactivatePanic, isPanicActive } from '@hushspec/core';

activatePanic();
// All evaluate() calls now return deny
deactivatePanic();
策略加载与热重载

策略可以从本地文件、HTTPS URL(带 ETag 缓存和 SSRF 防护)或内置规则集加载。PolicyWatcher 和 PolicyPoller 支持无需重启进程的热重载。

root@kitploit:~
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();

10 条核心规则

扩展

HushSpec 支持可选的扩展模块,以实现更高级的策略行为:

扩展用途
Posture用于能力和预算的声明式状态机
Origins感知来源的策略投影(Slack、GitHub、电子邮件等)
Detection提示注入、越狱、威胁情报的阈值配置
root@kitploit:~
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/:

与 Clawdstrike 配合使用

HushSpec 文档可在 Clawdstrike 中原生加载:

root@kitploit:~
// Auto-detects HushSpec vs Clawdstrike-native format
let policy = clawdstrike::Policy::from_yaml_auto(yaml)?;
root@kitploit:~
# Convert between formats
hush policy migrate policy.yaml --to hushspec

仓库结构

root@kitploit:~
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

设计原则

  • 默认拒绝:未知字段会被拒绝,无效文档会以显式错误的形式失败。
  • 无状态:核心规则是纯声明式的,不包含运行时状态。
  • 引擎中立:规范不要求特定的强制执行引擎、检测器或插件模型。
  • 可扩展:Posture、Origins 和 Detection 保持可选,而不是让核心格式变得臃肿。

规范

规范性规范位于 spec/。用于程序化验证的 JSON Schema 定义位于 schemas/。完整文档位于 docs/。

许可证

Apache-2.0。请参阅 LICENSE。

下载工具
能力RustTypeScriptPythonGo
解析 + 验证(第 1 级)是是是是
合并(第 2 级)是是是是
归一化(第 2 级以上)是是是是
评估(第 3 级)是是是是
审计追踪(第 4 级)是是是是
检测是是是是
可观测性是是是是
回执接收器是是是是
方法命令
Homebrew(macOS/Linux)brew install backbay-labs/tap/h2h
npmnpm install -g @hushspec/cli(或 npx @hushspec/cli validate policy.yaml)
Cargo(从源码)cargo install hushspec-cli
预编译二进制GitHub Releases — h2h-<tag>-<target>.tar.gz + SHA256SUMS,附来源证明
框架适配器SDK
Claude / AnthropicmapClaudeToolToAction, createSecureToolHandlerTypeScript
OpenAImapOpenAIToolCall, createOpenAIGuardTypeScript
MCP(模型上下文协议)mapMCPToolCall, createMCPGuardTypeScript
root@kitploit:~
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阻止危险的 shell 命令
tool_access控制工具/MCP 调用
computer_use控制 CUA(计算机使用智能体)操作
remote_desktop_channels控制远程桌面侧信道
input_injection控制输入注入能力
规则集描述
default面向 AI 智能体执行的均衡安全
strict最高安全性,最小权限
permissive适合开发,限制宽松
ai-agent针对 AI 编码助手优化
cicdCI/CD 流水线安全
remote-desktop计算机使用(computer use)智能体会话
panic全部拒绝的紧急覆盖