๐Ÿ”’ OWASP API Security Training

SOAP VS REST APIs

Important Note: SOAP and REST are often compared, but this comparison isn't entirely accurate since SOAP is a protocol while REST is an architectural style. Understanding their fundamental differences is crucial for API security testing.

๐Ÿ“‹ Overview

This comprehensive guide explores the key differences between SOAP and REST APIs, their security implications, and their practical applications in modern systems. Understanding these differences is essential for proper API security testing and vulnerability assessment.

๐Ÿงผ SOAP (Simple Object Access Protocol)

Key Characteristics

SOAP Request Example

POST /InStock HTTP/1.1 Host: example.org Content-Type: application/soap+xml Content-Length: [length] <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> <Authentication> <Username>user123</Username> <Password>pass456</Password> </Authentication> </soap:Header> <soap:Body> <GetStockPrice> <StockName>AAPL</StockName> </GetStockPrice> </soap:Body> </soap:Envelope>

SOAP Response Example

<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <GetStockPriceResponse> <Price>150.25</Price> <Currency>USD</Currency> </GetStockPriceResponse> </soap:Body> </soap:Envelope>

SOAP Components

๐Ÿ”„ REST (Representational State Transfer)

Key Characteristics

REST Request Example

POST /api/products HTTP/1.1 Host: api.example.com Content-Type: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... { "productName": "Laptop", "price": 999.99, "category": "Electronics" }

REST Response Example

HTTP/1.1 201 Created Content-Type: application/json { "id": 12345, "productName": "Laptop", "price": 999.99, "category": "Electronics", "createdAt": "2026-03-12T10:30:00Z" }

REST Components

โš–๏ธ Key Differences Comparison

Aspect SOAP REST
Type Protocol Architectural Style
Communication Method Service Operations CRUD Operations (Create, Read, Update, Delete)
Message Format XML only JSON, XML, HTML, plain text
State Management Can be stateful or stateless Always stateless
Error Handling Built-in (SOAP Fault element) Standard HTTP status codes
Protocol Support HTTP, SMTP, FTP, etc. HTTP/HTTPS only
Performance Slower (XML parsing overhead) Faster (lightweight, especially with JSON)
Ease of Use More complex, requires tools Simple, can use browser or basic tools
Caching Not supported by default Built-in HTTP caching support
Standards Strict standards (WS-Security, WS-AtomicTransaction) Flexible, fewer standards

๐Ÿ“Š API Communication Flow Diagrams

SOAP Communication Flow

Client
โ†’
SOAP Envelope (XML)
โ†’
Server


Server
โ†’
SOAP Response (XML)
โ†’
Client

REST Communication Flow

Client
โ†’
HTTP Request (JSON/XML)
โ†’
Server


Server
โ†’
HTTP Response + Status
โ†’
Client

๐ŸŽฏ Use Cases and Applications

SOAP - Best Used For:

REST - Best Used For:

๐Ÿ” Security Implications

โš ๏ธ Common Security Vulnerabilities

Both SOAP and REST APIs share several security challenges that must be addressed:

SOAP Security Considerations

Common SOAP Security Commands

wsdler.py -u http://target.com/service?wsdl
soapui -Dfile.encoding=UTF-8 -jar soapui.jar
curl -X POST -H "Content-Type: text/xml" -d @soap_request.xml http://target.com/service

REST Security Considerations

Common REST Security Testing Commands

curl -X GET "http://api.target.com/users" -H "Authorization: Bearer TOKEN"
curl -X POST "http://api.target.com/users" -H "Content-Type: application/json" -d '{"username":"test","password":"test123"}'
curl -X PUT "http://api.target.com/users/123" -H "Authorization: Bearer TOKEN" -d '{"email":"[email protected]"}'
curl -X DELETE "http://api.target.com/users/123" -H "Authorization: Bearer TOKEN"
ffuf -u http://api.target.com/FUZZ -w wordlist.txt -H "Authorization: Bearer TOKEN"
wfuzz -c -z file,wordlist.txt http://api.target.com/api/FUZZ
postman newman run collection.json --environment env.json

Security Testing with Burp Suite

java -jar burpsuite.jar

Configure proxy settings: 127.0.0.1:8080, then intercept and modify API requests

๐Ÿ”’ Best Practices for Both

๐Ÿš€ Modern Alternatives

GraphQL

A query language for APIs that allows clients to request exactly the data they need. Provides a single endpoint with flexible queries.

curl -X POST http://api.target.com/graphql -H "Content-Type: application/json" -d '{"query":"{ users { id name email } }"}'

gRPC (Google Remote Procedure Call)

High-performance RPC framework using HTTP/2 and Protocol Buffers. Excellent for microservices communication.

grpcurl -plaintext -d '{"name":"John"}' localhost:50051 user.UserService/GetUser

๐ŸŽ“ Practical API Security Testing Workflow

Step 1: Reconnaissance

nmap -p 80,443,8080 -sV target.com
nikto -h http://target.com/api
gobuster dir -u http://target.com/api -w wordlist.txt

Step 2: API Documentation Discovery

curl http://target.com/api/swagger.json
curl http://target.com/api/openapi.json
curl http://target.com/api/docs

Step 3: Authentication Testing

curl -X POST http://target.com/api/login -d '{"username":"admin","password":"password"}' -H "Content-Type: application/json"
hydra -l admin -P passwords.txt target.com http-post-form "/api/login:username=^USER^&password=^PASS^:F=incorrect"

Step 4: Authorization Testing (BOLA/IDOR)

curl -X GET http://target.com/api/users/1 -H "Authorization: Bearer TOKEN"
curl -X GET http://target.com/api/users/2 -H "Authorization: Bearer TOKEN"
for i in {1..100}; do curl -s http://target.com/api/users/$i -H "Authorization: Bearer TOKEN"; done

Step 5: Injection Testing

curl -X GET "http://target.com/api/users?id=1' OR '1'='1" -H "Authorization: Bearer TOKEN"
sqlmap -u "http://target.com/api/users?id=1" --batch --cookie="session=TOKEN"

Step 6: Rate Limiting Testing

for i in {1..1000}; do curl -X POST http://target.com/api/login -d '{"username":"test","password":"test"}'; done
ab -n 1000 -c 10 http://target.com/api/endpoint

๐Ÿ“ Conclusion

Key Takeaways:

Next Steps in API Security:

In the following lessons, we will dive deeper into specific API vulnerabilities including OWASP API Security Top 10, explore GraphQL security in detail, and work with real-life examples and vulnerable APIs to practice exploitation and remediation techniques.