安全由伺服器決定,而不是小工具狀態。
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 完整性 · 一次性原子消耗 · server-only 業務訊號 · 關鍵 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 測試
- 發布 checksum 與 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。