david-grig/VeriPay
GitHub: david-grig/VeriPay
VeriPay 将可验证意图规范嵌入 ISO 20022 清算消息,在网关层面阻断针对自主 AI 支付代理的指令注入与交易篡改。
Stars: 0 | Forks: 0
# VeriPay
VeriPay 是一个企业级的 agentic B2B 采购与交易安全网关。它将官方的 **Mastercard/Google Verifiable Intent (VI) 规范**与传统的 **ISO 20022 `pacs.008` (Customer Credit Transfer)** 实时清算消息结构集成在一起。这可以保护自主 AI 交易循环免受清算网络边界处的 prompt 注入、中间人篡改和上下文漂移的影响。
## 项目结构
```
VeriPay/
├── requirements.txt # Python dependencies (fastmcp, pyjwt, cryptography, etc.)
├── README.md # System Architecture & Documentation
├── KAGGLE_WRITEUP.md # Kaggle Capstone Project submission writeup
├── src/
│ ├── __init__.py
│ ├── utils/
│ │ ├── __init__.py
│ │ └── crypto_utils.py # RSA generation, JWT L2/L3a signatures, SHA-256 checkout hash
│ ├── mcp/
│ │ ├── __init__.py
│ │ └── validator_server.py # FastMCP Clearing Gateway Server exposing transaction validation
│ ├── agents/
│ │ ├── __init__.py
│ │ └── compliance_agent.py # ADK-driven guardrail agent (evaluates proposal, signs L3a XML)
│ └── main.py # E2E pipeline orchestrator running Scenarios A, B, and C
└── tests/
├── __init__.py
└── test_security.py # Security Evaluation Suite (Adversary and injection attacks)
```
## Verifiable Intent 数据流架构
VeriPay 实施了 Verifiable Intent 标准定义的三个逻辑安全层:
```
┌──────────────────────────────────────────────────────────┐
│ Layer 1 (L1): Human Identity │
│ - Consumer / Corporate Administrator Public Key │
└────────────────────────────┬─────────────────────────────┘
│
▼ Signs
┌──────────────────────────────────────────────────────────┐
│ Layer 2 (L2): Mandate Limits │
│ - Corporate Policies (max_amount, allowed payees) │
│ - Encoded as a User-Signed JWT │
└────────────────────────────┬─────────────────────────────┘
│
▼ Constrains
┌──────────────────────────────────────────────────────────┐
│ Layer 3 (L3): Action Execution │
│ - L3a (Payment Token): Agent-signed JWT referencing L2 │
│ and containing `checkout_hash` (SHA-256 bound) │
│ - L3b (Checkout Context): Merchant cart details │
└────────────────────────────┬─────────────────────────────┘
│
▼ Injects L3a Token
┌──────────────────────────────────────────────────────────┐
│ ISO 20022 pacs.008 XML Envelope │
│ - Structures transaction: amount, currency, creditor │
│ - Layer 3a Token is embedded inside │
└────────────────────────────┬─────────────────────────────┘
│
▼ Dispatches to
┌──────────────────────────────────────────────────────────┐
│ Clearing Network (Validator Server) │
│ - Parses XML, extracts L3a, decodes L2 delegation │
│ - Verifies L3a signature, L2 signature, and constraints │
│ - Compares XML parameters against signed `checkout_hash`│
└──────────────────────────────────────────────────────────┘
```
1. **L1 (Identity):** 以加密方式将企业买家的密钥对与授权系统关联起来。
2. **L2 (Intent/Mandate):** 由人工配置的边界(例如,最大支出 = $10,000,允许的收款人 = `["US1234567890"]`),由 L1 身份进行签名。
3. **L3 (Action/Fulfillment):** 暴露一个分离的信任 token:
- **L3a (Payment Token):** 由 agent 提取并嵌入到 ISO 20022 payload 中。
- **L3b (Checkout Context):** 包含商户发票详情。它们通过加密的 `checkout_hash`(`payee_account`、`amount` 和 `currency` 的 SHA-256)进行绑定。
4. **Network Gateway (Clearing Layer):** 清算网关解析 XML envelope,提取 L3a token,并将 XML 交易变量与已签名的 `checkout_hash` 进行匹配。任何签名后的篡改都会导致 hash 不匹配,并导致在网关层面被立即拒绝。
## 安装与设置
1. **前置条件:** 需要 Python 3.13+。
2. **克隆并导航:**
cd VeriPay
3. **安装依赖:**
pip install -r requirements.txt
## 作为 MCP Server 暴露
VeriPay 通过 FastMCP 实现了 **Model Context Protocol (MCP)**。清算网络网关可以暴露给支持 MCP 的客户端。
### 在 `settings.json` 中注册
将以下配置块添加到客户端的 `settings.json` 文件中:
```
{
"mcpServers": {
"veripay-clearing-gateway": {
"command": "python",
"args": [
"/Users/david/.gemini/antigravity/scratch/VeriPay/src/mcp/validator_server.py"
],
"env": {
"PYTHONPATH": "/Users/david/.gemini/antigravity/scratch/VeriPay"
}
}
}
}
```
## 执行指南
### 1. 运行编排 Pipeline
运行自动化 orchestrator 以验证场景 A(合规路径)、场景 B(限额违规)和场景 C(未批准的收款人):
```
PYTHONPATH=. python src/main.py
```
### 2. 运行自动化安全评估套件
使用 `pytest` 执行安全测试,以模拟对抗性攻击(prompt 注入、收款人篡改和金额夸大)并验证网关拒绝:
```
PYTHONPATH=. pytest -v tests/test_security.py
```
标签:AI安全, Chat Copilot, CVE, ISO 20022, MCP, 安全规则引擎, 支付网关, 数字签名, 逆向工具, 防提示注入