validators

package
v0.4.92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package validators 实现按漏洞类别的程序化验证(v0.4.92 验证层冲刺,方向调研 共识①:渗透 agent 可信度取决于 harness——XBOW validators / AIxCC PoV 范式)。

与 evidence_check(人工可读的 13 项静态检查)互补:这里跑真实探针并对响应做 机械断言,输出机器可判定的 verdict 与证据标记(validate:<token>:pass), agent 把标记引用进 report_finding 的 evidence 即完成「机验闭环」。

v1 覆盖三类:RCE/命令注入(回显 token + 时延)、XSS(反射+上下文+CSP 核查)、 SSRF(OOB 回连 + 响应特征)。全部非阻断——validator 是加分证据,不替代 evidence_check 的必过项,也不拦截任何上报路径。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkerOf

func MarkerOf(token string) string

MarkerOf 组装 evidence 里的机验标记(pass 时才写入 evidence)。

func NewToken

func NewToken() string

NewToken 生成 8 字节 hex 探针标记(64bit 熵足够区分并发验证)。

Types

type ProbeResult

type ProbeResult struct {
	Name     string `json:"name"`     // 探针名(echo_token / sleep_timing / reflection_raw ...)
	Injected string `json:"injected"` // 实际注入的参数值
	Detail   string `json:"detail"`   // 断言结论(人读)
	Hit      bool   `json:"hit"`      // 机械断言是否命中
}

ProbeResult 是单个探针的断言结果。

type Result

type Result struct {
	Class   string        `json:"class"`
	Verdict Verdict       `json:"verdict"`
	Token   string        `json:"token"`
	Probes  []ProbeResult `json:"probes"`
	Marker  string        `json:"marker,omitempty"`
	Note    string        `json:"note,omitempty"`
}

Result 是一次 validate 的完整结果。Marker 只在 Verdict==VerdictPass 时非空: 形如 `validate:<token>:pass`,agent 把它引用进 report_finding 的 evidence, evidence_check 的机验检查项据此判定。

func RunRCE

func RunRCE(ctx context.Context, client *http.Client, targetURL, param, token string) *Result

func RunSSRF

func RunSSRF(ctx context.Context, client *http.Client, targetURL, param, token string, oob SSRFOOB) *Result

RunSSRF 验证 SSRF 类,三组探针:

  1. OOB 型——参数注入回连 URL(http://cb/<token>),目标侧发起请求即命中 (最可靠的执行级证据);依赖外带通道可用。
  2. 文件读取响应型——file:///etc/passwd 等探针,断言响应含强特征;有响应 回读即强信号。
  3. 云元数据型——169.254.169.254 等探针,断言响应含 ami-/instance-id 特征。

verdict:OOB 命中 → pass;响应强特征命中 → pass(note 注明类型); 全未命中 → fail(不代表无 SSRF,只代表本组探针没打出来)。

func RunXSS

func RunXSS(ctx context.Context, client *http.Client, targetURL, param, token string) *Result

RunXSS 验证 XSS 类(v1=反射+上下文机械断言,执行确认留给浏览器步骤):

  1. 反射探针——注入带唯一标记的 SVG/onload payload,断言响应含「未转义」的 payload 关键片段(<svg 原样出现、&lt;svg 不算)且与标记同现(排除静态误配);
  2. CSP 核查——严格 CSP(script-src/default-src 且无 unsafe-inline)时 verdict 降为 warn:反射确认但执行大概率被拦。

verdict:原始反射+宽松 CSP → pass;原始反射+严格 CSP → warn; 仅转义反射(&lt;svg)→ fail(带「已转义」结论);无反射 → fail。

type SSRFOOB

type SSRFOOB struct {
	// Base 是回连 URL 前缀(不含 token),形如 http://<LHOST>:<LPORT>。
	// 空 = 无法外带(未配置出口解析/监听不可用),OOB 探针跳过。
	Base string
	// Note 是外带通道不可用时的说明(透传进结果 Note)。
	Note string
	// Wait 是 OOB 等待时长(<=0 用默认 8s)。
	Wait time.Duration
	// WaitOOB 阻塞等待回连命中:返回 true 表示有连接携带 token。工具层查
	// listener 会话 Preview 实现。
	WaitOOB func(token string, timeout time.Duration) bool
}

SSRFOOB 是外带回连的接入面:工具层用 listener.Manager 实现它(起临时监听、 按超时查会话 Preview 是否含 token),validators 包保持纯函数。

type Verdict

type Verdict string

Verdict 是一次验证的机器判定:pass=探针断言命中;warn=有部分信号但缺执行级 证据(如 XSS 仅确认反射、未确认执行);fail=探针未命中(不代表漏洞不存在, 只代表本组探针没打出来)。

const (
	VerdictPass Verdict = "pass"
	VerdictWarn Verdict = "warn"
	VerdictFail Verdict = "fail"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL