关于 testing-for-business-logic-vulnerabilities
这是面向授权渗透测试人员的业务逻辑漏洞测试技能,帮助梳理业务流程并检查规则绕过、状态操纵和权限问题。内容涵盖常见测试步骤及结果报告格式。
主要功能
- 01梳理关键业务流程与约束
- 02测试价格、数量和总额操纵
- 03检查多步骤流程绕过
- 04评估并发请求竞态条件
- 05测试角色权限与奖励滥用
- 06整理漏洞复现和报告
适用场景
- 01审查电商结账和优惠券规则
- 02测试注册、审批等多步骤流程
- 03检查转账或奖励系统的并发问题
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill testing-for-business-logic-vulnerabilities安装后在 Claude Code 中输入/testing-for-business-logic-vulnerabilities确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEreferences/api-reference.mdscripts/agent.py详细介绍
业务逻辑漏洞测试
适用场景
- 在已授权的渗透测试中,自动化扫描器发现的技术漏洞很少时
- 评估电子商务平台的定价、购物车和支付流程是否存在操纵风险时
- 测试多步骤工作流(注册、结账、审批流程)是否存在绕过机会时
- 评估优惠券、折扣码、推荐和奖励系统等受速率限制的功能时
- 对金融应用、投票系统或任何包含关键业务规则的应用进行安全评估时
前提条件
- 授权:获得书面的渗透测试协议,明确涵盖业务逻辑测试
- Burp Suite Professional:用于拦截和修改多步骤请求流程
- 应用理解:充分了解应用预期的业务工作流
- 多个测试账户:拥有不同权限级别和状态的账户
- 浏览器 DevTools:用于检查客户端验证逻辑
- 文档:描述预期行为的业务需求或用户故事
工作流
步骤 1:梳理业务工作流和规则
记录所有关键业务流程及其预期约束。
# Critical business flows to map:
# 1. Registration/Onboarding flow
# - Email verification requirements
# - Account approval process
# - Role assignment logic
# 2. E-commerce/Purchase flow
# - Product selection → Cart → Checkout → Payment → Confirmation
# - Price calculation logic
# - Discount/coupon application
# - Quantity limits
# - Shipping cost calculation
# 3. Authentication/Authorization flow
# - Login → MFA → Dashboard
# - Password reset → Token → New password
# - Role escalation/approval
# 4. Financial transactions
# - Balance check → Transfer → Confirmation
# - Withdrawal limits
# - Currency conversion
# Document expected constraints:
# - Minimum order amounts
# - Maximum quantity per item
# - Coupon usage limits (one per user)
# - Referral reward caps
# - Withdrawal daily limits
# - Account verification requirements before certain actions
步骤 2:测试价格和数量操纵
拦截并修改请求中的价格、数量和总额。
# Test negative quantity
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": -1, "price": 99.99}' \
"https://target.example.com/api/cart/add"
# Test zero price
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": 1, "price": 0}' \
"https://target.example.com/api/cart/add"
# Test extremely large quantity
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": 999999999}' \
"https://target.example.com/api/cart/add"
# Test decimal/float manipulation
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": 0.001, "price": 0.01}' \
"https://target.example.com/api/cart/add"
# Test integer overflow
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"product_id": 1, "quantity": 2147483647}' \
"https://target.example.com/api/cart/add"
# Modify total amount directly in checkout request
# Intercept in Burp and change total from 299.99 to 0.01
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"cart_id": "abc123", "total": 0.01, "payment_method": "card"}' \
"https://target.example.com/api/checkout"
步骤 3:测试工作流步骤绕过
尝试跳过多步骤流程中必需的步骤。
# Skip email verification
# Instead of: Register → Verify email → Access dashboard
# Try: Register → Access dashboard directly
curl -s -H "Authorization: Bearer $UNVERIFIED_TOKEN" \
"https://target.example.com/api/dashboard"
# Skip payment step
# Instead of: Cart → Shipping → Payment → Confirmation
# Try: Cart → Confirmation (skip payment)
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"cart_id": "abc123", "shipping_address": "123 Main St"}' \
"https://target.example.com/api/orders/confirm"
# Skip MFA step
# Instead of: Login → MFA → Dashboard
# Try: Login → Dashboard (skip MFA)
# After successful password auth, directly access protected resources
# Skip approval process
# Instead of: Submit request → Manager approval → Access granted
# Try: Submit request → Access granted (skip approval)
# Repeat a step that should be one-time
# Apply same coupon code multiple times
for i in $(seq 1 5); do
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"coupon_code": "DISCOUNT50"}' \
"https://target.example.com/api/cart/apply-coupon"
echo "Attempt $i"
done
步骤 4:测试业务逻辑中的竞态条件
利用并发请求处理过程中的时间窗口。
# Race condition on coupon application
# Send multiple identical requests simultaneously
for i in $(seq 1 10); do
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"coupon_code": "ONETIME50"}' \
"https://target.example.com/api/cart/apply-coupon" &
done
wait
# Race condition on balance transfer
# If user has $100, try to transfer $100 to two accounts simultaneously
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to": "user_b", "amount": 100}' \
"https://target.example.com/api/transfer" &
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to": "user_c", "amount": 100}' \
"https://target.example.com/api/transfer" &
wait
# Race condition on reward claiming
# Using Burp Turbo Intruder for precise timing:
# 1. Send request to Turbo Intruder
# 2. Use race condition script template
# 3. Send 20+ requests simultaneously
# 4. Check if reward was claimed multiple times
步骤 5:测试推荐和奖励系统滥用
寻找利用促销功能和奖励机制的方法。
# Self-referral: refer your own email
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"referral_email": "[email protected]"}' \
"https://target.example.com/api/referrals/invite"
# Referral code reuse across multiple accounts
# Create multiple accounts and use same referral code
# Coupon stacking: apply multiple discount codes
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"coupon_codes": ["SAVE10", "WELCOME20", "VIP50"]}' \
"https://target.example.com/api/cart/apply-coupons"
# Abuse free trial: re-register with same details
# Test if [email protected] or [email protected] bypass duplicate detection
# Gift card / credit manipulation
# Buy gift card with gift card balance (circular)
# Apply gift card with value > purchase price (get change as credit)
# Test reward point manipulation
# Earn points on order → Cancel order → Keep points
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
"https://target.example.com/api/orders/12345/cancel"
# Check if reward points from order 12345 were revoked
步骤 6:测试角色和权限逻辑
评估授权逻辑,检查是否能通过业务流程提升权限。
# Role escalation via registration parameter
curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"Test1234!","role":"admin"}' \
"https://target.example.com/api/auth/register"
# Organization tenant boundary testing
# User in Org A tries to access Org B resources via business workflows
curl -s -X POST \
-H "Authorization: Bearer $TOKEN_ORG_A" \
-H "Content-Type: application/json" \
-d '{"org_id": "org_b_id", "action": "view_reports"}' \
"https://target.example.com/api/reports"
# Test for privilege retention after role downgrade
# Admin → Regular user: can they still access admin functions?
# Employee → Terminated: can they still access company resources?
# Test invitation/delegation abuse
# Invite user with higher privileges than inviter has
curl -s -X POST \
-H "Authorization: Bearer $REGULAR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","role":"admin"}' \
"https://target.example.com/api/users/invite"
核心概念
| 概念 | 描述 |
|---|---|
| 业务逻辑缺陷 | 应用工作流或规则中的漏洞,可导致非预期操作 |
| 价格操纵 | 修改客户端请求中的价格、数量或总额 |
| 工作流绕过 | 跳过多步骤业务流程中必需的步骤 |
| 竞态条件 | 利用并发请求处理违反业务约束 |
| 权限提升 | 通过操纵业务流程获得更高权限 |
| 负向测试 | 使用非预期值(负数、零、null、极端值)进行测试 |
| 状态操纵 | 以业务逻辑未预期的顺序改变应用状态 |
工具和系统
| 工具 | 用途 |
|---|---|
| Burp Suite Professional | 拦截、修改请求并测试请求序列 |
| Burp Turbo Intruder | 高速发送请求,用于测试竞态条件 |
| Burp Sequencer | 分析令牌随机性,以测试引用值是否可预测 |
| OWASP ZAP | 基于代理的测试的开源替代工具 |
| Postman | 使用集合运行器和环境变量测试工作流 |
| 自定义脚本 | 用于自动化业务逻辑测试的 Python/bash 脚本 |
常见场景
场景 1:叠加使用优惠码
某电子商务网站允许同时使用多个优惠码。通过叠加使用 “WELCOME10”、“SAVE20” 和 “VIP30”,总折扣超过商品价格,导致余额为负或订单免费。
场景 2:资金转账中的竞态条件
某银行应用在转账前检查余额,但不会锁定账户。从余额为 $1000 的账户同时发起两笔 $1000 转账,结果两笔都成功,凭空产生资金。
场景 3:结账价格覆盖
结账流程会在 POST 请求正文中发送总金额。拦截并将总金额从 $499.99 改为 $0.01,即可按操纵后的价格成功下单。
场景 4:重复使用密码重置令牌
密码重置流程会生成一次性令牌,但使用后不会使其失效。同一个令牌可以被重复用于重置密码。
输出格式
## Business Logic Vulnerability Finding
**Vulnerability**: Price Manipulation in Checkout Flow
**Severity**: Critical (CVSS 9.1)
**Location**: POST /api/checkout - `total` parameter
**OWASP Category**: A04:2021 - Insecure Design
### Reproduction Steps
1. Add item to cart (price: $499.99)
2. Proceed to checkout
3. Intercept POST /api/checkout request in Burp
4. Modify "total" from 499.99 to 0.01
5. Forward the request; order completes at $0.01
### Business Rules Violated
| Rule | Expected | Actual |
|------|----------|--------|
| Server-side price calculation | Total computed server-side | Client-submitted total accepted |
| Coupon single use | One coupon per order | Same coupon applied 5 times |
| Negative quantity check | Quantity >= 1 | Quantity -1 accepted (credit issued) |
| Race condition on transfer | Balance checked atomically | Dual transfer exceeded balance |
### Impact
- Financial loss: orders processed at attacker-controlled prices
- Inventory loss: products shipped for $0.01
- Reward abuse: unlimited referral credits via self-referral
- Double-spending via race condition on transfers
### Recommendation
1. Perform all price calculations server-side; never trust client-submitted totals
2. Implement server-side validation for quantity (positive integers only)
3. Use database-level locks or atomic transactions for financial operations
4. Implement idempotency keys to prevent duplicate transaction processing
5. Rate-limit and log coupon applications, referral submissions, and transfers
评论
支持 Markdown