安全由服务器决定,而不是由小组件状态决定。
2IZI Guard 通过本地风险评估、自适应摩擦和一次性服务器授权令牌保护表单与公开操作。核心运行时不强制依赖外部 CAPTCHA。
集成面小,最终权限始终在服务器端。
当前核心面向 PHP 8.1+,安全边界不绑定框架。每个 action 显式保护,并在业务操作前消费 token。
1. Frontend
<script src="/guard/public/assets/guard.js?v=0.4.10" defer></script> <form data-guard-action="contact"> … </form>
2. Protected action
$result = Guard::verifyAndConsume(
$_POST['guard_token'] ?? '',
'contact'
);
if (!$result->allowed()) {
http_response_code(403);
exit;
}典型 actions
loginregisterpassword_resetcontactcheckoutfile_upload一个受保护 action,五个独立检查点。
浏览器可以参与 challenge,但业务权限始终由服务器签发并消费。
验证上下文
先检查 Origin、action、session 和基础限流。
本地评分
服务器与应用信号生成可解释的风险决策。
增加摩擦
策略选择 PASS、PoW、交互、节流或拒绝。
一次签发
随机 256-bit opaque token 绑定 session/action/origin 和短 TTL。
原子消费
业务 endpoint 只消费一次;重放、失配和过期会被拒绝。
Policy modes
可信流量可静默通过,高风险可触发 PoW、按住确认、节流或拒绝。
Integration contract
当前核心面向 PHP 8.1+,安全边界不绑定框架。每个 action 显式保护,并在业务操作前消费 token。
Action registry
The server defines allowed action names. Never use a client-provided action as authorization context.
'contact' => [ 'mode' => 'adaptive', 'fail_mode' => 'open_with_limit' ]
Origin / session binding
256-bit opaque token · 仅保存 hash · 短 TTL · action/session/origin 绑定 · HMAC 完整性 · 单次原子消费 · 仅服务器业务信号 · 关键 action fail-closed。
UI isolation
Shadow DOM isolates Guard visuals from host CSS. It is a UI reliability layer, not a security boundary.
Localization
UI locale is BCP-47-style, UTF-8, RTL-ready, touch/keyboard compatible, and extendable with locale packs.
假设攻击者知道完整代码库。
2IZI Guard 采用 Kerckhoffs-style 假设:源码、JavaScript、API、数据库结构、PoW 和阈值都可能公开。秘密和授权仍必须留在服务器端。
假设攻击者拥有
- 完整源码
- 现代 AI 模型
- Playwright / Selenium / headless Chromium
- 住宅代理
- 自己的流量记录
安全不依赖隐藏
- JavaScript
- challenge 算法
- 字段名
- endpoint
- risk threshold
公开代码应提升可审计性,而不是削弱安全模型。
阅读实现不应产生授权绕过。公开审查需要严格的发布、密钥、仓库权限和漏洞处理流程。
公开
- 源码与变更历史
- SECURITY.md 与 responsible disclosure
- 威胁模型与架构
- 自动 security / red-team 测试
- 发布校验和与 notes
保持私有
- 生产 config/guard.php
- APP_KEY 与 HMAC/privacy/rate-limit 密钥
- 数据库 dump 与真实 security events
- 真实 cookie/token/session
- 部署秘密与私有基础设施信息
Diagnostics, tests and updates
Diagnostics
php bin/diagnose.php
Check database state, key material, Origin configuration and registered actions before enabling enforcement.
Regression / red-team
bash tests/run-all.sh
Release acceptance includes replay, proxy, risk, tampering, UI and integration checks. Run disposable MariaDB/MySQL concurrency tests where available.
Updates
Read release notes and migrations first. Do not overwrite production config/guard.php with a distribution template. Rotate keys only when a release explicitly requires it.
Rollout
Start with Shadow Mode, review predicted decisions and false positives, tune action policies, then enable calibrated enforcement.
0.4.10 · pre-1.0 · 活跃开发
当前分支采用 security-first 架构并包含自动 regression/red-team 测试。建议先 Shadow Mode,再按真实流量调优 enforcement。