π Programmatic Attack Surfaces, Stateless Microservices & Object Authorization
In modern cloud-native architectures, single-page applications (SPAs), mobile apps, and microservice meshes interact primarily through programmatic Application Programming Interfaces (REST, GraphQL, gRPC). Unlike traditional server-rendered HTML applicationsβwhere the server controls the display logic and navigational flowsβAPIs decouple business data from the user interface. APIs expose direct database object identifiers, accept raw JSON/XML property payloads, and provide granular endpoints for business functions. Consequently, traditional network perimeter firewalls and legacy web application firewalls (WAFs) fail to detect modern API exploitation: requests arrive as syntactically valid JSON payloads over encrypted TLS channels with authentic authentication tokens. The OWASP API Security Top 10 standardizes the threat landscape of programmatic interfaces, dominated by Broken Object Level Authorization (BOLA), Broken Object Property Level Authorization (Mass Assignment), and Business Logic Subversion. Securing modern APIs requires embedding granular, object-level authorization and strict input/output DTO filtering directly into the application controller tier.
OWASP API SECURITY TOP 10 TAXONOMY & RISK MAPPING:
βββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β OWASP ID β VULNERABILITY CLASSIFICATION β CORE ARCHITECTURAL FAILURE MECHANISM β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API1:2023 β Broken Object Level Authorization (BOLA / IDOR) β Endpoint verifies user identity, but β
β β β fails to verify object ownership check! β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API2:2023 β Broken Authentication β Weak token validation, missing rate β
β β β limiting on login, unvalidated resets. β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API3:2023 β Broken Object Property Level Authorization β Merged Mass Assignment & Excessive Data β
β β β Exposure: binds raw JSON to model/DB. β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API4:2023 β Unrestricted Resource Consumption β Missing rate limits, unbounded page β
β β β queries (?limit=999999), payload bombs. β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API5:2023 β Broken Function Level Authorization (BFLA) β Administrative endpoints exposed to β
β β β low-privilege users; missing role checksβ
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API6:2023 β Unrestricted Access to Sensitive Business Flows β Business logic abuse: automated ticket β
β β β scalping, credit card testing, bots. β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API7:2023 β Server-Side Request Forgery (SSRF) β API server fetches untrusted URLs, β
β β β exposing cloud metadata (169.254.169.254β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API8:2023 β Security Misconfiguration β Permissive CORS, exposed stack traces, β
β β β unpatched gateways, missing TLS flags. β
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API9:2023 β Improper Inventory Management β Shadow APIs (untracked undocumented v1),β
β β β Zombie APIs (deprecated unpatched routesβ
βββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β API10:2023β Unsafe Consumption of APIs β Blindly trusting responses originating β
β β β from third-party vendor APIs/webhooks. β
βββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ
from flask import Flask, request, jsonify, g
import sqlite3
app = Flask(__name__)
# Mock authentication middleware: Populates g.current_user_id from validated JWT
@app.before_request
def authenticate():
# In production: jwt.decode(request.headers.get("Authorization"))
# Simulating authenticated student with user_id = 101
g.current_user_id = 101
# ==============================================================================
# INSECURE ENDPOINT: VULNERABLE TO BOLA (API1:2023)
# ==============================================================================
@app.route("/api/v1/academic_records/<int:record_id>", methods=["GET"])
def get_record_insecure(record_id):
conn = sqlite3.connect("university.db")
cursor = conn.cursor()
# SECURITY FLAW: Queries ONLY by the user-supplied record_id!
# The server confirms the caller is logged in, but NEVER checks if record_id
# belongs to g.current_user_id!
# Attacker (user 101) simply requests /api/v1/academic_records/102 and reads
# another student's confidential transcripts, grades, and personal data!
cursor.execute("SELECT id, student_id, cgpa, transcripts FROM records WHERE id = ?", (record_id,))
row = cursor.fetchone()
if not row:
return jsonify({"error": "Record not found"}), 404
return jsonify({"record_id": row[0], "student_id": row[1], "cgpa": row[2], "transcripts": row[3]})
# ==============================================================================
# SECURE HARDENED ENDPOINT: STRICT OBJECT OWNERSHIP ENFORCEMENT
# ==============================================================================
@app.route("/api/v2/academic_records/<int:record_id>", methods=["GET"])
def get_record_secure(record_id):
conn = sqlite3.connect("university.db")
cursor = conn.cursor()
# REMEDIATION: Scope the database query to BOTH the record_id AND the current user!
cursor.execute(
"SELECT id, student_id, cgpa, transcripts FROM records WHERE id = ? AND student_id = ?",
(record_id, g.current_user_id)
)
row = cursor.fetchone()
# Return 404 instead of 403 to prevent object existence enumeration!
if not row:
return jsonify({"error": "Record not found or access denied"}), 404
return jsonify({"record_id": row[0], "student_id": row[1], "cgpa": row[2], "transcripts": row[3]})
is_admin or account_balance directly to ORM database models) and Excessive Data Exposure (relying on client-side UI to hide sensitive JSON fields).
from pydantic import BaseModel, ValidationError
from flask import Flask, request, jsonify
app = Flask(__name__)
# ==============================================================================
# FLAW 1: MASS ASSIGNMENT VULNERABILITY (BLIND JSON MODEL BINDING)
# ==============================================================================
class UserDatabaseModel:
def __init__(self, user_id, username, email, is_admin=False, credit_balance=0.0):
self.user_id = user_id
self.username = username
self.email = email
self.is_admin = is_admin
self.credit_balance = credit_balance
@app.route("/api/v1/users/profile", methods=["PUT"])
def update_profile_insecure():
user = UserDatabaseModel(user_id=101, username="sdet_aarav", email="aarav@example.com")
incoming_json = request.get_json() or {}
# SECURITY DEFECT: Iterates over ALL incoming JSON keys and binds directly to model!
# Attacker submits payload:
# {"email": "new@example.com", "is_admin": true, "credit_balance": 99999.00}
for key, value in incoming_json.items():
if hasattr(user, key):
setattr(user, key, value) # VULNERABLE: Overwrites internal security properties!
return jsonify({"status": "updated", "is_admin": user.is_admin, "balance": user.credit_balance})
# ==============================================================================
# REMEDIATION: STRICT DATA TRANSFER OBJECT (DTO) INPUT/OUTPUT ALLOWLISTS
# ==============================================================================
class UserProfileUpdateDTO(BaseModel):
# Only permit explicit, non-sensitive fields to be mutated by clients!
username: str
email: str
class Config:
extra = "forbid" # Forbids unexpected JSON properties; raises ValidationError!
class UserProfileResponseDTO(BaseModel):
# Prevents Excessive Data Exposure: Excludes password hashes and internal tokens!
username: str
email: str
@app.route("/api/v2/users/profile", methods=["PUT"])
def update_profile_secure():
try:
# Pydantic validates payload against strict schema allowlist
validated_dto = UserProfileUpdateDTO(**request.get_json())
except ValidationError as e:
return jsonify({"error": "Invalid property payload", "details": e.errors()}), 422
# Safe update: Only validated DTO attributes are touched
user = UserDatabaseModel(user_id=101, username="sdet_aarav", email="aarav@example.com")
user.username = validated_dto.username
user.email = validated_dto.email
# Return filtered output DTO (Never return raw database model directly!)
response_data = UserProfileResponseDTO(username=user.username, email=user.email)
return jsonify(response_data.dict())
from functools import wraps
from flask import Flask, request, jsonify, g
app = Flask(__name__)
# Mock session context: User authenticated with standard "STUDENT" role
@app.before_request
def load_user_session():
# Decoded from JWT: user_id=101, role="STUDENT"
g.user_id = 101
g.user_role = "STUDENT"
# ==============================================================================
# SECURE ROLE-BASED ACCESS CONTROL (RBAC) DECORATOR
# ==============================================================================
def require_roles(*allowed_roles):
"""Enforces strict function-level authorization at the endpoint route handler."""
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
if not hasattr(g, 'user_role') or g.user_role not in allowed_roles:
# Log unauthorized attempt for SIEM audit
print(f"[SECURITY ALERT]: User {g.user_id} ({g.user_role}) attempted to execute "
f"restricted function {request.path} [{request.method}]!")
return jsonify({"error": "Forbidden: Insufficient functional privileges"}), 403
return f(*args, **kwargs)
return wrapper
return decorator
# ------------------------------------------------------------------------------
# INSECURE ENDPOINT (VULNERABLE TO BFLA):
# Developer hid the "Delete User" button in the frontend HTML, but forgot to check
# the user's role on the backend endpoint!
# ------------------------------------------------------------------------------
@app.route("/api/v1/users/<int:target_user_id>", methods=["DELETE"])
def delete_user_insecure(target_user_id):
# FLAW: Executes delete operation without verifying g.user_role == "ADMIN"!
return jsonify({"status": "deleted", "target": target_user_id})
# ------------------------------------------------------------------------------
# SECURE HARDENED ENDPOINT:
# Protected by function-level decorator enforcing ADMIN role
# ------------------------------------------------------------------------------
@app.route("/api/v2/users/<int:target_user_id>", methods=["DELETE"])
@require_roles("ADMIN", "SUPER_ADMIN")
def delete_user_secure(target_user_id):
return jsonify({"status": "deleted", "target": target_user_id})
if __name__ == "__main__":
print("[*] Testing BFLA security gate...")
?limit=9999999), oversized JSON request bodies, and expensive computational endpoints cause API denial of service and memory exhaustion.
from flask import Flask, request, jsonify
app = Flask(__name__)
# HARDENED RESOURCE GOVERNANCE LIMITS:
MAX_PAGE_SIZE = 50 # Hard upper bound on pagination requests
DEFAULT_PAGE_SIZE = 20 # Default safe fallback
MAX_CONTENT_LENGTH = 1048576 # 1 MB maximum incoming JSON payload cap
app.config['MAX_CONTENT_LENGTH'] = MAX_CONTENT_LENGTH
@app.errorhandler(413)
def request_entity_too_large(error):
return jsonify({"error": "Payload Too Large: Max request body limit is 1MB"}), 413
# ==============================================================================
# SECURE HARDENED PAGINATION ENDPOINT
# ==============================================================================
@app.route("/api/v1/transactions", methods=["GET"])
def get_transactions():
"""
Vulnerability Defended:
Adversary requests: GET /api/v1/transactions?limit=10000000&offset=0
Server executes SELECT * FROM transactions LIMIT 10000000;
Loads 10 million rows into RAM, causing an Out-Of-Memory (OOM) kernel crash!
"""
try:
# Extract and sanitize page parameters
requested_limit = int(request.args.get("limit", DEFAULT_PAGE_SIZE))
offset = int(request.args.get("offset", 0))
if requested_limit < 1 or offset < 0:
return jsonify({"error": "Limit and offset must be positive integers"}), 400
except ValueError:
return jsonify({"error": "Malformed pagination parameters"}), 400
# ENFORCE HARD UPPER BOUND: Clamp limit to MAX_PAGE_SIZE!
effective_limit = min(requested_limit, MAX_PAGE_SIZE)
# Simulated bounded database query
# SELECT * FROM transactions LIMIT effective_limit OFFSET offset
return jsonify({
"page_limit_applied": effective_limit,
"offset": offset,
"max_allowed_limit": MAX_PAGE_SIZE,
"data": [f"Transaction #{i}" for i in range(1, effective_limit + 1)]
})
BUSINESS LOGIC FLOW SUBVERSION ARCHITECTURE:
THE CORE CHALLENGE:
β’ The API works EXACTLY as designed. There is no SQLi, no buffer overflow, no BOLA bug.
β’ The vulnerability is AUTOMATION AT SCALE against a sensitive business transaction.
CASE STUDY 1: PROMOTIONAL SIGNUP BONUS FARMING:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Business Intent: "Each new verified student gets Rs. 500 academic credit." β
β Attack Scenario: Adversary spins up automated headless Puppeteer script: β
β 1. Calls POST /api/v1/register 5,000 times using disposable email domains. β
β 2. Calls POST /api/v1/claim_voucher across all 5,000 generated accounts. β
β 3. Transfers Rs. 25,00,000 worth of vouchers to a master account! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
CASE STUDY 2: HIGH-SPEED TICKET / INVENTORY HOARDING:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Business Intent: "Users reserve seats for 10 minutes while entering payment details." β
β Attack Scenario: Adversary bot network calls POST /api/v1/seats/reserve for EVERY seat in β
β the auditorium the millisecond tickets go on sale. Legitimate users see "Sold Out". β
β Scalper bot scalps tickets on external forums for 500% profit, releasing unsold seats later. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DEFENSIVE HEURISTIC FRAMEWORK:
1. Proof of Work / CAPTCHA Verification: Gate sensitive endpoints (signup, reserve) with turnstile tokens.
2. Device Fingerprinting & Behavioral Velocity: Track mouse movements, request cadences, and client TLS JA4.
3. Strict Business Flow Rate-Limiting: Limit reservation actions to 2 per verified Aadhaar/credit card per day.
4. Disposable Email & Virtual Number Blocking: Validate domains against real-time disposable email blacklists.
/v1/ that lack modern patches and remain exposed on the public internet).
API INVENTORY THREAT TOPOGRAPHY: SHADOW VS. ZOMBIE ENDPOINTS:
1. ZOMBIE APIS (DEPRECATED BUT STILL ACTIVE):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Production Current: https://api.nikita-infotech.com/v3/users (Protected by MFA, Rate Limits, DTOs)β
β β
β Forgotten Endpoint: https://api.nikita-infotech.com/v1/users (Deployed in 2021, never retired) β
β β
β Attack Vector: β
β β’ Attacker discovers /v1/ via historical documentation, Wayback Machine, or fuzzing. β
β β’ The v1 endpoint connects to the SAME PRODUCTION DATABASE, but lacks MFA and BOLA checks! β
β β’ Attacker exploits BOLA on /v1/ to dump modern production data, bypassing all /v3/ controls! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. SHADOW APIS (UNTRACKED & UNDOCUMENTED):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Debug Endpoints: /api/test/dump_db, /api/debug/login_as_user, /api/v2/swagger.json β
β Deployed by development teams during testing; accidentally routed to public internet gateway. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
INVENTORY GOVERNANCE AUTOMATION (CI/CD PIPELINE AUDITING):
β’ OpenAPI / Swagger Contract Verification: No endpoint can be exposed on the public API gateway
without a verified, machine-readable OpenAPI 3.0 specification registered in the service mesh.
β’ Automated Sunset Headers: Deprecated versions emit HTTP Sunset headers before automatic retirement:
Sunset: Wed, 11 Nov 2026 00:00:00 GMT
Deprecation: @1794355200
import requests
from typing import Dict, Any
class BolaSecurityScanner:
"""
Automated Multi-Tenant BOLA Vulnerability Scanner:
1. Authenticates as User A (Victim) and creates an object.
2. Authenticates as User B (Attacker).
3. Attempts to read, update, or delete User A's object using User B's token.
4. If operation returns HTTP 200 OK, flags a CRITICAL BOLA vulnerability!
"""
def __init__(self, base_url: str):
self.base_url = base_url.rstrip("/")
def audit_endpoint_for_bola(self, endpoint_template: str, user_a_id: int,
user_a_token: str, user_b_token: str) -> dict:
# Step 1: Construct target object URL belonging to User A
target_url = f"{self.base_url}{endpoint_template.replace('{id}', str(user_a_id))}"
headers_attacker = {
"Authorization": f"Bearer {user_b_token}",
"User-Agent": "SecOps-Api-Auditor/1.0"
}
print(f"[*] Probing Object Endpoint: {target_url} using Attacker Token...")
try:
# In a live test: response = requests.get(target_url, headers=headers_attacker, timeout=5)
# Simulated audit logic for demonstration:
simulated_status_code = 200 # Simulating vulnerable endpoint leak
simulated_body = {"record_id": user_a_id, "data": "CONFIDENTIAL_EXAM_SCORES"}
if simulated_status_code == 200:
return {
"vulnerable": True,
"severity": "CRITICAL",
"cwe": "CWE-639 (BOLA)",
"message": f"CRITICAL LEAK: User B successfully accessed User A's object via {target_url}!",
"leaked_data": simulated_body
}
elif simulated_status_code in [403, 404]:
return {"vulnerable": False, "status": "Secure: Access rejected by endpoint."}
else:
return {"vulnerable": False, "status": f"Unexpected HTTP status: {simulated_status_code}"}
except Exception as e:
return {"vulnerable": False, "error": str(e)}
if __name__ == "__main__":
scanner = BolaSecurityScanner("https://api.nikita-infotech.com")
print("==========================================================================")
print(" AUTOMATED BOLA / IDOR REST API SECURITY AUDIT")
print("==========================================================================")
audit_result = scanner.audit_endpoint_for_bola(
endpoint_template="/api/v1/students/{id}/grades",
user_a_id=101,
user_a_token="TOKEN_USER_A_VICTIM",
user_b_token="TOKEN_USER_B_ATTACKER"
)
print(f"[*] Audit Verdict : {'VULNERABLE (BOLA)' if audit_result['vulnerable'] else 'SECURE'}")
print(f"[*] Severity Rating : {audit_result.get('severity', 'NONE')}")
print(f"[*] Diagnostic Note : {audit_result.get('message', audit_result.get('status'))}")
Access-Control-Allow-Origin: * with credentials), verbose stack traces leaking internal paths, and missing API gateway rate limiting.
API SECURITY DEFECTS & ARCHITECTURAL CORRECTIONS:
// ==============================================================================
// PITFALL 1: PERMISSIVE CORS MISCONFIGURATION WITH CREDENTIALS
// DEFECT:
// Access-Control-Allow-Origin: *
// Access-Control-Allow-Credentials: true
// FLAW: Browsers reject wildcards with credentials, but developers bypass this by
// dynamically reflecting the incoming Origin header:
// Access-Control-Allow-Origin: $_SERVER['HTTP_ORIGIN'] // VULNERABLE!
// ATTACK: An attacker hosts a page on evil.com; the API reflects Origin: evil.com,
// enabling the attacker's script to read confidential API responses via AJAX!
// CORRECTION: Enforce an explicit allowlist of trusted origins:
// $allowed = ['https://portal.nikita-infotech.com'];
// if (in_array($_SERVER['HTTP_ORIGIN'], $allowed)) { header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']); }
// ==============================================================================
// ==============================================================================
// PITFALL 2: EXPOSING INTERNAL DATABASE STACK TRACES (API8:2023)
// DEFECT: Uncaught exception returns raw SQL and file paths:
// HTTP/1.1 500 Internal Server Error
// {"error": "PDOException: SQLSTATE[42S02]: Base table or view not found in /var/www/api/v1/user.php:44"}
// FLAW: Leaks database technology (MySQL/PostgreSQL), table names, and internal file paths.
// CORRECTION: Catch all exceptions globally; log the technical trace internally to
// monitoring tools, and return a sanitized JSON error response to callers:
// {"error": "An internal error occurred. Transaction ID: TXN-88219"}
// ==============================================================================
// ==============================================================================
// PITFALL 3: ACCEPTING ARBITRARY HTTP VERBS (METHOD TAMPERING)
// DEFECT: Route handler processes request without validating HTTP verb:
// @app.route("/api/users/<id>", methods=["GET", "POST", "DELETE", "PATCH"])
// def handle_user(id): ...
// FLAW: WAF rules may inspect only GET or POST traffic; attackers bypass filters
// by sending unexpected verbs like HEAD or PATCH.
// CORRECTION: Map endpoints to single, explicit HTTP verbs. Reject unlisted verbs with 405.
// ==============================================================================
OWASP API SECURITY TOP 10 SPECIFICATION MATRIX:
βββββββββββββ¬ββββββββββββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β OWASP ID β VULNERABILITY NAME β CWE NUMBER β ATTACK VECTOR β MANDATORY ENTERPRISE DEFENSE β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API1:2023 β Broken Object Level β CWE-639 β Parameter Tamper β Bind user identity in databaseβ
β β Authorization (BOLA) β (IDOR) β (IDs in URL) β WHERE clause on every query β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API2:2023 β Broken Authentication β CWE-287 β Credential spray,β Rate limiting, strong JWT β
β β β β weak tokens, MFA β verification, secure resets β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API3:2023 β Broken Object Property β CWE-915 / β Mass Assignment, β Strict Input DTO allowlists; β
β β Level Authorization β CWE-213 β Data Exposure β Output serialization filters β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API4:2023 β Unrestricted Resource β CWE-770 β DoS, pagination β Enforce MAX_PAGE_SIZE limits; β
β β Consumption β β exploitation β Request body size caps (1MB) β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API5:2023 β Broken Function Level β CWE-285 β Admin route drop,β Endpoint route-handler RBAC β
β β Authorization (BFLA) β β HTTP verb swap β decorators; Default Deny β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API6:2023 β Unrestricted Business β CWE-799 β Bot ticket scalp,β CAPTCHAs, behavioral velocity β
β β Flow Access β β bonus farming β rate-limiting, KYC validation β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API7:2023 β Server-Side Request β CWE-918 β Webhooks, Cloud β Single DNS resolve, IP pinningβ
β β Forgery (SSRF) β β metadata theft β Enforce AWS IMDSv2 tokens β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API8:2023 β Security β CWE-16 β Permissive CORS, β Strict origin allowlists, β
β β Misconfiguration β β verbose traces β Generic error messages β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API9:2023 β Improper Inventory β CWE-1059 β Shadow APIs, β OpenAPI contract enforcement, β
β β Management β β Zombie v1 routes β Automated deprecation sunsets β
βββββββββββββΌββββββββββββββββββββββββββΌβββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β API10:2023β Unsafe API Consumption β CWE-20 β Poisoned 3rd β Validate incoming webhook dataβ
β β β β party vendor dataβ Treat external APIs as untrustβ
βββββββββββββ΄ββββββββββββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β TOP 5 API SECURITY DESIGN PRINCIPLES: β
β 1. Validate Object Ownership on Every Request: Check both record ID and authenticated user ID. β
β 2. Use Strict DTOs for Input and Output: Avoid automatic model binding to prevent mass assignment. β
β 3. Enforce Route-Level RBAC: Check roles at the endpoint handler, not just in client-side code. β
β 4. Bound All Requests: Set hard upper limits on pagination queries and request payload sizes. β
β 5. Maintain an Active API Inventory: Track all endpoints and retire legacy versions regularly. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ