The REST API GOAT project is a deliberately vulnerable API application designed for security
professionals to practice identifying and exploiting common API security vulnerabilities. This
comprehensive guide will walk you through installation, configuration, and exploitation techniques.
🎓 Learning Objectives:
Understand REST API architecture and common vulnerabilities
Master tools like Postman and Burp Suite for API testing
Identify and exploit OWASP API Security Top 10 vulnerabilities
Practice real-world API penetration testing scenarios
⚙️ Installation & Setup
System Requirements
Linux-based operating system (Ubuntu/Debian recommended)
Step 1: Login and note your user IDPOST /login → Returns JWT token and user_id: 2Step 2: Request your own data (baseline)GET /api/v1/customer/2 → Success: Returns your dataStep 3: Try accessing another user's dataGET /api/v1/customer/1 → Success: Returns user 1's data
(VULNERABILITY!)GET /api/v1/customer/4 → Success: Returns user 4's data
(VULNERABILITY!)Step 4: Test the secure endpointGET /api/v2/customer/1 → Error: Unauthorized (Properly secured)
🔍 What to Look For:
Sequential IDs (1, 2, 3...) - easy to enumerate
Missing authorization checks on GET requests
Different responses for existing vs. non-existing resources
Company_id or tenant_id not properly validated
Business Logic Vulnerabilities
The REST API GOAT includes a money transfer feature with a critical race condition vulnerability.
The Double-Spend Attack
🎯 Exploitation Scenario:
User has $1000 in their account
Create Transfer #1: Send $1000 to external account
Create Transfer #2: Send $1000 to external account (before processing #1)
Process both transfers before balance check
Result: $2000 transferred from $1000 balance!
Testing the Vulnerability:PUT /api/transfer → Create first transfer (amount: 1000)PUT /api/transfer → Create second transfer (amount: 1000) QUICKLY!POST /api/transfer/1/process → Process first transferPOST /api/transfer/2/process → Process second transferGET /api/balance → Check final balance (negative or zero)
SQL Injection in APIs
SQL injection can occur in unexpected places within REST APIs.
📍 Common Injection Points:
Search parameters: GET /api/products?search=';DROP TABLE--
Sorting parameters: GET /api/users?sort=name' OR '1'='1
Filter parameters: GET /api/orders?status=pending' UNION SELECT
PUT/PATCH request bodies with insufficient validation
Testing for SQL Injection:GET /api/search?q=' OR '1'='1 → Test for boolean-based SQLiGET /api/search?q=' UNION SELECT NULL-- → Test for union-based SQLiGET /api/search?q=' AND SLEEP(5)-- → Test for time-based SQLi
🎓 Practice Exam Overview
Cheese Store API Exam Scenario
In the practice exam, you'll receive a Cheese Inventory Management API with deliberately planted
vulnerabilities. Your task is to identify and document at least 7 out of 10 critical security
flaws.
🧀 Cheese Store API Features:
User registration and JWT-based authentication
Cheese inventory management (CRUD operations)
Sales processing system
Purchase history tracking
Multiple user roles and permissions
API Endpoints Overview
Endpoint
Method
Description
Auth Required
/register
POST
Create new user account
No
/login
POST
Authenticate and receive JWT
No
/cheeses
GET
List all cheeses in inventory
Yes
/cheeses
POST
Add new cheese to inventory
Yes
/cheeses/{id}
GET
Get specific cheese details
Yes
/cheeses/{id}
PUT
Update cheese information
Yes
/cheeses/{id}/sell
POST
Process cheese sale
Yes
What You'll Receive
📦 Exam Package Contents:
Tkinter-based GUI application for testing the API
Complete Python source code (Flask API implementation)
SQLite database with sample data
Instructions for running the application
Finding API Documentation
The first step is discovering how to access the API documentation:
Common Documentation Endpoints:http://localhost:5107/apidocshttp://localhost:5107/api-docshttp://localhost:5107/swaggerhttp://localhost:5107/docs
Expected Vulnerability Types
Missing Authorization
Endpoints that should require authentication but don't validate JWT tokens.
IDOR Vulnerabilities
Access other users' data by manipulating resource IDs in requests.
SQL Injection
Unsanitized inputs in search, filter, or update operations.
Weak JWT Implementation
Insecure token generation, missing expiration, or weak secrets.
Broken Access Control
Users accessing admin functions or bypassing role restrictions.
Business Logic Flaws
Race conditions, negative quantities, or insufficient validation.
🔬 Testing Methodology
Step-by-Step Testing Approach
API Security Testing Workflow
1. Reconnaissance & Documentation Discovery
↓
2. Authentication Testing
↓
3. Authorization & Access Control Testing
↓
4. Input Validation Testing
↓
5. Business Logic Testing
↓
6. Documentation & Reporting
Phase 1: Reconnaissance
Discovery Commands:curl http://localhost:5107/ → Check for index page or API infocurl http://localhost:5107/apidocs → Look for Swagger/OpenAPI docscurl -X OPTIONS http://localhost:5107/cheeses → Check allowed methodscurl -I http://localhost:5107/ → Examine response headers
Phase 2: Authentication Testing
Test User Registration
POST /registerBody: {"username": "testuser", "password": "Test123!"}
Test Login Mechanism
POST /loginBody: {"username": "testuser", "password": "Test123!"}
Analyze JWT Token
Decode token at jwt.io
Check algorithm (HS256 vs none)
Verify expiration time
Look for sensitive data in payload
Phase 3: Authorization Testing
🎯 Test Scenarios:
Access endpoints without authentication token
Use expired or invalid tokens
Modify token payload (user_id, role)
Access resources belonging to other users
Attempt privilege escalation to admin role
Phase 4: Input Validation
Test Type
Payload Example
Expected Behavior
SQL Injection
' OR '1'='1
Should be sanitized
XSS
<script>alert(1)</script>
Should be escaped
Command Injection
; ls -la
Should be rejected
Negative Numbers
{"quantity": -10}
Should be validated
Oversized Input
"A" * 10000
Should have limits
Phase 5: Business Logic Testing
Race Condition Testing:# Terminal 1: Create transfercurl -X POST http://localhost:5107/transfer -H "Authorization: Bearer TOKEN"
-d '{"amount":1000}'# Terminal 2: Create another transfer simultaneouslycurl -X POST http://localhost:5107/transfer -H "Authorization: Bearer TOKEN"
-d '{"amount":1000}'# Process both before balance checkcurl -X POST http://localhost:5107/transfer/1/confirmcurl -X POST http://localhost:5107/transfer/2/confirm
Documentation Template
📝 Vulnerability Report Structure:
Vulnerability Name: e.g., "SQL Injection in Search Endpoint"
Severity: Critical / High / Medium / Low
Affected Endpoint:GET /api/search
Description: Brief explanation of the vulnerability
Steps to Reproduce: Detailed reproduction steps
Proof of Concept: Request/response examples
Impact: What an attacker could achieve
Remediation: How to fix the vulnerability
Tools Checklist
Tool
Purpose
Key Features
Postman
API Testing
Collection management, environment variables
Burp Suite
Intercepting Proxy
Request modification, scanning, repeater
curl
Command-line Requests
Scripting, automation, quick testing
jwt.io
JWT Analysis
Token decoding, verification
sqlmap
SQL Injection
Automated SQLi detection and exploitation
🎯 Key Takeaways
Always start with reconnaissance - Find documentation, understand endpoints
Test authentication thoroughly - Weak JWT implementation is common
Look for IDOR vulnerabilities - Test access to other users' resources
Don't forget business logic - Race conditions and validation bypasses
Document everything - Clear, reproducible proof of concepts
Think like an attacker - What's the worst that could happen?